Skip to content

refactor(ui): keep shell lifecycle in native Solid components - #179381

Closed
steipete wants to merge 2 commits into
mainfrom
solid2/w-s2-app-ownership
Closed

steipete wants to merge 2 commits into
mainfrom
solid2/w-s2-app-ownership

Conversation

@steipete

@steipete steipete commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Whole-scope Solid 2 census, base e3fbdbc7 → this head. Counts are before → after; unchanged values appear once. “Candidates” means local presentation work, excluding synchronous domain-owner APIs and deliberate foreign-DOM adapters.

File family 1 unsafe/native bindings 2 component/all cleanup 3 manual read pipelines 4 local mutation flows 5 manual view loaders/runtime imports 6 copied presentation objects 7 manual component factories 8 throw-only contexts 9 sibling loading groups 10 non-island/all owner APIs
app (190 files) 0/30 0/3 1 1 0/67; native lazy 6 → 7 3: focus plus two dialogs in separate PR 0 0 0 6 → 1 / 6 → 1
lib, excluding reactive (345 files) 0/10 0/5 2 1 controller, 3 commands 0/10 1 tab-focus slot 3 foreign-DOM adapter calls 0 0 0/4
plugin presentations (5 files) 0 0/2 1 1 raw + 1 native action 0/1 2: dashboard and history 0 0 0 0
plugin SDK/DOM bridges (5 files) 0 1 / 2 2 foreign mounts, exempt 3 delegated SDK commands, exempt 0/8 1 opaque props slot, exempt 0 0 0 0/7
plain plugin owners (9 files) 0 0 0 presentation wrappers 0 presentation wrappers 0/4 0 0 0 0 0
plain API owners (12 files) 0 0 0 presentation wrappers 0 presentation wrappers 0/2 0 0 0 0 0

Whole-scope production LOC: 91,586 → 91,601 across 566 files (production TypeScript, excluding tests/support/generated declarations). This PR removes five of six app owner API calls: one createRoot, two getOwner, and two runWithOwner. The existing shell-commit runWithOwner remains until commit admission moves into the rendered shell component. The existing readiness effect remains 1 → 1; no guarded call count increases. Tab/dashboard refactors are separate PRs. Item 6 incorporates the corrected later audit: browser-auth recovery, update confirmation and plugin history were omitted from the initial count. The two dialogs are migrated separately in #179405; this PR does not alter those slots.

What Problem This Solves

The shell created an extra Solid root just to subscribe its synchronous owner, and the lazy automation observer restored a captured owner after import.

Why This Change Was Made

Keep ShellOwner plain and synchronous: subscribe directly to theme/catalog changes and filtered router facts, with teardown in its existing disconnect path. Mount the renderless readiness observer as a native lazy component only when automation first reads the hook. Its settled lifecycle connects and disconnects the observer; initial root commitment follows connection because connection clears the prior receipt. Shell settlement retains its existing same-flush admission outside the invalidating caller's lifetime; deferring it to a microtask broke focus restoration and was removed.

The only coupled interface is subscribeI18n in lib/reactive/i18n.ts, exposing the existing translation projection's subscription so lazy English catalog notifications remain included. No new owner or projection is added.

User Impact

Behavior is preserved: automation stays lazy, catches up on first read, and keeps login mounted. Terminal readiness retires on detach and recovers on reattach. Shell updateComplete survives caller disposal and resolves false when its shell is retired. No routes, tags, markup, CSS or E2E selectors change.

Evidence

Proof Result
Warm-boot readiness and caller-disposal regressions 2 tests pass, existing assertions unchanged
Detached-terminal readiness lifecycle Pass, including unmount cleanup
pnpm tsgo:ui (tsrs) Pass
Scoped lint / formatting Pass
Controller guard with --prune Pass; removes two getOwner and two runWithOwner allowances
Independent Codex P0–P2 review Pass; scoped-clean, no actionable findings
Production Knip Pass on repaired head
Base/head UI builds Pass on both; base measurement reused
Strict startup JS gzip 331,221 → 331,248 B (+27 B)
Strict Chat boot JS gzip 1,500,644 → 1,500,652 B (+8 B)
New Session boot JS gzip 1,018,041 → 1,018,041 B (unchanged; under cap)
Startup CSS 1 request, 40,439 B unchanged

Both strict checks retain the pre-existing absolute startup and Chat cap failures. The same-machine comparison adds 27 B and 8 B respectively, satisfying the current “no growth beyond 64 B while over budget” rule. All 21 locale pairs remain under their cap. No budget or baseline is raised.

The first full targeted selection passed 45 tests and exposed one real warm-boot regression: the observer's effect could commit before settled connection, then connection cleared that root receipt. The fix commits the initial root after connecting; the exact failing test now passes. An initial guard check rejected an unnecessary .tsx rename; the renderless module stays at its original .ts path, with no transferred/raised allowance and no E2E path change. One unused test import was removed by scoped lint. These are corrected failures, not inherited exceptions.

Production LOC: 1,504 → 1,520 (+16) across the four production files, including the one-line coupled interface; test LOC: 240 → 246 (+6). The typed observer props and explicit component lifetime account for growth; the nested owner root and capture/restore calls disappear. No new tests duplicate existing behavior: the terminal test now exercises actual component mount, invalidation and teardown instead of manual owner commits.

Remaining scope and permitted exceptions

