From d16413ef4306ddb5875dc52e96aa51ff3a39b4d5 Mon Sep 17 00:00:00 2001
From: Teknium <127238744+teknium1@users.noreply.github.com>
Date: Mon, 17 Aug 2026 16:01:49 -0700
Subject: [PATCH] fix(desktop): stop Skills Hub picker overlaying the installed
list and cut Capabilities lag
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Layout (overlap bug): the EmbeddedHubPicker section had no flex
containment — its fixed-height iframe viewport made the section's
min-content height rigid, so at a tall persisted drag height or a short
window the flex column starved the installed-skills area to 0px and the
hub header row painted straight over the list's sort strip and "changes
apply to new sessions" footer. The picker section now clips its own
content (overflow-hidden, shrinkable, min-h for the header row), the hub
viewport uses flex-basis instead of a hard height so it gives pixels
back first, the list region keeps a min-h-40 floor, and the sash drag is
clamped against the actual column height (list reserve) rather than just
the window.
Perf (Capabilities lag):
- The hub iframe (a full Docusaurus site) mounted eagerly with the view
and re-mounted on every scope change (key={`picker-${scopeKey}`}).
It now lazy-mounts the first time the Skills tab is shown, then stays
mounted but display:none across Tools/MCP so a tab bounce never
reloads the site. The scope key is gone — the picker fetches nothing;
the profile rides into each install call as a prop.
- EmbeddedHubPicker is memo()ed and subscribes to the single
UPDATE_ALL_KEY running flag via useStoreSelector instead of the whole
$hubActions map, which churns on every tailed log line during installs.
- Collapse state now persists through the pane store (0 = collapsed),
matching DetailPane, instead of resetting open on every mount.
- CapRow gets content-visibility:auto so 80+ row lists skip offscreen
layout/paint (fixed row heights keep scroll geometry stable).
Validation: npm run check:lint (tsc x3 + eslint) clean; vitest
src/app/skills 9/9 passing, including a new test asserting the iframe
is absent on non-Skills tabs, mounts with the Skills tab, and survives
a tab switch hidden.
---
apps/desktop/src/app/master-detail.tsx | 6 +-
.../src/app/skills/embedded-hub-picker.tsx | 82 +++++-
apps/desktop/src/app/skills/index.test.tsx | 36 +++
apps/desktop/src/app/skills/index.tsx | 275 +++++++++---------
4 files changed, 252 insertions(+), 147 deletions(-)
diff --git a/apps/desktop/src/app/master-detail.tsx b/apps/desktop/src/app/master-detail.tsx
index f62edff46d..3b8ad95bab 100644
--- a/apps/desktop/src/app/master-detail.tsx
+++ b/apps/desktop/src/app/master-detail.tsx
@@ -449,7 +449,11 @@ export function CapRow({
return (
@@ -46,15 +58,28 @@ interface EmbeddedHubPickerProps {
/** The Skills Hub browser for the Skills tab: a resizable iframe of the live
* hub where every card installs with one click. Expanded by default —
- * discovery IS the point — with a collapse toggle and an update-all action. */
-export function EmbeddedHubPicker({ installedNames, profile }: EmbeddedHubPickerProps) {
+ * discovery IS the point — with a collapse toggle (persisted, like every
+ * other pane) and an update-all action. Memoized: the iframe must not sit in
+ * the parent's keystroke/re-render path. */
+export const EmbeddedHubPicker = memo(function EmbeddedHubPicker({
+ hidden = false,
+ installedNames,
+ profile
+}: EmbeddedHubPickerProps) {
const { t } = useI18n()
const h = t.skills.hub
- const [open, setOpen] = useState(true)
- const updating = useStore($hubActions)[UPDATE_ALL_KEY]?.running ?? false
+ // Subscribe to the ONE flag this header renders, not the whole action map —
+ // $hubActions churns on every tailed log line during an install.
+ const updating = useStoreSelector($hubActions, actions => actions[UPDATE_ALL_KEY]?.running ?? false)
+ // Collapse state rides the same persisted height override the sash writes
+ // (0 = collapsed to the header), so "Hide the hub browser" survives tab
+ // switches and restarts instead of re-expanding — and re-loading the docs
+ // site — on every visit. Same contract as DetailPane.
const heightOverride = useStore($paneHeightOverride(HUB_PANE_ID))
const height = heightOverride ?? HUB_DEFAULT_PX
+ const open = height > HUB_COLLAPSED_PX
const [dragging, setDragging] = useState(false)
+ const sectionRef = useRef(null)
// Top-edge sash: dragging UP grows the hub (shrinking the skills list above,
// which is the flex-1 sibling). Same gesture as DetailPane / the shell's
@@ -68,7 +93,13 @@ export function EmbeddedHubPicker({ installedNames, profile }: EmbeddedHubPicker
event.preventDefault()
const startY = event.clientY
const startHeight = height
- const max = Math.round(window.innerHeight * HUB_MAX_VH)
+ // Clamp against the actual Capabilities column, not just the window: the
+ // hub may never grow past "column minus the list's reserved strip", so
+ // the installed list always keeps real height and its header/footer can't
+ // end up sharing pixels with the hub header.
+ const column = sectionRef.current?.parentElement
+ const columnMax = column ? column.clientHeight - HUB_LIST_RESERVED_PX : Number.POSITIVE_INFINITY
+ const max = Math.max(HUB_MIN_PX, Math.round(Math.min(window.innerHeight * HUB_MAX_VH, columnMax)))
setDragging(true)
const onMove = (move: globalThis.PointerEvent) => {
@@ -131,7 +162,20 @@ export function EmbeddedHubPicker({ installedNames, profile }: EmbeddedHubPicker
}
return (
-
{/* Resizable viewport: height comes from the top-edge drag sash
- above (persisted; double-click resets). The iframe is rendered
+ above (persisted; double-click resets). flex-basis instead of a
+ hard height so a short window shrinks the hub viewport rather
+ than letting it spill over the list. The iframe is rendered
oversized and scaled DOWN (133% × 0.75) so the hub page starts
zoomed out — the cross-origin page itself can't be styled, but
scaling the frame is ours. */}
@@ -168,9 +218,9 @@ export function EmbeddedHubPicker({ installedNames, profile }: EmbeddedHubPicker
style={{
border: '1px solid var(--ui-stroke-secondary)',
borderRadius: 8,
- height,
+ flex: `0 1 ${height}px`,
maxWidth: '100%',
- minHeight: HUB_MIN_PX,
+ minHeight: 0,
minWidth: 320,
overflow: 'hidden',
position: 'relative',
@@ -194,9 +244,9 @@ export function EmbeddedHubPicker({ installedNames, profile }: EmbeddedHubPicker
title={h.pickerTitle}
/>
-
{h.pickerHint}
+
{h.pickerHint}
)}
-
+
)
-}
+})
diff --git a/apps/desktop/src/app/skills/index.test.tsx b/apps/desktop/src/app/skills/index.test.tsx
index fbbcd8fa04..ab5fc30265 100644
--- a/apps/desktop/src/app/skills/index.test.tsx
+++ b/apps/desktop/src/app/skills/index.test.tsx
@@ -292,6 +292,42 @@ describe('SkillsView toolset management', () => {
)
})
+ it('mounts the hub iframe lazily and keeps it (hidden) across tab switches', async () => {
+ // On a non-Skills tab the docs-site iframe must not exist at all — an
+ // eagerly mounted hub is exactly the Capabilities lag bug.
+ await renderSkills() // ?tab=toolsets
+ await screen.findByRole('switch', { name: 'Turn Web Search toolset off' })
+ expect(document.querySelector('iframe')).toBeNull()
+ cleanup()
+
+ // Embedded mode drives tabs through local state (the route hooks are
+ // mocked here), starting on Skills: the picker mounts with the tab.
+ const { SkillsView } = await import('./index')
+ await act(async () => {
+ render(
+
+
+
+
+
+ )
+ })
+
+ const iframe = document.querySelector('iframe')
+ expect(iframe).toBeTruthy()
+ expect(iframe!.closest('section')!.classList.contains('hidden')).toBe(false)
+
+ // Switch to Tools → the iframe STAYS mounted (no docs-site reload on the
+ // next visit) but its section is fully hidden, so nothing from the hub
+ // can paint over the toolsets UI.
+ await act(async () => {
+ fireEvent.click(screen.getByRole('button', { name: /Tools/ }))
+ })
+ const kept = document.querySelector('iframe')
+ expect(kept).toBeTruthy()
+ expect(kept!.closest('section')!.classList.contains('hidden')).toBe(true)
+ })
+
it('shows a vision explainer that deep-links to Settings → Models', async () => {
// Vision has no TOOL_CATEGORIES provider matrix — its model lives in the
// auxiliary model config, so the detail pane must point there instead of
diff --git a/apps/desktop/src/app/skills/index.tsx b/apps/desktop/src/app/skills/index.tsx
index 5f12039c01..cc895b7cfb 100644
--- a/apps/desktop/src/app/skills/index.tsx
+++ b/apps/desktop/src/app/skills/index.tsx
@@ -211,6 +211,17 @@ export function SkillsView({
const [query, setQuery] = useState('')
+ // The hub picker hosts a full docs-site iframe — the single most expensive
+ // thing on this page. It mounts lazily (first time the Skills tab is shown)
+ // and then STAYS mounted but hidden across tab switches, so bouncing to
+ // Tools/MCP and back never reloads the site. Derived-state pattern: flips
+ // once, during render, never back.
+ const [hubMounted, setHubMounted] = useState(mode === 'skills')
+
+ if (mode === 'skills' && !hubMounted) {
+ setHubMounted(true)
+ }
+
// Capabilities profile-scope selector: which profile's Tools/MCP config we're
// editing. Defaults to the app-wide active profile; overriding it here lets
// the user configure ANY profile's toolsets/MCP without switching the whole
@@ -670,138 +681,142 @@ export function SkillsView({
profile. */}
{profileScopeSelector}
-
- {mode === 'mcp' ? (
-
- ) : (skillsFailed || toolsetsFailed) && (!skills || !toolsets) ? (
- void refreshCapabilities()} size="sm">
- {t.skills.refresh}
-
- }
- description={skillsError instanceof Error ? skillsError.message : undefined}
- icon="error"
- title={t.skills.skillsLoadFailed}
- />
- ) : !skills || !toolsets ? (
-
- ) : mode === 'skills' ? (
- // Installed skills on top, the Skills Hub browser underneath —
- // discovery sits with management, expanded by default. The picker
- // renders even when the (filtered) list is empty: a fresh install
- // with zero skills is exactly when browsing the hub matters most.
-
+ {/* Hub picker OUTSIDE the tab ternary: it lazy-mounts the first time
+ Skills is shown, then stays mounted (hidden) across Tools/MCP so
+ the docs-site iframe never reloads on a tab bounce. No scope key
+ on purpose — the picker fetches nothing; scope rides the
+ `profile` prop into each install call, and remounting on scope
+ change would reload the whole site for no data benefit. */}
+ {hubMounted && (
+
)}