Skip to content

refactor(ui): reuse protocol file response types - #130789

Merged
steipete merged 2 commits into
mainfrom
codex/cleanup20k-ui-file-result-types-20260826
Aug 27, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/cleanup20k-ui-file-result-types-20260826

Conversation

@steipete

@steipete steipete commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The Control UI duplicates agent-file and session-workspace response shapes already owned by the gateway protocol. Maintaining both copies creates unnecessary drift risk when file metadata evolves. This is a maintainer-requested cleanup, not a claimed user-facing bug fix.

Why This Change Was Made

Reuse the existing protocol types for seven UI exports and remove their copied declarations. The UI keeps its existing exported names and its separate artifact metadata: the workspace view combines sessions.files.list with separately fetched artifacts.list results. No new helper, module, runtime import, protocol version, schema, dependency, or public field is introduced.

Ordinary CI exposed a flaky existing hovercard assertion: a 40 ms sleep after a real hover did not mean the browser was still before its 80 ms timer. The test now reuses the existing virtual-clock helper, preserves all eight scenarios and real pointer/keyboard/menu interactions, and checks the exact cold-open and sweep boundaries. Native CSS transitions remain enabled; one close-deadline browser evaluation accepts a closed card or a card already removed by its normal opacity transition.

Production LOC: +9/-82 (net -73). Tests: +33/-13 (net +20). The only production change is ui/src/api/types.ts; an adjacent correction keeps the existing hovercard timing test deterministic.

User Impact

No user-visible behavior or layout change. File editing, expected-absent files, nested workspace browsing, image metadata, CAS hashes, and artifact joins retain their existing contracts. This change was AI-assisted with Codex; the source, callers, dependency types, and actual proof were inspected directly.

Evidence

  • The final two-file candidate passed all 19 canonical changed checks in a pinned Linux environment, including complete UI/core-test type checks, typed lint, formatting, UI styles/i18n, dependency guards, and all three dead-export scans.
  • All 41 retained tests passed: agent-file editing (10), file lifecycle (8), and session-workspace behavior (23). No tests were removed or weakened.
  • Exact TypeScript 6.0.3 / TypeBox 1.3.16 compiler proof preserved all 100 UI exports. The seven reused shapes passed recursive structure, optional/readonly/literal/index-signature, excess-property, nested-rejection, and bidirectional-assignability checks with exactOptionalPropertyTypes both enabled and disabled. Runtime type erasure was byte-identical.
  • Three real production UI builds—baseline, repeated baseline, and candidate—ran sequentially at the same path, with identical supported build metadata. All asset/performance validators passed. Every filename and byte hash across all 1,827 output files matched exactly, including JavaScript, CSS, source maps, gzip and Brotli assets. No output normalization or exclusions were used. All 34,208 tracked source paths were fenced before/after; only the intended type file differed.
  • Authenticated, isolated read-only Codex precommit review is complete with no remaining actionable findings. The original scoped type-contract partition A is retained with every owner/artifact hash revalidated; the necessary revised partition B reviews the complete current two-file diff and timing owners after its CSS-cleanup finding was reproduced and fixed. Fresh published-head independent review and ordinary exact-head CI remain required before landing.

The pinned environment was Linux Node 24.19.0, Vitest 4.1.11 and Vite 8.2.1, with the frozen dependency fingerprint and all package/build source inputs verified before dependency reuse. The owned Testbox run was stopped after its commands completed; delegated command exit codes, not the lease workflow's cleanup status, are the execution proof.

Commands exercised:

node scripts/check-changed.mjs --staged --timed
node scripts/run-vitest.mjs ui/src/pages/agents/files.test.ts ui/src/pages/agents/agent-file-lifecycle.test.ts ui/src/pages/chat/components/chat-session-workspace.test.ts
node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/session-progress-hovercard.e2e.test.ts
node scripts/ui.js build

An initial comparison built baseline and candidate in different directories: both builds passed, but their output comparison failed. Investigation localized the executable difference to redundant memoized TypeBox initialization calls; the original logs and generated code were retained. The controlled same-path repeat above then proved literal full-output equality. This PR neither changes the bundler nor claims path-independent build determinism. No live external API or screenshot-based behavior claim is made for this type-only change.

Adjacent CI timing repair

The original ordinary CI run failed the existing cold/bridge/sweep/menu test: it observed the second row where its wall-clock assertion still expected the first. No blind CI retry was used. Bounded browser observations measured the RPC overhead and confirmed the unchanged 80 ms timer, but did not reproduce that chance failure; the hosted failure remains the pre-fix reproduction.

The revised test passed all eight scenarios in the pinned browser proof environment. Four deliberate timing mutations were rejected: sweep 80→0 and 80→160, and cold-open 450→0 and 450→900. Each failed at its intended pre-/at-deadline assertion, and the original runtime bytes were restored. No production timer, CSS rule, timeout, or test-only production seam changes.

That machine's backing workflow was later cancelled by the provider during the changed gate; the interrupted attempt is retained as a failure. A single recovery environment, hydrated from this PR's published branch to preserve its dependency cohort, completed all 19 checks and final source fences. No memory/concurrency override or CI retry was used to obtain that result.

