Skip to content

refactor(ui): make the review panel default document part of its slot definition - #125105

Merged
steipete merged 1 commit into
mainfrom
steipete/detail-slot-default-document
Aug 17, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/detail-slot-default-document

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

PR #124824 gave the Review panel a default document — the session diff — by seeding it from the pane's
render lifecycle: seedSessionDiffSidebar(), called from updated(), assigning state.sidebarContent
whenever the detail slot was open with nothing loaded. That fixed the reported bug and is proven by five
e2e cases, but it left the behavior as a special case outside the contract: a render-lifecycle side effect
mutating shared pane state, with a sidebarContent !== null latch quietly doing double duty as both
"already seeded" and "keep the object identity stable".

Meanwhile #124950 and #125019 made every other aspect of a slot — availability, content, empty state,
header actions — part of one declaration. Review's default document was the last thing that wasn't.

Why This Change Was Made

The detail slot now declares its own default document in sidebarPanelDefinitions() like every other
slot declares its content: explicit sidebarContent wins if the operator opened something, otherwise the
session diff resolves when the slot is genuinely open. seedSessionDiffSidebar(), its updated() call,
and its imports are deleted — no shim.

The non-obvious part is object identity. buildSessionDiffSidebarContent() mints a new object per call and
the mounted diff panel takes it as a property, so a resolver that recomputed on every render would hand the
panel a fresh loader each time and refetch sessions.diff in a loop. The old latch prevented that as a side
effect of seeding once. This PR makes it explicit: a WeakMap keyed by pane host caches the resolved
document with its sessionKey, so re-renders reuse identity and a session change rebuilds it. That
invariant carries an inline comment at the cache, because it is invisible at the call site.

Gating is preserved exactly: detailOpen is presented && sidebarLayout.open && detailSlotOpen(layout) —
the same three conditions the lifecycle hook checked. The panel is never auto-opened.

User Impact

None. Same panel, same document, same conditions — the behavior from #124824 is unchanged; only its owner
moved.

Evidence

The five e2e cases encoding #124824's behavior pass unchanged — the e2e diff is +37 / −0, pure
addition, so nothing was adjusted to fit: menu open, persisted-open reload, session switch replacing the
seeded diff, branch-chip open, and a non-git session issuing no request.

New guard for the identity hazard, since no existing test could have caught a refetch loop (they all assert
what renders, never how many times it fetched):

it("requests the default session diff once across subsequent pane renders")

It opens Review, asserts exactly one sessions.diff request, then forces further renders by opening another
panel and awaiting two animation frames, and asserts the count is still one.

 Test Files  3 passed (3)      Tests  13 passed (13)
 Test Files  1 passed (1)      Tests  15 passed (15)

pnpm check:changed green; Codex autoreview clean ("patch is correct").

