Skip to content

refactor: consolidate duplicate HTTP, voice, and catalog adapters - #169499

Closed
steipete wants to merge 1 commit into
mainfrom
deslop/w12-dup-clusters-20261011
Closed

steipete wants to merge 1 commit into
mainfrom
deslop/w12-dup-clusters-20261011

Conversation

@steipete

@steipete steipete commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Maintainer-requested duplicate-code consolidation gives HTTP, realtime voice, and catalog adapters shared execution owners instead of parallel implementations that can drift.

User Impact

Existing HTTP, voice, catalog, and media behavior stays intact. Successful MCP configuration retries no longer return stale failure text after the stored error has been cleared. No configuration, protocol, database schema, retention, permission, or dependency change is required.

Why This Change Was Made

The adapters now share OpenAI-compatible HTTP execution, OpenAI/xAI WebSocket transport, provider-selection preparation, UI set-request lifecycle, hosted-media request parsing, and bounded JSONL activity scanning. Vendor authentication, wire messages, transcript classification, stream-flush differences, resource bounds, and authorization remain with their existing owners. The retained branch also contains ACP catalog-adoption and TLS-preflight consolidation.

Net production reduction: 681 lines (+1,839/−2,520), excluding tests, fixtures, generated files, declaration files, documentation, and baseline maintenance. This uses the campaign's 500–999-line exception after the extended implementation pass; the coverage log below records rejected clusters. The former icon/usage-rendering changes are absent because #169367 already landed them.

Best-effort tradeoffs accepted

  • Removed duplicate per-upload cleanup-promise memoization in SMS and Synology Chat. The hosted store already serializes deletion and treats repeated deletion of an absent upload as a no-op; repeat cleanup now calls that owner directly. The wrappers originated with feat(sms): add Twilio MMS support #118664 and fix(synology-chat): deliver attachments without forwarding source URLs [AI] #119941, not an established human-reported failure. Vendor limits, reader retention, capability revocation, and retry-after-failure remain intact.
  • No security-effect check, common crash/restart durability, public contract, or realistic concurrency protection was removed. Other changes consolidate existing policy rather than relax it.

Evidence

  • 684 focused cases passed across HTTP wire/continuity/cancellation, provider selection, realtime connection/reconnect/terminal results, optional capture, hosted-media security/capacity, JSONL activity, UI acknowledgement/retry, and MCP suites. The MCP regression failed on the original returned/stored error mismatch and passed after the producer fix.
  • The new MCP regression took 4.210 seconds in its green run. The complete 13-case MCP file took 101.69 seconds including transforms; its wrapper took 298.83 seconds including 166.245 seconds of compiled-worker preparation. Hosted CI seconds remain pending.
  • Independent full-candidate review and fresh four-file follow-up review: no actionable P0–P2 findings. The follow-up review used the repaired configured transport and confirmed unchanged image validation, limits, abort and authority checks.
  • Eleven targeted image/media/upload HTTP cases passed after extraction; the filter intentionally left 121 other cases unselected. Formatting and all three lint-suppression tests passed on the final source (36.32-second suppression wrapper).
  • Production core/UI/extension types and focused type-aware lint passed, including the final Gateway extraction and extension import correction. Native SDK API comparison found no Plugin SDK API changes (digest ff7b090f); the follow-up only relocates private Gateway image handling and fixes import/shorthand lint. Final-head checks found zero runtime value cycles and zero Madge cycles.
  • Local changed checks passed the applicable boundary/ratchet/format guards. The full local invocation is not claimed green: its broad serial fixture-type sweep was deliberately stopped after 40 minutes under the CI-first proof rule. Remaining broad fixture types, legacy-store/media/sidecar/webhook/pairing repository scans, and full build are deferred to exact-head PR CI. The final native schema-version guard passed; the legacy-store scan was interrupted without a diagnostic. Dead-export scans also reported untouched UI component/page exports; this has not yet been qualified as a current-main failure. No finding named changed files, and no baseline was weakened.
  • All local runtime/test commands used task-owned HOME, OpenClaw state/config, and XDG directories. No operator Gateway was restarted. No visual appearance changed.
  • Published candidate: 93fac510284f12c5a52f459bbbcf1691434d358d. Exact-head hosted CI is the remaining broad-proof and landing gate.
