Show optimistic chat for new workspaces

This commit is contained in:
Mohamed Boudra
2026-05-25 21:26:31 +07:00
parent d271597ee8
commit 30a8bffc24
11 changed files with 452 additions and 140 deletions
@@ -10,6 +10,8 @@ export interface PendingWorkspaceDraftSubmission {
attachments: ComposerAttachment[];
cwd: string;
provider: AgentProvider;
clientMessageId: string;
timestamp: number;
modeId?: string;
model?: string;
thinkingOptionId?: string;
@@ -1772,13 +1772,13 @@ export function reconcileWorkspaceTabs(
continue;
}
if (group.tabs.some((tab) => tab.tabId === originalFocusedTabId)) {
reconciledFocusedTabId = canonicalTabId;
reconciledFocusedTabId = keeper.tabId;
}
if (keeper.tabId !== canonicalTabId || !workspaceTabTargetsEqual(keeper.target, group.target)) {
if (!workspaceTabTargetsEqual(keeper.target, group.target)) {
nextLayout = withNormalizedParentTabMap({
root: replaceTabInTree(asInternalLayout(nextLayout).root, {
tabId: keeper.tabId,
nextTabId: canonicalTabId,
nextTabId: keeper.tabId,
target: group.target,
}),
focusedPaneId: nextLayout.focusedPaneId,
@@ -1354,6 +1354,56 @@ describe("workspace-layout-store actions", () => {
expect(findPaneById(layout.root, "main")?.focusedTabId).toBe("agent_agent-1");
});
it("reconcileTabs preserves a draft-origin agent tab id when there is no duplicate", () => {
const workspaceKey = createWorkspaceKey();
workspaceLayoutStore.setState((state) => ({
...state,
layoutByWorkspace: {
...state.layoutByWorkspace,
[workspaceKey]: {
root: {
kind: "pane",
pane: {
id: "main",
tabIds: ["draft-agent"],
focusedTabId: "draft-agent",
tabs: [
{
tabId: "draft-agent",
target: { kind: "agent", agentId: "agent-1" },
createdAt: 1,
},
],
} as SplitPane,
},
focusedPaneId: "main",
},
},
}));
workspaceLayoutStore.getState().reconcileTabs(workspaceKey, {
agentsHydrated: true,
terminalsHydrated: true,
activeAgentIds: ["agent-1"],
autoOpenAgentIds: ["agent-1"],
knownAgentIds: ["agent-1"],
standaloneTerminalIds: [],
hasActivePendingDraftCreate: false,
});
const layout = workspaceLayoutStore.getState().layoutByWorkspace[workspaceKey];
expect(collectAllTabs(layout.root)).toEqual([
{
tabId: "draft-agent",
target: { kind: "agent", agentId: "agent-1" },
createdAt: 1,
},
]);
expect(findPaneById(layout.root, "main")?.focusedTabId).toBe("draft-agent");
});
it("reconcileTabs does not re-add locally hidden agent tabs", () => {
const workspaceKey = createWorkspaceKey();