reviewMetrics — production vs test LOC: production +41 / −34 (net +7), tests +37 / −0. The
lifecycle hook's deletion offsets most of the resolver and cache; the remainder buys an explicit invariant
where there was an implicit one. Series running total: −17 (#124950) +11 (#125019) +7 here = net −1 in
production, with four scattered sources now collapsed into one declaration.

No CHANGELOG.md edit — release-only per repo policy, and this step is behavior-neutral.

@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 17, 2026 06:20
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: S maintainer Maintainer-authored PR labels Aug 17, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 17, 2026
@clawsweeper

clawsweeper Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 2:45 AM ET / 06:45 UTC.

ClawSweeper review

What this changes

Moves the Review panel’s default session-diff document into the side-panel slot definition and caches its document identity across rerenders.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open. The slot-owned resolver and host/session identity cache are a coherent replacement for the lifecycle mutation, with no blocking code finding; exact-head CI and the required fresh autoreview remain incomplete.

Priority: P3
Reviewed head: 6fc514be8e4ae99e8c24fe3a87ab72a2bbbb4c7f

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, coherent refactor with targeted regression coverage; merge readiness awaits validation completion rather than code changes.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored behavior-preserving refactor is covered by mock-gateway Control UI E2E tests; the external-contributor real-proof gate does not apply.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored behavior-preserving refactor is covered by mock-gateway Control UI E2E tests; the external-contributor real-proof gate does not apply.
Evidence reviewed 7 items Slot-owner implementation: The detail definition prefers explicitly opened sidebar content and otherwise resolves a default session-diff document only when the Review slot is open.
Identity invariant: The cache is keyed by pane host and refreshes on session-key changes, preventing the mounted diff panel from receiving a new loader on ordinary rerenders.
Consumer contract: The detail panel passes the session-diff loader to the mounted diff component, whose task reruns when its loader identity changes; the cache therefore protects a real rendering boundary.
Findings None None.
Security None None.

How this fits together

The chat pane converts session and layout state into side-panel definitions before rendering the selected panel. When Review is genuinely open and has no explicit document, it resolves the session diff for the embedded detail panel.

flowchart LR
A[Session and layout state] --> B[Chat pane render]
B --> C[Side-panel definitions]
C --> D{Review slot open?}
D -->|yes| E[Resolve session-diff document]
E --> F[Host and session identity cache]
F --> G[Embedded Review panel]
D -->|no| G
Loading

Before merge

  • Resolve merge risk (P1) - Exact-head CI is still in progress; merge only after required jobs complete successfully.
  • Resolve merge risk (P1) - Fresh structured autoreview is blocked by the missing TruffleHog binary and must be rerun before landing.
  • Complete next step (P2) - No repair is indicated; complete exact-head validation and the blocked autoreview prerequisite before merge.
Agent review details

Security

None.

PR surface

Source +7, Tests +37. Total +44 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 4 41 34 +7
Tests 1 37 0 +37
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 78 34 +44

Review metrics

Metric Value Why it matters
Production versus test LOC production +41/-34 (net +7); tests +37/-0 The small production increase is the explicit identity cache that replaces the lifecycle latch; the added E2E covers its observable single-request invariant.

Stored data model

Persistent data-model change detected: vector/embedding metadata: ui/src/e2e/chat-session-diff.e2e.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the slot-owned resolver and session-aware cache, then land after exact-head CI and a clean fresh autoreview.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the slot-owned resolver and session-aware cache, then land after exact-head CI and a clean fresh autoreview.

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

Not applicable: this PR reorganizes an already-implemented Review-panel default rather than reporting a new defect.

Is this the best way to solve the issue?

Yes. Resolving the default in the slot declaration preserves explicit operator content while putting the default-document policy beside the rest of the slot contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 73ab74ecccdc.

Labels

Label justifications:

  • P3: This is a bounded, behavior-preserving Control UI refactor.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored behavior-preserving refactor is covered by mock-gateway Control UI E2E tests; the external-contributor real-proof gate does not apply.

Evidence

What I checked:

Likely related people:

  • steipete: History ties the prior Review-panel fix and the two slot-definition refactors to this area contributor. (role: introduced the preceding behavior and recent slot-refactor contributor; confidence: high; commits: d162ea5581fe, 07da6f6d6d4e, 3d1185f1373c; files: ui/src/pages/chat/chat-pane-embedded-panels.ts, ui/src/pages/chat/components/chat-session-workspace.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Complete exact-head CI.
  • Restore TruffleHog and rerun the required structured autoreview.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-17T06:26:03.787Z sha 6f362a9c31a1c1a59a0baf2fbb14d51d913736db :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the steipete/detail-slot-default-document branch from 6f362a9 to 6fc514b Compare August 17, 2026 06:38
@steipete steipete self-assigned this Aug 17, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 6fc514be8e4ae99e8c24fe3a87ab72a2bbbb4c7f:

  • Focused local proof: pnpm test ui/src/pages/chat/components/chat-sidebar-region.test.ts ui/src/e2e/chat-sidebar-panel-contract.e2e.test.ts ui/src/e2e/chat-session-diff.e2e.test.ts ui/src/e2e/terminal-open.e2e.test.ts — 4 files, 28 tests passed across 2 Vitest shards.
  • Fresh structured review: .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main — clean, no accepted/actionable findings.
  • Exact-head CI: run 32002495671 — green.
  • Native landing preparation: OPENCLAW_TESTBOX=1 scripts/pr prepare-run 125105 — passed with gates_mode=hosted_exact_or_recent_parent; the wrapper reused hosted exact-head CI, so there is no separate Testbox run ID.

Known proof gaps: none for this behavior-neutral ownership refactor. The existing focused browser-harness cases preserve the Review panel behavior and the new request-count assertion covers rerender identity stability.

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 maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant