Skip to content

fix(tab-area): key active plugin lookup by id - #2726

Merged
KagamiChan merged 1 commit into
poooi:masterfrom
momocow:fix/plugin-tab-active-id
Sep 15, 2026
Merged

KagamiChan merged 1 commit into
poooi:masterfrom
momocow:fix/plugin-tab-active-id

Conversation

@momocow

@momocow momocow commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Fixes #2725

Problem

The active plugin tab renders the wrong plugin's title and icon when a plugin declares a poiPlugin.id that differs from its package name. The tab content is correct — only the label and icon are wrong.

Cause

plugin.id is the tab key everywhere in views/components/tab-area/: PluginWrap key={plugin.id} (left-panel.tsx, right-panel.tsx), onSelectTab(plugin.id), and ui.activePluginName, which selectTab resolves through findChildByKey against those rendered keys.

Four spots compared against packageName instead. read-plugin.ts only defaults id to the package name (const id = getString(poiPlugin, 'id') ?? packageName), so for plugins that omit poiPlugin.id the two are equal and the mismatch is invisible. When a plugin sets its own id, the lookup falls through to ?? tabbedPlugins[0], silently substituting the first tabbed plugin by priority.

Changes

All four packageName comparisons in tab-area/index.tsx now use id:

  • :441 — activePlugin lookup, the source of the tab label and icon (the reported symptom)
  • :400 — the same lookup for the macOS touchbar
  • :234 — number-key tab-switch keys
  • :359 — touchbar tab keys

The last two are the same bug rather than drive-by edits: keys built from packageName never match a rendered child key for such a plugin, so findChildByKey fails and the switch is a silent no-op.

Testing

npm run typecheck and ESLint on the changed file both pass. No tests were added — views/components/tab-area/ has no test files today, so covering this would mean introducing React component test infrastructure; happy to do that in a follow-up if you'd like it.

Tab keys are plugin.id everywhere else (PluginWrap key, onSelectTab,
ui.activePluginName), so plugins declaring a custom poiPlugin.id fell
through to tabbedPlugins[0] and showed another plugin's title and icon.

Refs poooi#2725

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@KagamiChan

Copy link
Copy Markdown
Member

/ai-review

@petit-chiba petit-chiba Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review:

No actionable findings.

views/components/tab-area/index.tsx previously used plugin.packageName in four places where the rest of the file already keys tabs by plugin.id: the PluginWrap key={plugin.id} children, onSelectTab(plugin.id), ui.activePluginName, and the render/focus lookups at lines 332/417/427/432. Since read-plugin.tsx:82 defaults id to packageName, the replacements at lines 234, 359, 400, and 441 are behavior-preserving for plugins without a custom poiPlugin.id and correct the mismatch only when the plugin declares its own id — which is exactly the reported symptom (wrong title/icon) and the silent no-op number-key/touchbar paths. I verified the change against the rendered tab keys (tab-contents-union.tsx findChildByKey/childrenKey, plugin-wrapper.tsx id={plugin.id}, right-panel.tsx plugin contents) and the Plugin.id type guarantee, and found no new failure mode, including for the touchbar and auto-switch paths that already selected by id.

@KagamiChan KagamiChan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm holding this because there's some progress to make to reach an agreement

@KagamiChan KagamiChan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks good now as per our discussion

@KagamiChan
KagamiChan merged commit 7e1c97b into poooi:master Sep 15, 2026
1 check passed
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.

Plugin tab shows the wrong title and icon when poiPlugin.id differs from the package name

2 participants