Skip to content

Build bar panel content on first open instead of at startup - #15044

Merged
dhh merged 4 commits into
quattrofrom
lazy-panel-content
Oct 12, 2026
Merged

dhh merged 4 commits into
quattrofrom
lazy-panel-content

Conversation

@dhh

@dhh dhh commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

What

KeyboardPanel gets an optional content component slot. A Loader inside the card builds it the first time the panel opens and keeps it from then on, so reopening is instant and in-progress state (scroll position, an edit) survives a close. Panels that still declare children directly keep the old eager behaviour.

Every first-party bar panel moves its card into that slot: network, agents, audio, bluetooth, elsewhen, tailscale, monitor, weather, clock, dropbox, power.

Why

Each bar is built once per monitor, and each bar widget's Panel.qml built its whole card (network ~2150 lines, agents ~2000, audio ~1300, …) at startup whether or not it was ever opened.

How the conversion works

Ids inside the content are no longer visible to the rest of the file, so for each panel:

  • focusTarget and contentHeight read panel.loadedContent / panel.loadedContentHeight.
  • Items root-level code needs are exposed with property alias on the content root. Panels with few references read them through panel.loadedContent at the call site; panels with many (agents, elsewhen, tailscale, dropbox) mirror them as nullable readonly property Item on the root, so existing null guards keep working.
  • Code that runs while the panel is closed (phrase-swap animations, onRestrictedChanged, elsewhen's search/zone bindings, the spin fallback timer) is null-guarded. Elsewhen's opening spin drives the hero, so its open handler builds the content first with panel.ensureContent().
  • Elsewhen's inner id: content became scrollContent so it no longer shadows the new content property.

No timers, processes or IPC handlers lived inside any panel's content, so nothing that has to run while closed moved.

Numbers

One 2560x1440 monitor, shell started fresh three times per build, measured 10s after the first IPC answer:

RSS CPU used in first ~10s first shell ping
before ~497 MB (494–501) ~1.64 s 0.21 s
after ~458 MB (456–460) ~1.37 s 0.21 s

The memory saving grows with each extra monitor. Time to first ping doesn't change because the shell answers IPC before the bar's plugins finish loading.

Verification

  • Ran the shell from this branch and summoned network, audio, bluetooth, monitor, weather, clock, elsewhen, agents and tailscale. Compared screenshots side by side with the same panels on quattro: they match, and the only differences are live data (times, scan results). No QML warnings or errors in the journal.
  • Keyboard focus works on first open: j moves the audio cursor, and Space flips elsewhen to the globe.
  • The captive-portal runtime fixture now checks that a closed network panel hasn't built its content, then builds it on demand and runs the existing assertions against it.
  • New test/shell.d/keyboard-panel-lazy-test.sh covers the lazy contract. A runtime fixture drives the real KeyboardPanel through open, close and reopen, unmapped, and checks that nothing is built while closed, opening builds it, the focus target resolves, and close and reopen keep the same item. A static check makes every first-party KeyboardPanel pass content: and gives every root-level mirror a matching alias. Breaking the keep-after-close latch makes the test fail.
  • The network portal preview captures the whole card again, below the new Loader level.
  • ./test/shell passes apart from the known pre-existing failures.
  • Not checked visually: power (this machine has no battery) and dropbox (not on this bar).

🤖 Generated with Claude Code

dhh and others added 2 commits October 11, 2026 16:20
KeyboardPanel takes an optional `content` component, loaded the first
time the panel opens and kept afterwards. Panels that declare children
directly keep building them eagerly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every bar panel built its whole card on every monitor at startup, open or
not. Move each KeyboardPanel's card into its lazy content slot, reach the
few items root-level code needs through panel.loadedContent, and guard
the code that runs while the panel is closed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@greptile-apps

greptile-apps Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the remaining keyboard-focus test gap is non-blocking.

Findings

  1. P2 First-open behavior goes untested ▶

Summary

The PR builds bar panel content on first open and keeps it for later opens.

  • KeyboardPanel can keep a card unloaded until it opens.
  • Built-in bar panels build their cards on first open.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Panel starts closed] --> B[Content not built]
  B --> C[First open or ensureContent]
  C --> D[Loader builds content]
  D --> E[Close keeps content]
  E --> F[Reopen reuses content]
Loading

Reviews (2) · Last reviewed commit: "Exercise keyboard panel open, close and ..." · Reviewed by Greptile

Comment on lines +11 to +14
assert(/property Component content: null/.test(keyboardPanel), 'keyboard panels take their content as a component')
assert(/active: !!root\.content && \(root\.open \|\| root\.contentRequested\)/.test(keyboardPanel), 'keyboard panel content is built when the panel opens, not at startup')
assert(/if \(content\) contentRequested = true/.test(keyboardPanel), 'keyboard panel content stays built after its first open')
assert(/default property alias contentItem: contentHolder\.children/.test(keyboardPanel), 'keyboard panels that declare children directly still build them eagerly')

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.

P2 First-open behavior goes untested

These checks match source text, while the runtime fixture calls ensureContent() with the panel closed. Neither exercises loading through open, keeping the same item after close/reopen, or keyboard focus on first open. A regression in those paths could still pass.

Add a runtime open/close/reopen check that compares the loaded item and checks focus.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

dhh and others added 2 commits October 11, 2026 16:31
The lazy content Loader adds a level between the content and the card.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@dhh
dhh merged commit 4c1b4cb into quattro Oct 12, 2026
1 check passed
@dhh
dhh deleted the lazy-panel-content branch October 12, 2026 13:54
omarchybot added a commit to scottjones/omarchy-mx-mac that referenced this pull request Oct 12, 2026
Resolves the conflict with omacom#15044, which moved both panels' focusTarget to panel.loadedContent on the line beside centerOnBar: keeps quattro's focusTarget and this branch's centerOnBar: false.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
omarchybot added a commit to MBemera/omarchy that referenced this pull request Oct 12, 2026
Quattro now builds the calendar's content lazily as a KeyboardPanel content Component (omacom#15044), so heroRow is out of scope where the popup width is computed. The content exposes heroWidth, and contentWidth reads it through panel.loadedContent, the way contentHeight already reads loadedContentHeight.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
dmitry-solomadin added a commit to dmitry-solomadin/omarchy that referenced this pull request Oct 13, 2026
Since omacom#15044 the panel builds its content on first open, so the root-level
skyFx.replay() threw a ReferenceError and the sky never faded in. The sky
now replays itself on creation and on each reopen.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
omarchybot added a commit to VykosMolt/omarchy that referenced this pull request Oct 14, 2026
Since omacom#15044 the panel's card is a lazily loaded content component, so its ids are out of reach of root-level bindings. rowOrderPinned read deviceListHover directly and would have failed to resolve, leaving the pin permanently off; it now reaches the handler through panel.loadedContent, as heroStatus does. The section headings take quattro's translated strings.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
omarchybot added a commit that referenced this pull request Oct 16, 2026
The network panel now builds its content on first open (#15044), so `keyCatcher` is no longer an id the panel root can reach and the test's focus probe threw a ReferenceError after quattro was merged in.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@emirb emirb added this to the 4.5 milestone Oct 17, 2026
omarchybot added a commit to iskakaushik/omarchy that referenced this pull request Oct 22, 2026
Since this branch was cut, quattro builds panel content on first open (omacom#15044), routes every string through I18n with catalogs (omacom#15326), restyled the copy menu for right-to-left layouts, and qualifies palette references for Qt 6.12. The branch's intent is ported onto that structure rather than the old one restored.

The machine list, its search field and the shared copy menu now live inside the lazily built content, so root-level code reaches them through `panel.loadedContent` like the panel's other items, and every root caller tolerates them being null before the first open. The account-switch reset still records the last account seen while the panel has never opened, so the first open after a switch is not mistaken for one. The shared copy menu takes quattro's right-to-left placement, opening from whichever end the row's copy button sits at, and `Commons.Color`. The machine count, search placeholder, loading and no-match texts get English catalog entries, with the counts formatted for the language.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
omarchybot added a commit to andrepadez/omarchy that referenced this pull request Oct 22, 2026
Since quattro builds panel content on first open (omacom#15044), ids inside `content` are invisible to root-level code. `scrollCursorIntoView()` names `peerFlick` from the root, so on the merged tree j/k through the machines threw a ReferenceError and the highlighted row never scrolled into view. Mirror it through `panel.loadedContent` like the panel's other scrollers.

The lazy-content test now fails any first-party panel whose root-level code names an id that lives only inside its content, since that error surfaces only when the code runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
shawnduggan added a commit to shawnduggan/omarchy that referenced this pull request Oct 29, 2026
Resolve conflicts with the virtualized machine list (omacom#7623) and the panel
translations (omacom#15326): publishPeers now writes the cached _peers that the
visible peers list derives from, the offline switch sits beside the counted
MACHINES header, and the new switch, empty-state and Offline strings are
English catalog entries. The runtime fixture builds the lazily created panel
content (omacom#15044), feeds statuses as full peer fetches, and qualifies its
palette references (omacom#14553).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CFeF4GVPAdJb4fXF29e79S
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