The recovery machine was stopped after the final gate and review completed; no proof lease remains active.

Review caught a second clock-domain issue in the first correction: pausing JavaScript does not pause CSS. A real Chromium trace showed the card marked closed at virtual 100 ms, then removed by a native opacity transition without further virtual-clock advance. The final close assertion performs one browser evaluation accepting either valid state; the 99 ms mounted assertion and later removal assertion remain. The original review finding and diagnostic records are retained rather than relabeled clean.

Provenance: the wall-clock assertion is carried from commit 434fd0c106902 (2026-08-23, code author Vyctor H. Brzezowski, #125068). No merger or automation-trigger attribution is inferred from blame. This is a test-only repair; no new operator-visible behavior is claimed.

ClawSweeper disposition

The latest available ClawSweeper review found no source defects and requested ordinary review and exact-head CI completion; it contains no separate rank-up moves. The local integrated review and final checks above are complete. A fresh independent published-head review and ordinary CI on the updated head remain required before landing; the old failed run is not being treated as green.

@steipete steipete self-assigned this Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: S maintainer Maintainer-authored PR labels Aug 27, 2026
@steipete
steipete marked this pull request as ready for review August 27, 2026 07:27
@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 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 27, 2026, 5:34 AM ET / 09:34 UTC.

ClawSweeper review

What this changes

The PR reuses Gateway protocol file-response types in the Control UI and replaces wall-clock waits with virtual-clock assertions in the session hovercard E2E test.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: this is a coherent, maintainer-owned cleanup that removes current-main type duplication and makes a real browser timing regression deterministic. No patch defect was found; await the in-progress exact-head checks and ordinary maintainer review. Likely related people: steipete and vyctorbrzezowski.

Priority: P3
Reviewed head: 80dcd726bf725f57e655b10ef142cba638ddea14

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The implementation follows the existing protocol-owner pattern and the timing test targets real production deadlines, with normal exact-head CI still pending.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored internal refactor and test-stability repair is outside the external-contributor real-behavior-proof gate.
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 internal refactor and test-stability repair is outside the external-contributor real-behavior-proof gate.
Evidence reviewed 6 items Current main still duplicates protocol-owned shapes: Current main declares the agent-file and session-workspace result shapes locally, including the same normal-absence and CAS metadata represented by the protocol schemas.
Protocol is the canonical type owner: The PR-head UI module re-exports the seven shared response types from the protocol barrel, whose schemas define agent file entries/results and session file list/get/set results.
UI callers consume the shared response contracts: Agent-file requests use AgentsFilesListResult, while session workspace requests use the aliased protocol result types and retain only the UI-owned artifact join.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/session-progress-hovercard.e2e.test.ts

Result: FAIL (failed) — step 1 expect_output honors cold, bridge, sweep, and menu-suppression timing on real sidebar rows: expected terminal output was not visible within 30 seconds: "honors cold, bridge, sweep, and menu-suppression timing on real sidebar rows"

RUN  v4.1.11 /tmp/clawsweeper-live-proof-130789-asMNSY/target

[vitest] still running with no output for 30000ms.

Assertions:

  • FAIL expect_output: honors cold, bridge, sweep, and menu-suppression timing on real sidebar rows

How this fits together

Gateway protocol schemas define the file payloads consumed by Control UI agent editors and session workspace views. The sidebar’s session hovercard has a browser test that checks its open, bridge, sweep, and menu-suppression timing.

flowchart LR
  Protocol[Gateway protocol schemas] --> Types[Control UI type exports]
  Types --> AgentFiles[Agent file editor]
  Types --> Workspace[Session workspace]
  Sidebar[Session sidebar] --> Hovercard[Progress hovercard]
  Hovercard --> E2E[Browser timing test]
Loading

Before merge

  • Resolve merge risk (P1) - Exact-head CI is still in progress, so normal integration proof is not yet complete.
  • Complete next step (P2) - This maintainer-labelled PR has no discrete repair finding; the remaining action is ordinary exact-head CI and maintainer review.
Agent review details

Security

None.

PR surface

Source -73, Tests +20. Total -53 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 9 82 -73
Tests 1 33 13 +20
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 42 95 -53

Review metrics

Metric Value Why it matters
Production versus test delta production +9/-82 (net -73); tests +33/-13 (net +20) Production removes duplicated declarations while the added test lines make existing interaction deadlines deterministic.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the protocol-owned type consolidation and exact timing assertions after the pending exact-head checks and ordinary maintainer review complete.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the protocol-owned type consolidation and exact timing assertions after the pending exact-head checks and ordinary maintainer review complete.

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

Yes, source establishes the prior flaky mechanism: current main used wall-clock waits inside assertions for production timers with fixed 450/220/80/100 ms boundaries. The PR’s supplied CI failure is consistent with that path, although this review did not execute it.

Is this the best way to solve the issue?

Yes. The Gateway protocol already owns the exact shared payload types, while the UI correctly preserves only its artifact-specific intersection; the virtual-clock test directly checks the production timer boundaries.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 1cbcf141ed1e.

Labels

Label justifications:

  • P3: This is a focused internal type-owner refactor with a test-stability repair and no claimed user-visible behavior change.
  • 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 internal refactor and test-stability repair is outside the external-contributor real-behavior-proof gate.

Evidence

What I checked:

  • Current main still duplicates protocol-owned shapes: Current main declares the agent-file and session-workspace result shapes locally, including the same normal-absence and CAS metadata represented by the protocol schemas. (ui/src/api/types.ts:305, 1cbcf141ed1e)
  • Protocol is the canonical type owner: The PR-head UI module re-exports the seven shared response types from the protocol barrel, whose schemas define agent file entries/results and session file list/get/set results. (ui/src/api/types.ts:26, 80dcd726bf72)
  • UI callers consume the shared response contracts: Agent-file requests use AgentsFilesListResult, while session workspace requests use the aliased protocol result types and retain only the UI-owned artifact join. (ui/src/lib/sessions/session-requests.ts:207, 80dcd726bf72)
  • Timing assertions match production lifecycle boundaries: The changed test advances the installed, paused virtual clock to the production 450 ms open, 220 ms bridge, 80 ms sweep, and 100 ms close boundaries; the controller owns those values and uses a virtual-timer fallback for exit cleanup. (ui/src/e2e/session-progress-hovercard.e2e.test.ts:540, 80dcd726bf72)
  • Virtual-clock helper avoids real-time drift: The shared helper pauses an installed clock ahead of its current time so browser RPC overhead cannot consume timing assertion windows. (ui/src/test-helpers/control-ui-e2e.ts:592, 80dcd726bf72)
  • Feature-history routing: History shows steipete previously established the same protocol-derived UI type pattern, while the hovercard feature dates to the merged feature commit authored by vyctorbrzezowski. (ui/src/api/types.ts:26, 9b17b9341453)

Likely related people:

  • steipete: History includes the earlier protocol-derived Control UI type refactor and the current hovercard timing repair. (role: recent UI type-contract contributor; confidence: high; commits: 9b17b9341453, 80dcd726bf72; files: ui/src/api/types.ts, ui/src/e2e/session-progress-hovercard.e2e.test.ts)
  • vyctorbrzezowski: The session-hovercard feature history identifies this contributor as the author of the merged feature that introduced the timing surface. (role: hovercard feature author; confidence: high; commits: 434fd0c10690, 3aff572d74f1; files: ui/src/e2e/session-progress-hovercard.e2e.test.ts, ui/src/components/session-progress-hovercard.runtime.ts)

Rank-up moves

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

  • Allow the pending exact-head CI to complete before landing.

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-27T07:35:33.377Z sha 327d805 :: needs maintainer review before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

Ready for native preparation at commit 80dcd726bf725f57e655b10ef142cba638ddea14.

The production cleanup removes 73 lines of duplicated file-response declarations while preserving all 100 UI exports and the UI-owned artifact join. The adjacent test-only correction keeps all eight hovercard scenarios and real interactions, uses the existing browser-clock helper, and handles native CSS cleanup without changing production timing, CSS, or timeouts. Tests are +33/-13; production is +9/-82.

Fresh independent published-head Codex review covered the complete two-file diff in two explicit owner partitions and found no actionable defects. The ordinary exact-head CI run completed successfully on its first attempt. Its actual merge checkout included this head with main d8d8c6097ba2: the repaired eight-test file passed, including the precise timing scenario; its browser shard passed all 387 tests. The full UI suite passed 11,452 tests with one existing skip. Production build, SDK declarations, UI asset/performance checks, and real-Gateway MCP/auth/log tests also passed.

The final pinned proof passed all 19 canonical changed checks, 41 retained file/workspace tests, all eight browser scenarios, and four deliberate timing mutations rejected at their intended boundaries. The compiler proof retained the exact public types, and same-path baseline/repeated-baseline/candidate builds matched all 1,827 output files byte-for-byte. The original CI failure, accepted-and-fixed CSS review finding, different-path comparison failure, and provider-cancelled gate are preserved in the PR evidence. All task-owned proof machines are stopped.

Commands exercised include node scripts/check-changed.mjs, node scripts/run-vitest.mjs for the named retained and browser suites, and node scripts/ui.js build; exact scopes and environment boundaries are in the PR body.

ClawSweeper disposition: the latest completed review, updated at 09:48 UTC for this exact head, has no source or security findings. Its explicit rank-up move and remaining requirements—complete exact-head CI and ordinary maintainer review—are satisfied. Its separate live probe did not observe the named test output within 30 seconds and reported only a running-suite heartbeat; that failed observation is not relabeled successful. The completed hosted browser job actually reports all eight hovercard tests passing, including the named timing scenario (2.084 seconds), and all 387 tests in the shard passing. The independent pinned run also completed all eight cases. Native prepare/merge still needs to finish.

@steipete
steipete merged commit 29d0713 into main Aug 27, 2026
111 of 113 checks passed
@steipete
steipete deleted the codex/cleanup20k-ui-file-result-types-20260826 branch August 27, 2026 10:09
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 28, 2026
* refactor(ui): reuse protocol file response types

* test(ui): make session hovercard timing deterministic
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