Skip to content

refactor(workspace): polish tab context menu#29

Open
nianshou555qiansui wants to merge 3 commits into
ohmygit-hub:mainfrom
nianshou555qiansui:feat/tab-context-menu-polish
Open

refactor(workspace): polish tab context menu#29
nianshou555qiansui wants to merge 3 commits into
ohmygit-hub:mainfrom
nianshou555qiansui:feat/tab-context-menu-polish

Conversation

@nianshou555qiansui

@nianshou555qiansui nianshou555qiansui commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

What

Follow-up to #26 addressing the review nits plus a right-click bug I hit while using the feature.

  • Right-click no longer switches tabs. Right-clicking a background tab now only opens the context menu; it no longer activates that tab (matches Chrome/VS Code). Done by preventing the default focus on right mousedown so reka-ui's TabsTrigger @focus auto-activation doesn't fire.
  • Batch closes preserve the surviving tab's history. closeOtherTabs and closeTabsToRight previously wiped both nav stacks entirely, dropping the kept tab's back/forward history too. Both now use a new removeSnapshotTabs helper that strips only the closed tab URLs from the stacks (mirroring how single-tab closeTab uses removeSnapshotTab). Note: the initial push only fixed closeOtherTabs, despite this description claiming both — good catch in review. closeTabsToRight is fixed in 1981c49 together with regression tests covering the reported repro.
  • "Close all" is disabled on the no-op case. Added a canCloseAllTabs guard so the item is disabled when the workspace is already just the default /inbox tab, and closeAllTabs early-returns in that case.
  • Distinct icon for "Close all". Switched from a third X to Trash2 so it scans apart from the other close actions.

Why

These are the three nits from the #26 review (kept-tab history reset, close-all no-op guard, icon variety) plus the right-click-activates-tab behavior, which felt wrong in daily use.

Testing

  • Added regression tests (use-workspace-tabs.test.ts) that drive the composable through a memory-history router and reproduce the reviewed flow; both failed at the canGoBack assertion before the fix and pass after.
  • Merged current main (v0.0.13) into the branch; no conflicts.
  • pnpm --filter @oh-my-github/client typecheck passes.
  • Full monorepo test suite passes (pnpm -r test: api 254 + client 244 tests).
  • Manually verified in the running dev app: right-click keeps the current tab; "Close all" disabled only on the lone default tab and enabled otherwise with the trash icon.

- Right-clicking a tab no longer switches to it (prevent focus-driven
  activation on the tab trigger); the context menu still opens.
- Batch closes (close others / close to the right) now preserve the
  surviving tabs' navigation history instead of wiping both stacks,
  mirroring single-tab close (removeSnapshotTabs).
- 'Close all' is disabled when the workspace is already just the default
  inbox tab, avoiding a redundant no-op.
- 'Close all' uses a distinct trash icon to stand out from the other items.

Follow-up to ohmygit-hub#26 addressing review nits.

@AidenNovak AidenNovak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The “Close tabs to the right” path is still clearing navigation history.

The PR description says both closeOtherTabs and closeTabsToRight now preserve the surviving tab's history, but the diff only changes closeOtherTabs. closeTabsToRight still sets backStack.value and forwardStack.value to empty arrays.

I reproduced this from the production Electron build at commit ecff9dc. I opened Inbox and Needs Review, switched between them so Back was enabled, kept Needs Review active, then right-clicked Inbox and chose “Close tabs to the right.” Inbox was left open, but both Back and Forward became disabled.

The build, typecheck, and existing test suite all pass (68 files, 459 tests), so the current tests do not cover this interaction.

Could you update closeTabsToRight so it removes only the closed tab URLs from the navigation stacks, and add a regression test for this flow?

Before closing:

Two tabs before closing tabs to the right

Context menu on the background Inbox tab:

Context menu on background Inbox tab

After closing tabs to the right:

Inbox remains with Back and Forward disabled

@nianshou555qiansui
nianshou555qiansui marked this pull request as draft July 13, 2026 18:41
…he right

The PR description claimed both closeOtherTabs and closeTabsToRight kept the
surviving tabs' navigation history, but only closeOtherTabs was actually
changed; closeTabsToRight still cleared both stacks. Route it through
removeSnapshotTabs as well, and add regression tests covering the reported
repro.
@nianshou555qiansui
nianshou555qiansui marked this pull request as ready for review July 18, 2026 11:11
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