Skip to content

refactor(ui): derive gateway types from protocol and consolidate navigation/error helpers - #120348

Merged
steipete merged 3 commits into
mainfrom
steipete/loc5-uitypes-5a7d
Aug 7, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/loc5-uitypes-5a7d

Conversation

@steipete

@steipete steipete commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

The Control UI independently mirrored several Gateway protocol types and repeated the same navigation, error-formatting, and Gateway lifecycle policy across many call sites. Those copies had already drifted: presence omitted tags and treated its timestamp as optional, session rows omitted three protocol fields and required an optional timestamp, and agent scope widened a closed wire union to any string.

Why This Change Was Made

  • Derive PresenceEntry, AgentsListResult, and the protocol portion of GatewaySessionRow from gateway-protocol owners.
  • Make SessionRunStatus and QueueMode protocol-owned types and import them throughout core and UI consumers.
  • Move ordinary navigation-click handling into one UI helper and replace all existing/copy sites, while retaining parent-session modified-click multi-select semantics.
  • Canonicalize CapabilityMenuProps, bind UI error formatting to the browser-safe redactor once, and migrate the existing phase-one formatter sites only.
  • Move Logs and Debug Gateway source/reconnect state plumbing onto GatewayPageController while preserving each page's reset behavior.

User Impact

There is no visual redesign. The UI now receives the complete protocol session/presence shape and shares one consistent policy for normal navigation clicks, redacted error messages, and Gateway identity changes.

Intentional behavior fixes

  • Presence rows now expose protocol tags, and their protocol timestamp is required instead of optional.
  • Gateway session rows now expose lastMessagePreview, chatType, and lastInteractionAt; updatedAt is correctly optional.
  • Agent-list scope is exhaustively typed as per-sender or global instead of arbitrary strings.
  • A Lobsterdex link click that another handler already prevented is now ignored; previously it still called the SPA navigation callback.

Evidence

  • Production numstat: +258 / -488, net -230 lines.
  • Test numstat: +188 / -73, net +115 lines.
  • Generated manifest: +1 / -1 hash-only change from pnpm plugin-sdk:api:gen.
  • Focused UI proof: 31 files, 964 tests passed across two shards.
  • Focused protocol/core proof: 10 files, 228 tests passed across five shards.
  • Type-fixture proof: 12 files, 528 tests passed across two shards.
  • Sidebar modified-click rerun: 237 tests passed.
  • pnpm tsgo:ui passed; core, core-test, and UI tsgo all passed in check-changed.
  • node scripts/run-oxlint.mjs on all changed paths passed.
  • OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 node scripts/check-changed.mjs --timed passed every selected core, core-test, UI, docs, lint, API-surface, import-cycle, and repository guard. Blacksmith was unavailable locally, so this used the documented trusted-source local fallback.
  • pnpm plugin-sdk:api:check and pnpm plugin-sdk:surface:check passed.
  • Three pre-commit Codex autoreviews completed cleanly with no accepted/actionable findings.
  • No screenshot proof: state plumbing and type/helper ownership changed; render output did not.

Research Re-verification Notes

  • Current HEAD had 3 external navigation-helper importers and 6 existing calls, not 8 importers; all 6 calls, 9 full inline copies, and the child-only split guard were migrated.
  • The error-helper figure was 55 symbol sites: 42 calls plus 13 imports across the stated 13 files. All were migrated; the 76 raw ternaries remain phase two.
  • GatewaySessionRow had 91 direct UI consumers on the verified base, not 195; the derived type required only fixture corrections, with no production consumer workaround.

@steipete
steipete marked this pull request as ready for review August 7, 2026 20:52
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Aug 7, 2026
@clawsweeper clawsweeper Bot added 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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Aug 7, 2026
@clawsweeper

clawsweeper Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 7, 2026, 5:25 PM ET / 21:25 UTC.

ClawSweeper review

What this changes

The branch derives repeated Gateway types from protocol schemas and centralizes Control UI navigation, error-redaction, and Gateway lifecycle helpers.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for maintainer review: the PR repairs real protocol/UI ownership drift and no concrete patch defect was found, while the protected maintainer label requires explicit human merge ownership.

Priority: P3
Reviewed head: e79a2e1de7674db85d92767442a9b04d64f0a245
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has a coherent owner-boundary shape and broad reported validation, with final merge ownership reserved for maintainers.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored ownership refactor has no visual redesign; focused tests and required CI are reported, and no external-contributor proof gate applies.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored ownership refactor has no visual redesign; focused tests and required CI are reported, and no external-contributor proof gate applies.
Evidence reviewed 5 items Protocol owner boundary: The protocol schema already owns the four queue modes and session-run statuses; the PR removes duplicate TypeScript unions rather than changing runtime validation.
UI type drift: Current baseline UI types mirror PresenceEntry, AgentsListResult, and session rows with missing or widened fields; deriving them from schemas is the canonical repair.
Lifecycle behavior: GatewayPageController separates identity resets from reconnect invalidation, matching Logs, Debug, and sibling page behavior; the target main lifecycle files are unchanged from the PR base.
Findings None None.
Security None None.

How this fits together

Gateway schemas define data exchanged with the server; Control UI pages consume that data and react to connection changes. The PR moves duplicated type and lifecycle policy to their existing shared owners.