Duplicate-cluster coverage and retained distinctions

Exact-token and normalized structural scans covered the coordinator-approved production scope, followed by an SDK-only plugin scan. Tests, fixtures, generated declarations, other live-lane areas, audit, changelog and PR tooling were excluded from implementation scope.

Cluster Decision
Chat/Responses HTTP execution Shared preparation, JSON and SSE execution; preserve protocol encoding, different flush schedules, continuity persistence and cancellation.
OpenAI/xAI realtime bridges Shared socket/connect/retry/capture owner; preserve provider auth, parsing, replay, startup caps and audio backpressure.
Capability/Talk provider selection Shared candidate/config/error preparation; preserve separate synchronous and asynchronous callback execution.
Viewer presence/PR subscriptions Existing set-sync owner absorbs request identity/abort/retry; preserve final-clear acknowledgement and forced-refresh intent.
SMS/Synology hosted media Reuse canonical media-access normalization and shared request parsing; retain vendor security/resource controls.
Pi/Claude upstream activity Shared bounded file scan; retain provider row, timestamp, invalid-row and marker semantics.
CLI registrations and media commands Existing parameterized owners already cover the executable duplication; remaining import/data similarities do not justify a new abstraction.
UI/TUI controllers and CSS Different update-completion, authorization and queue semantics; scattered CSS similarities would add cascade coupling.
Config reload and managed secrets One reload scheduler already exists; secret activation/rollback is a distinct owner, not a duplicate scheduler.
Claw reference CRUD Different reconciliation/ownership and rollback semantics; no generic persistence factory. Fixed the directly observed stale MCP return-value defect instead.
Protocol validator/type lists Explicit public wire declarations, not removable duplicate runtime policy.

Provenance inspected includes #167775 and #115652 (HTTP/flush behavior), #117865 and #122414 (realtime lifecycle/bridge split), #169111 (async provider-selection counterpart), and #167925/#168656 (UI lifecycle/refresh bookkeeping). This is a structural cutover; no speculative race removal is claimed for those families.

@clawsweeper

clawsweeper Bot commented Oct 12, 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.

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 12, 2026
@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR shares icon geometry, provider usage rendering, TLS preflight, and Pi/OpenCode session-adoption implementations.

Example: Usage displays 75% remaining quota and a $12.50 / $50.00 budget.

  • Before: The legacy Lit renderer displays these values.
  • After: The shared Solid renderer displays the same values and appearance.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, source-consistent consolidation with strong renderer parity evidence but limited runtime-flow proof; conflict and pending-CI state do not lower the rating.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor-proof gate: inspected synthetic screenshots establish isolated icon and usage-renderer parity, while the reported native-fetch core probe establishes endpoint reachability only; Gateway adoption and plugin-login flows are not shown.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: No observed user-facing defect is reported; parallel implementations create maintenance drift in otherwise equivalent behavior.
Reason: The maintainer-authored direction removes substantial duplication, preserves existing contracts, and explicitly accepts the verified runtime tradeoffs.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this maintainer-authored PR open: its runtime consolidation remains useful despite overlapping presentation work already on main; no introduced defect was found, but reported conflicts remain.

Priority: P3
Reviewed head: e147bc93b83d964af7cdd559dab19bf7d050b4c5

Before merge

  • Complete next step - Resolve the reported conflicts while preserving main’s canonical icon and Solid usage implementations, then validate the affected UI and runtime paths.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied captures do not exercise native-session continuation through the Gateway or the plugin OAuth login flow.
Agent review details

How this fits together

Control UI adapters turn icon geometry and provider snapshots into DOM, while runtime helpers turn endpoint probes and native-session selections into diagnostics and adopted OpenClaw sessions.

flowchart TD
  A[Icon catalog] --> B[Lit and Solid adapters]
  C[Provider snapshots] --> D[Solid usage renderer]
  E[OAuth endpoint probe] --> F[Shared TLS preflight]
  G[Pi and OpenCode catalogs] --> H[Shared session adoption]
