Skip to content

fix: context ring always opens context stats panel - #156

Merged
jeonghun-jj-lee merged 1 commit into
local/amicodefrom
fix/context-ring-always-opens-stats
Aug 9, 2026
Merged

fix: context ring always opens context stats panel#156
jeonghun-jj-lee merged 1 commit into
local/amicodefrom
fix/context-ring-always-opens-stats

Conversation

@jeonghun-jj-lee

Copy link
Copy Markdown
Contributor

Problem

Clicking the circular context-stats ring while on the file changes tab sometimes failed to switch to the context stats panel.

Root Causes

1. Wrong toggle detection (session-context-usage.tsx)

contextVisible used a local tabState.activeTab() derived from createSessionTabs with a missing review accessor. When the real active tab was "review", the fallback logic incorrectly returned "context" (if it was still in all()), causing the ring to close context instead of opening it.

Fix: Read tabs().active() directly from the store.

2. Kobalte trigger registration timing (session-side-panel.tsx)

The context Tabs.Trigger was gated behind <Show when={contextOpen()}>. When openSessionTab simultaneously adds "context" to all and sets active="context", Kobalte processes the value prop change before the Show mounts the trigger element — it can't find it, so nothing switches.

Fix: Replace <Show> with display: none on a wrapper div. The trigger stays registered with Kobalte at all times; it just becomes visible when context is open.

Test

Added a test exercising the close → reopen cycle, confirming the state transforms produce the correct activeTab() at each step.

Two bugs prevented the circular ring from reliably switching to the
context stats tab:

1. session-context-usage: contextVisible used a local tabState.activeTab()
   derived from createSessionTabs with a missing review accessor. When the
   active tab was 'review', the fallback logic returned 'context' if it was
   still in all(), causing the ring to close instead of open. Fixed by
   reading tabs().active() directly.

2. session-side-panel: the context Tabs.Trigger was gated behind
   <Show when={contextOpen()}>, which unmounts the trigger when context is
   closed. When openSessionTab simultaneously adds 'context' to all and
   sets active='context', Kobalte processes the value change before the
   Show mounts the trigger, so it can't find it. Fixed by replacing Show
   with display:none on a wrapper div — the trigger stays registered with
   Kobalte at all times.

Added a test exercising the close-then-reopen cycle to verify the state
transforms produce the correct activeTab at each step.
@jeonghun-jj-lee
jeonghun-jj-lee merged commit 1b06950 into local/amicode Aug 9, 2026
1 of 4 checks passed
@jeonghun-jj-lee
jeonghun-jj-lee deleted the fix/context-ring-always-opens-stats branch August 9, 2026 03:25
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