fix: bound sidebar snapshots and remove blocking discovery

Merged
AU
2mo ago
+1924-900

Sidebar workspace churn retained closed-workspace snapshots in two caches and could subscribe rendering to live pane bookkeeping. Both sidebar implementations now share one bounded snapshot owner. Lifecycle and event handlers populate immutable snapshots; rendering only reads them. Current workspace values are delivered when observation starts so a title update during membership changes cannot be lost.

Two independent blocking paths are also repaired: browser discovery coalesces scans on a dedicated I/O queue, and native FSEvents registration/teardown runs asynchronously with callback state retained until cleanup. Git watcher replacement is generation-fenced and preserves the installed watcher until a replacement succeeds.

Closes #12791.

Browser import uses one composition-root-owned coordinator across Settings, menus, browser views, and automation. Admission precedes profile creation. Pure destination resolution and tests live in CmuxBrowser; the app adapter decodes RPC parameters, maps localized errors, and performs storage mutation. Stable UUID selection takes precedence, ambiguous names fail, and blank UUID inputs fall back to a supplied name.

Current head: 1d9676d4d95fa51d9e0496e2f8293715343fb8a3, synced through main 2be7607733418f4f3c6ca41eb73cc511e593ae50.

  • Resolved Settings constructor/call-site and Xcode project conflicts, retaining both import coordination and main's automation/onboarding dependencies. Removed app references for types main moved into packages.
  • Reused the exact project-wiring repair from #14461, with cherry-pick provenance, after main's missing AgentChatProseStreamWakeDriver entry broke compilation.
  • Added CmuxSidebarGit to CI's package-test list. Its 53-test run exposed an obsolete assertion predating main's deliberate directory-trust policy (67d6b2a705). The test now verifies clearing unattributed metadata at first trust, with complementary coverage preserving metadata on a repeated trusted path and clearing it on a changed path. Production policy is unchanged.
  • Removed the ineffective .common run-loop test workaround; the actual subscription-gap repair remains.

Validation:

  • Current CI: all completed checks pass; compile admission is waiting for a hosted runner. The expanded package job passed, including all 54 CmuxSidebarGit tests and both new directory-provenance cases.
  • Focused app tests: compilation and execution passed, with 16 browser-import XCTest cases and 10 Swift Testing tests across Settings, snapshot lifetime, and snapshot ownership. Both renderers completed five churn cycles with retained=1, live=1. This tests da813a56c0, whose production and app-test sources are identical to current head; only the two standalone package-test files changed afterward.
  • Project normalization, test wiring, package groups, Swift file-length guard, and whitespace checks pass. Project-normalizer tests: 12 passed. Package-selection behavior tests pass.
  • Localization audit: browser-import scope errors and moved import copy use catalog keys; 9 catalogs across 9 supported locales have zero parity errors.
  • Current-head dev build/live UI verification remains blocked before submission: the tagged backend service returned HTTP 429 at its 320-instance registration limit, with no existing tag to reuse. Fleet complaint 4f9c0692f664d7ef3fe71e2f records the failure. Older artifacts are not current-head evidence.

All 15 existing review threads have a disposition and are resolved, including the outdated localization thread. The top-level package-boundary finding is implemented. Render-time cache population remains declined because it writes observed state during SwiftUI projection; lifecycle reconciliation owns that work. The immutable constructor-injected watcher factory remains to exercise native registration deterministically. The optional blanket docstring percentage is not used as a correctness gate; the public resolver API is documented.

Evidence boundary: the issue groups alerts from independent paths without raw stacks. These changes repair snapshot retention/observation, discovery, and native watcher blocking; they do not establish one cause for all 26 alerts. Titlebar, geometry, and icon-observer paths require their own telemetry attribution. Native discovery calls finish under their owner when callers cancel; callers discard the result. Native watcher cleanup completes asynchronously after Swift consumers finish.