Repository navigation
fix(tab-area): key active plugin lookup by id - #2726
Conversation
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>
|
/ai-review |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
I'm holding this because there's some progress to make to reach an agreement
KagamiChan
left a comment
There was a problem hiding this comment.
looks good now as per our discussion
Fixes #2725
Problem
The active plugin tab renders the wrong plugin's title and icon when a plugin declares a
poiPlugin.idthat differs from its package name. The tab content is correct — only the label and icon are wrong.Cause
plugin.idis the tab key everywhere inviews/components/tab-area/:PluginWrap key={plugin.id}(left-panel.tsx,right-panel.tsx),onSelectTab(plugin.id), andui.activePluginName, whichselectTabresolves throughfindChildByKeyagainst those rendered keys.Four spots compared against
packageNameinstead.read-plugin.tsonly defaultsidto the package name (const id = getString(poiPlugin, 'id') ?? packageName), so for plugins that omitpoiPlugin.idthe two are equal and the mismatch is invisible. When a plugin sets its ownid, the lookup falls through to?? tabbedPlugins[0], silently substituting the first tabbed plugin by priority.Changes
All four
packageNamecomparisons intab-area/index.tsxnow useid::441—activePluginlookup, 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 keysThe last two are the same bug rather than drive-by edits: keys built from
packageNamenever match a rendered child key for such a plugin, sofindChildByKeyfails and the switch is a silent no-op.Testing
npm run typecheckand 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.