Skip to content

feat: add stable workspace switch slots - #585

Closed
wibus-wee wants to merge 2 commits into
mainfrom
feat/workspace-switch-slots
Closed

feat: add stable workspace switch slots#585
wibus-wee wants to merge 2 commits into
mainfrom
feat/workspace-switch-slots

Conversation

@wibus-wee

@wibus-wee wibus-wee commented Sep 10, 2026

Copy link
Copy Markdown
Member

Related issue

Refs #288

Problem / pressure

Workspace switching was duplicated across sidebar, mobile, and organization selectors, while numeric shortcuts need stable targets that do not change when the organization catalog reorders. The shortcut lifecycle from #572 provides one command registration path, but there was no shared workspace transition boundary or durable 1-9 slot model.

Summary

  • Add per-user, per-device workspace ID slots with deterministic initialization, removal without renumbering, reassignment uniqueness, malformed-data recovery, and cross-window storage synchronization.
  • Route ordinary workspace selection through useWorkspaceSwitcher, then register Electron-only Mod+1..9 commands through the existing useCommand lifecycle and conflict index.
  • Add slot assignment controls to Keyboard Shortcuts settings, English/Chinese copy, component integration coverage, and real two-window Electron shortcut smoke coverage.
  • Keep sidebar swipe out of scope for the follow-up PR; this PR intentionally does not close Issue [Feature Request] Easier workspace switching: sidebar swipe and Cmd+1-9 shortcuts #288.

Visual explanation

flowchart LR
  A[Sidebar / mobile / selector] --> S[useWorkspaceSwitcher]
  B[Mod+1..9] --> C[CommandShortcutHost]
  C --> D[workspace.switchSlot.N]
  E[Keyboard settings] --> F[stable workspace ID slots]
  F --> D
  D --> S
  S --> G[preferred slug + workspace context]
  S --> H[active organization]
  S --> I[current window route]
  F <-. storage event .-> J[other renderer windows]
Loading

Before / after

Before After
UI entry points independently updated organization and routing state. Ordinary workspace changes share one workspace-ID transition boundary.
Numeric position depended on catalog presentation and had no command registration. Slots persist stable workspace IDs and expose Electron Mod+1..9 through the unified command registry.
No workspace target configuration or two-window registration evidence. Keyboard settings assign targets; component and Electron smoke tests cover state and renderer lifecycle.

Test plan

  • pnpm check
  • pnpm format
  • pnpm run docs check
  • pnpm e2e:check
  • Fresh pnpm e2e:build
  • pnpm e2e:smoke (4 P0 scenarios, 28 steps, including both Electron renderers)
  • Focused workspace/command integration: 10 tests passed

Context handoff

Instructions for reviewing agents

  • Review focus: Inspect the slot reconciliation/store, dynamic commands in app-commands.tsx, and useWorkspaceSwitcher state transition as the risk-bearing paths.
  • Decisions to challenge: Validate stable ID slots, per-user local persistence, Electron-only defaults, and immediate optimistic workspace context publication.
  • Plausible failures / evidence gaps: Public OSS E2E has one implicit workspace, so actual A-to-B navigation is exercised at the React command-host boundary while real Electron verifies registration in two windows.

Authoring context

  • User goal / directives: Implement the workspace-switching PR after the shortcut lifecycle PR, including stable 1-9 slots, defaults, settings, conflict handling, and regression evidence.
  • Constraints / non-goals: Preserve physical-key semantics and the unified refactor: centralize shortcut lifecycle with TanStack Hotkeys #572 lifecycle; sidebar swipe is a later PR and Issue [Feature Request] Easier workspace switching: sidebar swipe and Cmd+1-9 shortcuts #288 remains open.
  • Risk-bearing decisions: Slot removal leaves a hole, reassignment moves an ID, storage is device-local and user-scoped, and switching publishes identity before best-effort organization activation.
  • Destructive or irreversible behavior: Invalid stored slot payloads are cleared; removed workspace assignments are cleared without shifting surviving slots, and no server data is mutated by slot storage.
  • Deliberately not done or tested: No cloud-only test backdoor was added to create a second OSS E2E workspace; component integration supplies two synthetic workspaces instead.
  • Unknowns / confidence: Main residual risk is cloud organization activation failure after optimistic navigation; this preserves existing UI behavior and is independently reviewable in the shared switch hook.

Original user prompt

Show original prompt
可以来

@wibus-wee

Copy link
Copy Markdown
Member Author

The design does not align with the expected UX direction; closing this PR.

@wibus-wee wibus-wee closed this Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant