mirror of
https://github.com/jlengrand/Maestro.git
synced 2026-03-10 08:31:19 +00:00
MAESTRO: Clear activeFileTabId when selecting an AI tab
Modify setActiveTab function to deselect any active file preview tab when an AI tab is selected. This ensures only one tab type (AI or file) is active at a time. Updated early-return condition to also check if activeFileTabId is null before returning unchanged session.
This commit is contained in:
@@ -72,6 +72,9 @@ function createMockSession(overrides: Partial<Session> = {}): Session {
|
||||
aiTabs: [],
|
||||
activeTabId: '',
|
||||
closedTabHistory: [],
|
||||
filePreviewTabs: [],
|
||||
activeFileTabId: null,
|
||||
unifiedTabOrder: [],
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
@@ -578,6 +581,22 @@ describe('tabHelpers', () => {
|
||||
expect(result!.session.activeTabId).toBe('tab-2');
|
||||
expect(result!.tab).toBe(tab2);
|
||||
});
|
||||
|
||||
it('clears activeFileTabId when selecting an AI tab', () => {
|
||||
const tab = createMockTab({ id: 'tab-1' });
|
||||
const session = createMockSession({
|
||||
aiTabs: [tab],
|
||||
activeTabId: 'tab-1',
|
||||
activeFileTabId: 'file-tab-1', // A file tab was active
|
||||
});
|
||||
|
||||
const result = setActiveTab(session, 'tab-1');
|
||||
|
||||
// Should return a new session with activeFileTabId cleared
|
||||
expect(result!.session).not.toBe(session);
|
||||
expect(result!.session.activeFileTabId).toBeNull();
|
||||
expect(result!.session.activeTabId).toBe('tab-1');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getWriteModeTab', () => {
|
||||
|
||||
@@ -440,19 +440,22 @@ export function setActiveTab(session: Session, tabId: string): SetActiveTabResul
|
||||
return null;
|
||||
}
|
||||
|
||||
// If already active, return current state (no mutation needed)
|
||||
if (session.activeTabId === tabId) {
|
||||
// If already active and no file tab is selected, return current state (no mutation needed)
|
||||
if (session.activeTabId === tabId && session.activeFileTabId === null) {
|
||||
return {
|
||||
tab: targetTab,
|
||||
session,
|
||||
};
|
||||
}
|
||||
|
||||
// When selecting an AI tab, deselect any active file preview tab
|
||||
// This ensures only one tab type (AI or file) is active at a time
|
||||
return {
|
||||
tab: targetTab,
|
||||
session: {
|
||||
...session,
|
||||
activeTabId: tabId,
|
||||
activeFileTabId: null,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user