Loading

Technical review

Best possible solution:

Preserve main’s canonical presentation owners and land the distinct runtime consolidation after resolving conflicts and validating affected paths.

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

This is a refactor rather than a reported bug; the original blobs and pinned diff establish the duplication without running target code.

Is this the best way to solve the issue?

The shared helpers fit existing owners and preserve their contracts, with the overlapping presentation work best reconciled against current main.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned introduced changes: The introduction diff removes duplicated implementations, migrates both bundled adoption consumers, and retains the existing TLS and presentation contracts. (e147bc93b83d)
  • Presentation overlap on main: refactor(ui): consolidate presentation and preference recovery #169367 already consolidated the Lit icon catalog and switched Usage to Solid; current main retains separate TLS and adoption implementations. (ui/src/components/icons-tools.ts:40, f9d2ebefe12f)
  • Current merge state: GitHub reports mergeable=false and mergeable_state=dirty for the reviewed head; the PR is now ready for review, so the previous draft requirement is resolved. (e147bc93b83d)
  • Inspected visual parity: All four downloaded screenshots were inspected: the icon atlas and synthetic provider quota, billing, and cost-history presentation match; each before/after pair also has identical SHA-256 hashes. (e147bc93b83d)
  • Accepted runtime tradeoffs: The maintainer-authored body accepts cached executable availability and best-effort response cancellation; the existing resolver and cancellation owner implement those choices without removing the TLS authority or abort checks. (src/infra/http-response-body.ts:10, e147bc93b83d)
  • Private SDK boundary: provider-http and session-catalog-runtime are private-local SDK subpaths, and their documentation identifies that boundary; these helper additions do not expand the supported third-party SDK API. (scripts/lib/plugin-sdk-private-local-only-subpaths.json:129, e147bc93b83d)

PR surface

Source -1013, Tests +22, Docs +13. Total -978 across 16 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 12 265 1278 -1013
Tests 2 62 40 +22
Docs 2 13 0 +13
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 16 340 1318 -978

Review metrics

Metric Value Why it matters
Production versus test growth Production net −1,013 lines; tests net +22 lines. Removes duplicate production implementations while retaining currency/chart contracts and adding SVG attribute-escaping coverage; presentation savings overlap work already on main.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: Internal consolidation with no intended user-visible, configuration, protocol, or stored-data change.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-12T01:14:47.569Z sha e147bc9 :: needs changes before merge. :: none

Reviewed October 11, 2026, 9:45 PM ET / October 12, 2026, 01:45 UTC (Revision 2).

@steipete
steipete marked this pull request as ready for review October 12, 2026 01:40
@steipete

Copy link
Copy Markdown
Contributor Author

The conflict-only rebase onto 44f538c1855de6924851f56d23018852a7e3e86c found that #169367 already landed the shared icon geometry and provider-usage renderer cutover. I kept main's implementation and tests, including its added history icon, rather than replacing it with another equivalent helper.

The remaining unique work is 107 net production lines removed: shared Pi/OpenCode adoption and HTTP TLS preflight. Under the campaign's BELOW-500 rule, this is branch-only work, not a merge candidate. Closing this PR without merging; the remaining signed branch is preserved for follow-up consolidation. The original 1,013-line candidate's focused, build, review, SDK API, and image evidence remains in the history above, but is not claimed as new work beyond current main.

@steipete steipete closed this Oct 12, 2026
@steipete steipete changed the title refactor: consolidate duplicated icons and provider helpers refactor: consolidate duplicate HTTP, voice, and catalog adapters Oct 12, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Continued in #169756 at 93fac510284f12c5a52f459bbbcf1691434d358d after the coordinator restart. GitHub refused to reopen this closed PR after the branch was rebased and pushed, so the new PR carries the remaining 681-line production reduction, updated provenance and proof gaps. This PR remains closed and unmerged.

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 docs Improvements or additions to documentation extensions: acpx extensions: openai extensions: opencode P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL 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