Skip to content

fix(workspace): stop layout jumps and stale chrome when switching workspaces - #224

Merged
juacker merged 2 commits into
mainfrom
fix/workspace-switch-layout-jumps
Sep 30, 2026
Merged

juacker merged 2 commits into
mainfrom
fix/workspace-switch-layout-jumps

Conversation

@juacker

@juacker juacker commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Problem

When you switched from workspace A to workspace B, the page kept showing A's data until B's details finished loading. That included A's header, drawer, counts and run state. So pressing Stop or Ctrl+C during that time could cancel A's run. The chat area's padding also animated on every switch.

Fix (src/pages/Workspace.tsx)

  • The raw state is renamed to rawDetails. Every consumer now reads details, which is only set once it matches the current workspaceId, so everything is gated by default.
  • While B loads, the header shows the sidebar title with title editing turned off, and the drawer shows "Loading…".
  • Replies and updater writes that belong to a workspace you already left are dropped. They are checked at every await point, and a ref updated in a layout effect tracks the current workspace.
  • The chat area is keyed by workspace, so its padding no longer animates on a switch.

Tests

Workspace.test.tsx covers:

  • the Stop button and counts not showing A's run while B loads;
  • the drawer and tasks/memories/artifactCount gates;
  • the sidebar title shown while loading;
  • A's late reply being dropped after switching to B.

Lint, typecheck and vitest (700 tests) pass locally.

Not covered

  • The padding animation can't be tested in jsdom. It needs a check in the real app.
  • Known follow-ups from review (minor): A's in-flight runNowBusy/pauseBusy flags and setError calls can still land on B, an existing error banner survives the switch, and the catch/finally guards have no test.

…kspaces

The page instance is reused across workspace navigation, so the header,
drawer, attention banner and run controls rendered the previous
workspace's details until the new ones loaded, and the chat pane animated
its side-panel padding from the previous workspace's layout.

- Render header, drawer, tasks, roster and active run from details that
  belong to the current workspace; show the rail's title meanwhile.
- Keep the drawer shell open with a loading state during the switch.
- Key the chat pane by workspace so its padding applies without the
  220ms transition.
- Keep the title's rename padding stable while details load.
…left workspace

- Rename the state to rawDetails; details is the workspace-gated value, so the
  fork-prompt effect, stop-lock clear and settings modal are gated too.
- loadDetails and the title/pause optimistic updaters ignore results for a
  workspace the user has left.
- Apply titleEditable only when the title is editable again.
- Test the rail title during loading, the gated counts/attention banner, and
  a late reply from the previous workspace.
@juacker
juacker marked this pull request as ready for review September 30, 2026 09:05
@juacker
juacker merged commit e0615f1 into main Sep 30, 2026
2 checks passed
@juacker
juacker deleted the fix/workspace-switch-layout-jumps branch September 30, 2026 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant