Skip to content

Cut warm popup open from ~84ms to ~35ms to first frame - #60

Merged
mstallone merged 20 commits into
mainfrom
perf/ui-02-close-pays-for-close
Aug 2, 2026
Merged

mstallone merged 20 commits into
mainfrom
perf/ui-02-close-pays-for-close

Conversation

@mstallone

Copy link
Copy Markdown
Owner

Supersedes #55, which GitHub auto-closed when its stacked base branch was deleted on the #54 merge. Same change series, now rebased onto main (all review threads from #55 were addressed there and are reflected in this branch).


TL;DR — Warm popup open drops from ~84ms to ~35ms click-to-first-frame (upstream openusage measures 42ms with half our content). Three changes: per-view TimelineViews gated on visibility become one shared observable clock, the panel height is retained across closes instead of reset to 0, and the close settles the hidden tree so the next open finds it clean.

What was happening

  • Every dated metric row (and the footer countdown) wrapped its content in TimelineView behind an if popoverIsVisible gate. The panel's SwiftUI tree survives orderOut, so each open AND close was a structural branch swap that tore down and rebuilt every dated row's subtree — measured as the largest cost in the open's pre-show layoutSubtreeIfNeeded (~57ms avg).
  • Closing reset animatedHeight to the 0 sentinel, so each reopen walked 0 → target: a root frame change that forced a second full-tree layout.
  • The close's cleanup (card collapse, scroll reset) sat in pending transactions until the next open flushed them.

What this changes

  • DashboardClock (new): one 1s/30s wall clock owned by AppContainer, started/stopped at the panel show/hide chokepoints. Rows and the footer read it via observation — stable view structure, no ticks while closed, fresh stamps on open. Environment reads are optional so ImageRenderer share cards (no clock) stay static, matching prior behavior.
  • DashboardView keeps animatedHeight across closes; the reopen seed and the hidden collapsed re-measure walk it un-animated, and same-value seeds are skipped.
  • hidePanel() runs layoutSubtreeIfNeeded() on the hidden tree so close pays for close (~34ms, invisible), replacing the ~70–100ms post-close display-cycle stall.

Heads-up

  • Row tick cadence and countdown behavior are unchanged from the user's perspective (docs/dashboard.md's "tick every 30 seconds" still holds).
  • The measured stall count for the warm open/close phase went from 24 (≈1.9s total) to 1.

Tests

  • Full suite passes (1529 tests). New DashboardClockTests. script/profile_ui.sh before/after on this machine: open.toFirstRunloopTurn 84.1ms → 35.6ms avg; close.syncTotal 3.6ms+deferred-stall → 34.1ms all-inclusive.

…et, per-phase stats, exit trap, timestamped backups
…-for-close

# Conflicts:
#	Sources/Runway/App/StatusItemController.swift
@mstallone
mstallone merged commit 01d279b into main Aug 2, 2026
2 checks passed
@mstallone
mstallone deleted the perf/ui-02-close-pays-for-close branch August 2, 2026 07:44

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 59e426388f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +353 to +357
// The driven height is deliberately KEPT across the close (it used to reset to the 0
// sentinel here). The close-time settle re-measures the collapsed dashboard while hidden and
// the `measuredIdeal` onChange walks the retained value to the collapsed target, so the next
// open finds the height already correct and its pre-show layout pass has nothing to do —
// resetting to 0 made every reopen pay a full-tree re-layout just to walk 0 → target. The

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Cancel retained height animations on close

When the user closes and quickly reopens the panel during a content-driven height morph whose target does not change during cleanup—for example, while a refresh changes a card's height—animatedHeight already contains the final target, so retaining it here neither cancels the active SwiftUI spring nor triggers the hidden measuredIdeal branch. finishClosing() only invalidates existing bridge work; subsequent animation frames can still update the retained hidden tree, and reopening can therefore display an intermediate, still-moving height. Explicitly settle or cancel any active height animation on close while preserving the final target.

Useful? React with 👍 / 👎.

mstallone added a commit that referenced this pull request Oct 6, 2026
**TL;DR**

Second batch from the production cleanup audit: rewrites comments and
one doc page that describe code that no longer exists or no longer works
that way. No code changes.

**What was happening**

- Claude and Codex comments still described the era before read-only
credentials (#84, #90) and guarded renewal (#99): "Runway never
refreshes a Claude token", "so Runway rotates on the same schedule", "a
successful usage fetch (which rotates tokens back to disk)". Two
functions in `CodexAuthStore` carried two doc comments fused together,
the first describing removed behavior.
- `DashboardView` comments said steady state keeps one live screen tree
and that the outgoing page unmounts when the push completes. Since #67
the page stays parked until the popover closes. Others referred to a
"scroll spacer" and an `outgoing` identifier that do not exist.
- `WidgetRowView` described a per-row timeline gate that #60 replaced
with the shared clock, 22 lines below a doc comment saying it is
deliberately not that.
- `MemoryEditorState.saveDirtyDocument` was documented as overwriting a
moved file; it keeps the conflict check.
- Comments named things that are gone or renamed: `EscapeToCloseReader`,
`discover`, `compactValue`, `formatTokens`, `enterpriseUnverified`, a
`Logger` in `LocalUsageServer`, the `MenuBarExtra` label, "Phase 1" of
account discovery, a pinned count on `ProviderRow`.
- `ProviderAuthRetry` was described as shared by every OAuth-style
provider; only Grok calls `fetch`.
- `docs/providers/openrouter.md` said `/credits` is required for a
usable snapshot. The provider renders whatever either endpoint returned
and reports an invalid key only when both return 401 or 403.

**What this changes**

- Rewrites each comment to match the code, after checking the claim
against the current source.
- Moves the keychain-before-file ordering doc in `ClaudeAuthStore` from
the `StoredCandidateLoad` struct to `orderedStoredCandidates`, the
function it describes. This is the only non-comment line movement in the
diff.
- Updates the OpenRouter page.

**Tests**

`swift build --build-tests` passes. The diff changes only comment lines,
apart from the struct move above.
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