flowchart LR
  A[Gateway protocol schemas] --> B[Gateway server responses]
  B --> C[Control UI API types]
  C --> D[Shared UI helpers]
  D --> E[Navigation and page views]
  F[Gateway connection changes] --> D
Loading

Decision needed

Question Recommendation
Should this maintainer-owned, broad but behavior-preserving protocol and Control UI refactor be accepted after its current-base merge result is refreshed? Accept after refresh: Recheck the clean three-way merge and required checks on the current base, then merge the refactor as the canonical owner-boundary cleanup.

Why: The protected maintainer label and member authorship prohibit automated cleanup; the remaining decision is merge ownership rather than a mechanical patch repair.

Before merge

  • Resolve merge risk (P1) - GitHub reports the branch is behind its base, so maintainers should refresh the exact three-way merge and required checks before landing.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production versus test delta production +258/-488 (net -230); tests +188/-73 (net +115) The branch reduces production duplication while adding targeted regression and type-fixture coverage.

Stored data model

Persistent data-model change detected: serialized state: src/agents/tools/sessions-helpers.ts, serialized state: src/agents/tools/sessions-list-tool.ts, serialized state: src/auto-reply/reply/queue/state.ts, serialized state: src/config/sessions/session-transcript-turn-lifecycle.types.ts, serialized state: src/config/sessions/types.ts, serialized state: src/gateway/session-lifecycle-state.ts, and 7 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the coherent owner-boundary refactor after a maintainer confirms the refreshed merge result; retain page-specific reset callbacks while sharing only Gateway connection lifecycle mechanics.
  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 coherent owner-boundary refactor after a maintainer confirms the refreshed merge result; retain page-specific reset callbacks while sharing only Gateway connection lifecycle mechanics.

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

Not applicable: this is a refactor; the relevant evidence is behavior-preservation coverage for protocol typing, navigation, and connection lifecycle handling.

Is this the best way to solve the issue?

Yes: existing Gateway schemas and GatewayPageController are the narrowest canonical owners, avoiding further UI-local type copies and page-local subscription loops.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 87156bab23d0.

Labels

Label changes:

  • add P3: This is a behavior-preserving ownership cleanup with a small navigation-click correction, not an urgent user-impact regression.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This member-authored ownership refactor has no visual redesign; focused tests and required CI are reported, and no external-contributor proof gate applies.

Label justifications:

  • P3: This is a behavior-preserving ownership cleanup with a small navigation-click correction, not an urgent user-impact regression.
  • 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 member-authored ownership refactor has no visual redesign; focused tests and required CI are reported, and no external-contributor proof gate applies.

Evidence

What I checked:

  • Protocol owner boundary: The protocol schema already owns the four queue modes and session-run statuses; the PR removes duplicate TypeScript unions rather than changing runtime validation. (packages/gateway-protocol/src/schema/logs-chat.ts:123, e79a2e1de767)
  • UI type drift: Current baseline UI types mirror PresenceEntry, AgentsListResult, and session rows with missing or widened fields; deriving them from schemas is the canonical repair. (ui/src/api/types.ts:256, 588d8bb85388)
  • Lifecycle behavior: GatewayPageController separates identity resets from reconnect invalidation, matching Logs, Debug, and sibling page behavior; the target main lifecycle files are unchanged from the PR base. (ui/src/lit/gateway-page-controller.ts:155, 87156bab23d0)
  • Feature provenance: Blame attributes the protocol schema and current lifecycle boundary to Peter Steinberger; recent Debug follow-up history also includes Shakker. (ui/src/lit/gateway-page-controller.ts:155, a672065d5e55)
  • Validation supplied with the PR: The PR body reports focused UI, protocol/core, and type-fixture tests plus UI/E2E and required CI checks passing on the proposed head. (e79a2e1de767)

Likely related people:

  • Peter Steinberger: Blame ties the protocol schemas and shared Gateway page-controller lifecycle behavior to this contributor. (role: feature owner; confidence: high; commits: a672065d5e55, 3d4a7d496223; files: packages/gateway-protocol/src/schema/logs-chat.ts, packages/gateway-protocol/src/schema/sessions-row.ts, ui/src/lit/gateway-page-controller.ts)
  • Shakker: Recent history includes a Debug diagnostics follow-up in the page-lifecycle area. (role: recent adjacent contributor; confidence: medium; commits: a3cf376258be; files: ui/src/pages/debug/debug-page.ts)
  • steipete: The submitted commits span the protocol, UI helper, and lifecycle refactor and the provided item identifies this author as a repository member. (role: recent area contributor; confidence: medium; commits: 5399ea6281ff, c023fe6e012d, e79a2e1de767; files: packages/gateway-protocol/src, ui/src)

Rank-up moves

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

  • Refresh the exact merge result and required checks against current main 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.

@steipete
steipete merged commit 8bf62e7 into main Aug 7, 2026
259 of 263 checks passed
@steipete
steipete deleted the steipete/loc5-uitypes-5a7d branch August 7, 2026 22:25
@steipete

steipete commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 8, 2026
…gation/error helpers (openclaw#120348)

* refactor(protocol): derive shared gateway types

* refactor(ui): consolidate navigation click handling

* refactor(ui): centralize UI state and error helpers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime 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: XL 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