🤖 feat: archive workspace navigates to next sibling instead of project page#2367
🤖 feat: archive workspace navigates to next sibling instead of project page#2367
Conversation
…page When archiving the active workspace, prefer navigating to the adjacent workspace in sidebar DOM order (matching Ctrl+J behaviour) rather than always falling back to the project page. The project page is still the fallback when no other workspaces are visible. Extracted getVisibleWorkspaceIds/findAdjacentWorkspaceId into a shared utility (workspaceDomNav.ts) used by both App.tsx Ctrl+J/K and the archive handler in WorkspaceContext.
…gate Eliminates duplication - the archive handler now delegates to setSelectedWorkspace() for the next-workspace case, matching the delete handler's pattern. The project-page fallback still uses manual navigateToProject since setSelectedWorkspace(null) routes to home.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d784b6fbd3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…sist+navigate duplication Both the archive and delete handlers were manually clearing selectedWorkspaceRef + SELECTED_WORKSPACE_KEY + calling navigateToProject when falling back to a project page. Extracted this into a clearSelectionToProject() callback next to setSelectedWorkspace. Also fixes a latent bug in the delete handler's project-page fallback which called navigateToProject without clearing the ref or persisted state (the route change would eventually fix it, but the ref was stale within the same tick).
When the archived workspace's sidebar row isn't rendered (project or section is collapsed), indexOf returns -1. Previously this returned null, falling back to the project page even when other workspaces were visible. Now returns the first visible workspace that isn't the one being removed — matching Ctrl+J's fallback behaviour.
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
The integration CI runs Jest for tests/ which can't resolve bun:test. Unit tests using bun:test belong in src/ where only bun runs them. Switched from tests/ui/dom import to inline happy-dom setup (same pattern as layoutSlotHotkeys.test.ts).
Integration tests already prove the feature end-to-end. The unit tests just re-verified Array.indexOf and document.querySelectorAll.
Summary
When archiving the active workspace, the app now navigates to the next adjacent workspace in sidebar DOM order (matching Ctrl+J behaviour) instead of always falling back to the project page. The project page remains the fallback when no other workspaces are visible.
Background
Previously, archiving the workspace you were viewing always dropped you onto the project page. This was jarring when you had other active workspaces — you'd have to manually re-select one. The new behaviour mirrors how Ctrl+J picks the next workspace from DOM order, keeping you in flow.
Implementation
src/browser/utils/ui/workspaceDomNav.ts— New shared utility with:getVisibleWorkspaceIds()— reads[data-workspace-id][data-workspace-path]elements from the DOMfindAdjacentWorkspaceId(id)— prefers the item after the current workspace, falls back to the item before, returnsnullwhen there are no otherssrc/browser/contexts/WorkspaceContext.tsx— Archive subscription handler now callsfindAdjacentWorkspaceId()and navigates to the next workspace (vianavigateToWorkspace). Falls back tonavigateToProjectwhennullis returned.src/browser/App.tsx—handleNavigateWorkspace(Ctrl+J/K) refactored to use the sharedgetVisibleWorkspaceIds()utility.Validation
archiving the active workspace navigates to the next sibling workspace— creates 2 workspaces, archives the active one, asserts the URL updates to the second workspace.archiving the only workspace in a project falls back to project page— confirms single-workspace-archive still lands on the project page.tests/ui/workspaceDomNav.test.ts— 8 tests covering next/prev/only/missing/empty cases.make static-checkpasses.Generated with
mux• Model:anthropic:claude-opus-4-6• Thinking:xhigh• Cost:$-