refactor: extract workspace layout actions and pane state logic

This commit is contained in:
Mohamed Boudra
2026-03-18 09:39:12 +07:00
parent 30a225ce9f
commit e2f20f0e24
14 changed files with 2156 additions and 1548 deletions
@@ -87,6 +87,31 @@ describe("deriveWorkspaceTabModel", () => {
expect(model.activeTab?.descriptor.target).toEqual({ kind: "agent", agentId: "agent-b" });
});
it("normalizes preferredTarget before overriding focused tab selection", () => {
const model = deriveWorkspaceTabModel({
tabs: [
{
tabId: "file_/repo/worktree/README.md",
target: { kind: "file", path: "/repo/worktree/README.md" },
createdAt: 1,
},
{
tabId: "agent_agent-a",
target: { kind: "agent", agentId: "agent-a" },
createdAt: 2,
},
],
focusedTabId: "agent_agent-a",
preferredTarget: { kind: "file", path: "\\repo\\worktree\\README.md" },
});
expect(model.activeTabId).toBe("file_/repo/worktree/README.md");
expect(model.activeTab?.descriptor.target).toEqual({
kind: "file",
path: "/repo/worktree/README.md",
});
});
it("keeps retargeted tab ids stable while matching upgraded targets", () => {
const model = deriveWorkspaceTabModel({
tabs: [