Full PR CI exposed two scheduler regressions that pass on scheduled main: preserves reload intent on disconnect but clears it on context replacement and reorders plugin sidebar tabs and keeps the order after reload. Both came from the added microtask boundary. The repair restores the existing synchronous onSettled admission and its original shrink-only allowance. The lifecycle case and disposed-caller case pass with their original assertions; focus restoration requires the next full PR CI run. The separate Markdown-table and Telegram automation failures also fail by exact name on scheduled main run 39585413125.

@steipete steipete added the ci:full Keep ordinary native-locale CI selection on the next PR run. label Oct 21, 2026
@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 21, 2026 10:39
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T10:45:44.024636Z 7cae02a Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 21, 2026
@clawsweeper

clawsweeper Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR replaces captured Solid owners and a nested root with native component lifecycles, direct owner subscriptions, and deferred shell settlement.

Example: Automation first reads window.openclawControlUi after login is mounted.

  • Before: The readiness import restores a captured Solid owner to create its observer.
  • After: A renderless lazy component connects the observer after settlement and disconnects it on disposal.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The ownership simplification is coherent and focused, but an attributable exact-head test failure remains.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored refactor is outside the ordinary contributor proof gate; supplied validation exercises lifecycle harnesses, while the related Automations screenshots do not demonstrate this change.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Shell and automation readiness must preserve their behavior while lifecycle ownership moves to native Solid components.
Reason: The maintainer-authored direction removes nested roots and owner restoration without introducing another state owner, changing settings, or expanding the public API.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this maintainer-authored refactor open; its direction is sound, but deferred shell settlement breaks an existing reload-intent test and the exact-head UI check.

Priority: P3
Reviewed head: 7cae02a6e925ae0c19ebab3ccf2a30cb201b628c

Before merge

  • Await deferred shell settlement in the reload-intent test (P2) - Adding queueMicrotask means Solid's synchronous flush() no longer reaches afterCommit(), which replays the stored palette action. The existing preserves reload intent on disconnect but clears it on context replacement test still asserts immediately after flush() at app-host.test.ts:310, so it receives undefined instead of COMMAND_PALETTE_ELEMENT. Exact-head checks-ui (2/3) reports that failure. Update this test to await the shell's committed state before inspecting the palette request, preserving the subsequent context-replacement and intent-retirement assertions.

Findings

  • [P2] Await deferred shell settlement in the reload-intent test — ui/src/app/app-shell-presentation.ts:158-159
Agent review details

How this fits together

The Control UI shell consumes synchronous application, router, theme, and translation facts and publishes rendered shell state and automation readiness.

flowchart TD
  A[Application owners] --> B[ShellOwner subscriptions]
  B --> C[Solid shell presentation]
  C --> D[Deferred commit settlement]
  E[Automation first read] --> F[Lazy readiness component]
  D --> F
  F --> G[Window readiness hook]
Loading

Technical review

Best possible solution:

Keep the native lifecycle refactor and update the reload-intent test to await shell settlement while preserving its replacement and retirement assertions.

Do we have a high-confidence way to reproduce the issue?

Exact-head CI records the reload-intent assertion failure, and source tracing explains why the new native microtask runs after the test's synchronous flush; no target code was executed during this review.

Is this the best way to solve the issue?

The refactor uses existing owners and removes redundant ownership machinery; its smallest complete repair is to synchronize the affected test with the existing settlement contract.

Full review comments:

  • [P2] Await deferred shell settlement in the reload-intent test — ui/src/app/app-shell-presentation.ts:158-159
    Adding queueMicrotask means Solid's synchronous flush() no longer reaches afterCommit(), which replays the stored palette action. The existing preserves reload intent on disconnect but clears it on context replacement test still asserts immediately after flush() at app-host.test.ts:310, so it receives undefined instead of COMMAND_PALETTE_ELEMENT. Exact-head checks-ui (2/3) reports that failure. Update this test to await the shell's committed state before inspecting the palette request, preserving the subsequent context-replacement and intent-retirement assertions.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4cfa119396d4.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test ui/src/app/app-host.test.ts ui/src/app/app-host-lifecycle.test.ts ui/src/app/control-ui-readiness.test.ts --maxWorkers=1
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 9548737 adds ui/src/app/app-shell-presentation.ts:153 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 95487377bde8; files: ui/src/app/app-shell-presentation.ts)

PR surface

Source +16, Tests +6, Other -5. Total +17 across 8 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 88 72 +16
Tests 1 29 23 +6
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 0 5 -5
Total 8 117 100 +17

Labels

Label changes:

  • add P3: This is behavior-preserving lifecycle cleanup with a focused test synchronization repair; no production user failure was established.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P3: This is behavior-preserving lifecycle cleanup with a focused test synchronization repair; no production user failure was established.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 21, 2026, 6:56 AM ET / 10:56 UTC.

@steipete

Copy link
Copy Markdown
Contributor Author

Superseded by #179375, merged as f4f4dec. Current main removes app-host/app-root owner capture, exposes the i18n subscription, and creates readiness inside the application provider's owned branch. I checked those source paths and the removed owner-API allowances. This PR's alternate readiness component has no remaining migration work to contribute, so I am closing this duplicate rather than landing a second readiness design.

@steipete steipete closed this Oct 21, 2026
@RomneyDa
RomneyDa deleted the solid2/w-s2-app-ownership branch October 22, 2026 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui ci:full Keep ordinary native-locale CI selection on the next PR run. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant