MAESTRO: Add handleUnifiedTabReorder function for unified tab reordering

Implements unified tab reorder functionality that operates on the
unifiedTabOrder array, allowing both AI and file preview tabs to be
reordered relative to each other. This supplements the existing
handleTabReorder (AI-only) for the unified tab system.

Changes:
- Added handleUnifiedTabReorder in App.tsx with index validation
- Propagated through useMainPanelProps.ts, MainPanel.tsx, TabBar.tsx
This commit is contained in:
Pedram Amini
2026-02-02 03:29:43 -06:00
parent 115d9a042b
commit 7c06afa405
4 changed files with 43 additions and 0 deletions

View File

@@ -5300,6 +5300,40 @@ You are taking over this conversation. Based on the context above, provide a bri
);
}, []);
/**
* Reorder tabs in the unified tab order. This allows moving both AI and file tabs
* relative to each other. The fromIndex and toIndex refer to positions in unifiedTabOrder.
* This replaces/supplements handleTabReorder for the unified tab system.
*/
const handleUnifiedTabReorder = useCallback(
(fromIndex: number, toIndex: number) => {
setSessions((prev) =>
prev.map((s) => {
if (s.id !== activeSessionIdRef.current) return s;
// Validate indices
if (
fromIndex < 0 ||
fromIndex >= s.unifiedTabOrder.length ||
toIndex < 0 ||
toIndex >= s.unifiedTabOrder.length ||
fromIndex === toIndex
) {
return s;
}
// Reorder the unifiedTabOrder array
const newOrder = [...s.unifiedTabOrder];
const [movedRef] = newOrder.splice(fromIndex, 1);
newOrder.splice(toIndex, 0, movedRef);
return { ...s, unifiedTabOrder: newOrder };
})
);
},
[]
);
/**
* Internal tab close handler that performs the actual close.
* Wizard tabs are closed without being added to history (they can't be restored).
@@ -12588,6 +12622,7 @@ You are taking over this conversation. Based on the context above, provide a bri
handleNewTab,
handleRequestTabRename,
handleTabReorder,
handleUnifiedTabReorder,
handleUpdateTabByClaudeSessionId,
handleTabStar,
handleTabMarkUnread,

View File

@@ -188,6 +188,7 @@ interface MainPanelProps {
onNewTab?: () => void;
onRequestTabRename?: (tabId: string) => void;
onTabReorder?: (fromIndex: number, toIndex: number) => void;
onUnifiedTabReorder?: (fromIndex: number, toIndex: number) => void;
onTabStar?: (tabId: string, starred: boolean) => void;
onTabMarkUnread?: (tabId: string) => void;
onUpdateTabByClaudeSessionId?: (
@@ -453,6 +454,7 @@ export const MainPanel = React.memo(
onNewTab,
onRequestTabRename,
onTabReorder,
onUnifiedTabReorder,
onTabStar,
onTabMarkUnread,
showUnreadOnly,
@@ -1425,6 +1427,7 @@ export const MainPanel = React.memo(
onNewTab={onNewTab}
onRequestRename={onRequestTabRename}
onTabReorder={onTabReorder}
onUnifiedTabReorder={onUnifiedTabReorder}
onTabStar={onTabStar}
onTabMarkUnread={onTabMarkUnread}
onMergeWith={onMergeWith}

View File

@@ -31,6 +31,8 @@ interface TabBarProps {
onNewTab: () => void;
onRequestRename?: (tabId: string) => void;
onTabReorder?: (fromIndex: number, toIndex: number) => void;
/** Handler to reorder tabs in unified tab order (AI + file tabs) */
onUnifiedTabReorder?: (fromIndex: number, toIndex: number) => void;
onTabStar?: (tabId: string, starred: boolean) => void;
onTabMarkUnread?: (tabId: string) => void;
/** Handler to open merge session modal with this tab as source */

View File

@@ -200,6 +200,7 @@ export interface UseMainPanelPropsDeps {
handleNewTab: () => void;
handleRequestTabRename: (tabId: string) => void;
handleTabReorder: (fromIndex: number, toIndex: number) => void;
handleUnifiedTabReorder: (fromIndex: number, toIndex: number) => void;
handleUpdateTabByClaudeSessionId: (
agentSessionId: string,
updates: { name?: string | null; starred?: boolean }
@@ -386,6 +387,7 @@ export function useMainPanelProps(deps: UseMainPanelPropsDeps) {
onNewTab: deps.handleNewTab,
onRequestTabRename: deps.handleRequestTabRename,
onTabReorder: deps.handleTabReorder,
onUnifiedTabReorder: deps.handleUnifiedTabReorder,
onUpdateTabByClaudeSessionId: deps.handleUpdateTabByClaudeSessionId,
onTabStar: deps.handleTabStar,
onTabMarkUnread: deps.handleTabMarkUnread,
@@ -610,6 +612,7 @@ export function useMainPanelProps(deps: UseMainPanelPropsDeps) {
deps.handleNewTab,
deps.handleRequestTabRename,
deps.handleTabReorder,
deps.handleUnifiedTabReorder,
deps.handleUpdateTabByClaudeSessionId,
deps.handleTabStar,
deps.handleTabMarkUnread,