fix(tabs): COD-358 re-query tab after rename cancel

This commit is contained in:
Aamer Akhter
2026-08-23 13:40:42 -04:00
parent 1795a138b3
commit c9ea8bbac5
2 changed files with 14 additions and 2 deletions
+2 -2
View File
@@ -1788,11 +1788,11 @@ Object.assign(CodemanApp.prototype, {
const session = this.sessions.get(sessionId);
if (!session) return;
this._activeRename?.cancel();
const tabName = document.querySelector(`.tab-name[data-session-id="${sessionId}"]`);
if (!tabName) return;
this._activeRename?.cancel();
// Prevent tab re-renders from destroying the input while renaming
this._inlineRenameActive = true;
tabName.classList.add('tab-name-renaming');
+12
View File
@@ -459,6 +459,7 @@ describe('Inline rename input', () => {
app: {
_activeRename: { sessionId: string } | null;
sessions: Map<string, { id: string; name: string }>;
renderSessionTabs: () => void;
startInlineRename: (id: string) => void;
};
}
@@ -475,10 +476,20 @@ describe('Inline rename input', () => {
tabName.textContent = 'Second';
wrap.appendChild(tabName);
document.body.appendChild(wrap);
// Cancelling the first rename is allowed to repaint the tab list. Model
// that synchronously so a target captured before cancel() becomes stale.
const originalRenderSessionTabs = app.renderSessionTabs;
app.renderSessionTabs = () => {
const current = document.querySelector('.tab-name[data-session-id="second-id"]');
current?.replaceWith(current.cloneNode(true));
};
app.startInlineRename('second-id');
app.renderSessionTabs = originalRenderSessionTabs;
return {
firstActive,
secondActive: app._activeRename?.sessionId,
secondInputVisible: !!document.querySelector('.tab-name[data-session-id="second-id"] input.tab-rename-input'),
firstRenameClassActive:
document.querySelector('.tab-name[data-session-id="first-id"]')?.classList.contains('tab-name-renaming') ??
false,
@@ -487,6 +498,7 @@ describe('Inline rename input', () => {
expect(result.firstActive).toBe('first-id');
expect(result.secondActive).toBe('second-id');
expect(result.secondInputVisible).toBe(true);
expect(result.firstRenameClassActive).toBe(false);
});