Skip to content

🤖 feat: archive workspace navigates to next sibling instead of project page#2367

Merged
ammario merged 6 commits intomainfrom
workspace-nav-4bx6
Feb 12, 2026
Merged

🤖 feat: archive workspace navigates to next sibling instead of project page#2367
ammario merged 6 commits intomainfrom
workspace-nav-4bx6

Conversation

@ammar-agent
Copy link
Collaborator

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 DOM
    • findAdjacentWorkspaceId(id) — prefers the item after the current workspace, falls back to the item before, returns null when there are no others
  • src/browser/contexts/WorkspaceContext.tsx — Archive subscription handler now calls findAdjacentWorkspaceId() and navigates to the next workspace (via navigateToWorkspace). Falls back to navigateToProject when null is returned.
  • src/browser/App.tsxhandleNavigateWorkspace (Ctrl+J/K) refactored to use the shared getVisibleWorkspaceIds() utility.

Validation

  • New integration test: 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.
  • Existing test renamed/updated: archiving the only workspace in a project falls back to project page — confirms single-workspace-archive still lands on the project page.
  • Unit tests for the utility: tests/ui/workspaceDomNav.test.ts — 8 tests covering next/prev/only/missing/empty cases.
  • All 7 lifecycle integration tests pass, all 62 non-integration UI tests pass.
  • make static-check passes.

Generated with mux • Model: anthropic:claude-opus-4-6 • Thinking: xhigh • Cost: $-

…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.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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.
@ammar-agent
Copy link
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. 🎉

ℹ️ 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".

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.
@ammario ammario merged commit 7b18a92 into main Feb 12, 2026
23 checks passed
@ammario ammario deleted the workspace-nav-4bx6 branch February 12, 2026 00:15
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.

2 participants