Skip to content

fix(miner-ui): type a chat-dispatch mock against the union #9815 closed - #9846

Merged
JSONbored merged 1 commit into
mainfrom
fix/miner-ui-chat-dispatch-type
Jul 29, 2026
Merged

fix(miner-ui): type a chat-dispatch mock against the union #9815 closed#9846
JSONbored merged 1 commit into
mainfrom
fix/miner-ui-chat-dispatch-type

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

main is red, and it blocks every open PR

src/chat-conversation.test.tsx(297,9): error TS2322:
  Type 'Mock<() => Promise<{ ok: boolean; status: string; action: null; }>>'
  is not assignable to type '(...) => Promise<ChatActionDispatchResult>'

Reproduced on a clean origin/main checkout — not caused by any open PR. It's why #9840, #9821 and #9780 all show validate-code failures: they inherit it.

Cause

#9659/#9815 correctly tightened ChatActionDispatchResult:

- { ok: boolean; status: string; action: string | null; [key: string]: unknown }
+ | ({ ok: true;  status: "dispatched";           action: string | null } & Record<string, unknown>)
+ | ({ ok: false; status: ChatActionRefusalStatus; action: string | null } & Record<string, unknown>)

That's a real improvement — the miner MCP server maps a refusal onto a closed error-code set, and a bare string made that mapping uncheckable.

But this miner-UI test mocks the dispatcher with a bare object literal:

vi.fn(async () => ({ ok: false, status: "disabled", action: null }))

Inference widens ok to boolean and status to string, and a widened literal can't satisfy the closed union. The root typecheck doesn't cover apps/loopover-miner-ui — only ui:typecheck does — which is how it reached main.

Fix

Annotate the mock's return type and import the real ChatActionDispatchResult, so the mock is validated against the shipped contract rather than inference. That also stops it drifting the next time the union changes: the widened version would have kept compiling against literally any shape.

Only the one mock needed it — the sibling that throws is unaffected, and the other tests pass registries rather than inline literals.

Verification

ui:typecheck clean, ui:lint clean (prettier applied), ui:test 645 passed, miner-ui 407 passed, root tsc clean.

main is red on ui:typecheck, which blocks every open PR.

#9659/#9815 correctly tightened ChatActionDispatchResult from a loose
`{ ok: boolean; status: string; ... }` into a union discriminated on `ok`, so the
miner MCP server's refusal -> error-code mapping could finally be checked. But
this miner-UI test mocks the dispatcher with a bare object literal, whose
`ok`/`status` widen to boolean/string on inference -- and a widened literal no
longer satisfies the closed union.

Annotate the mock's return type (and import the real type) so it is validated
against the shipped contract instead of inference. That also stops the mock
drifting from the union the next time it changes -- the widened version would
have kept compiling against any shape at all.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 29, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
loopover-ui 8c8976e Commit Preview URL

Branch Preview URL
Jul 29 2026, 01:54 PM

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@loopover-orb

loopover-orb Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Warning

⏸️ LoopOver review result - manual review recommended

Review updated: 2026-07-29 14:01:00 UTC

1 file · 1 AI reviewer · 2 blockers · CI green · clean

⏸️ Suggested Action - Manual Review

Review summary
This is a narrow, correctly-scoped fix: it imports the real ChatActionDispatchResult union type and annotates the mock's async return, so TypeScript checks the literal against the closed union instead of widening `status`/`ok` to `boolean`/`string`. The PR description's root-cause analysis is accurate and matches what's shown — the mock at line 297 previously had no type annotation and would infer a wider type incompatible with the discriminated union defined in chat-action-dispatch.js. CI is green (validate-code passing confirms the typecheck fix works), and the change is minimal and correctly targeted at the actual failure.

Nits — 2 non-blocking

Concerns raised — review before merging

  • No linked issue detected: No closing reference or linked issue number was found in the PR metadata/body. — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue: This repo's maintainer focus manifest requires every PR to reference a tracked issue. — Link the relevant issue (for example Closes #123) before opening the PR.
📋 Copy for AI agents — paste into your coding agent
Fix the following blocker(s) from this PR review:

1. No linked issue detected: No closing reference or linked issue number was found in the PR metadata/body. — If this PR is intended to solve an issue, link it explicitly in the PR body.

2. Maintainer requires a linked issue: This repo's maintainer focus manifest requires every PR to reference a tracked issue. — Link the relevant issue (for example `Closes #123`) before opening the PR.

Decision drivers

  • ❌ Code review — 2 blockers (1 reviewer)
  • ❌ Gate result — Blocking (Repo-configured hard blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 14 registered-repo PR(s), 13 merged, 345 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 14 PR(s), 345 issue(s).
Improvement ℹ️ Insufficient signal risk: clean · value: insufficient-signal
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is registered but has no active allocation in the current snapshot.
  • Public profile languages: Python, TypeScript, Ruby, Go, MDX, Shell, Solidity, JavaScript
  • Official Gittensor activity: 14 PR(s), 345 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Then work through the remaining 3 steps in the Signals table above.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

Decision record
  • action: hold · clause: missing_linked_issue
  • config: 56f50595929f54d755f7a7c6a257effc9bd9034ce06959e261143c6cf7436863 · pack: oss-anti-slop · ci: passed
  • record: cd16efaf9841c5b6d44656f7ced5cb3039cc3c5cbbb1aadf7569a516e9a3da1c (schema v5, head 8c8976e)
Visual preview
Route Viewport Before (production) After (this PR's preview) Diff
/ desktop before /
before /
after /
after /
diff /
diff /
/ mobile before / (mobile)
before / (mobile)
after / (mobile)
after / (mobile)

Click any thumbnail to open the full-size screenshot. Before = production · After = this PR's preview deploy · Diff highlights exactly what changed.

Scroll preview
Route Before (production) After (this PR's preview)
/ before / (scroll)
before / (scroll)
after / (scroll)
after / (scroll)

A short scroll-through clip (desktop) — click either thumbnail to open the full animation. Evidence for scroll-linked behavior a single screenshot can't show.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 844 bytes (0.01%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
loopover-ui 7.9MB 844 bytes (0.01%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: loopover-ui

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/add-scalar-classes-BSPnTYjU.js (New) 2.16MB 2.16MB 100.0% 🚀
assets/tanstack-vendor-BSfui9Ry.js (New) 929.59kB 929.59kB 100.0% 🚀
openapi.json 422 bytes 747.96kB 0.06%
assets/docs.fumadocs-spike-api-reference-PEOA5eSX.js (New) 443.45kB 443.45kB 100.0% 🚀
assets/AgentScalarChatInterface.vue-DSb-a9zj.js (New) 201.7kB 201.7kB 100.0% 🚀
assets/modal-B0PABJnF.js (New) 184.5kB 184.5kB 100.0% 🚀
assets/client-Vn4u2jya.js (New) 151.47kB 151.47kB 100.0% 🚀
assets/maintainer-panel-B_OywHlT.js (New) 78.99kB 78.99kB 100.0% 🚀
assets/routes-BJ5dZvL6.js (New) 35.96kB 35.96kB 100.0% 🚀
assets/owner-panel-XwBRI6EE.js (New) 27.99kB 27.99kB 100.0% 🚀
assets/app-oW9SoyCK.js (New) 25.78kB 25.78kB 100.0% 🚀
assets/ui-vendor-DJr9t1ia.js (New) 24.57kB 24.57kB 100.0% 🚀
assets/miner-panel-D28oBVsG.js (New) 20.24kB 20.24kB 100.0% 🚀
assets/app.runs-BBUw0Jy7.js (New) 20.22kB 20.22kB 100.0% 🚀
assets/api._op-nH36pdBa.js (New) 17.57kB 17.57kB 100.0% 🚀
assets/self-hosting-docs-audit-DAewGL-F.js (New) 16.6kB 16.6kB 100.0% 🚀
assets/docs._slug-EnD-dtAp.js (New) 15.52kB 15.52kB 100.0% 🚀
assets/playground-panel-ByASbOi5.js (New) 14.42kB 14.42kB 100.0% 🚀
assets/fairness-BxxDu4ne.js (New) 13.98kB 13.98kB 100.0% 🚀
assets/app.audit-BZX-F7R9.js (New) 10.08kB 10.08kB 100.0% 🚀
assets/app.config-generator-D2QtU-1j.js (New) 10.06kB 10.06kB 100.0% 🚀
assets/maintainers-1kdw3a8z.js (New) 8.06kB 8.06kB 100.0% 🚀
assets/miners-B8Y4qB1N.js (New) 7.91kB 7.91kB 100.0% 🚀
assets/agents-DuRIBvje.js (New) 7.74kB 7.74kB 100.0% 🚀
assets/commands-panel-DHKrkVHD.js (New) 6.65kB 6.65kB 100.0% 🚀
assets/maintainer-workflow-CV_0wYQJ.js (New) 6.52kB 6.52kB 100.0% 🚀
assets/digest-panel-CozGcaup.js (New) 6.15kB 6.15kB 100.0% 🚀
assets/repos._owner._repo.quality-ClOqNqn9.js (New) 6.14kB 6.14kB 100.0% 🚀
assets/docs-nav-B47PLe_j.js (New) 6.01kB 6.01kB 100.0% 🚀
assets/docs.index-BUu0bCHw.js (New) 5.95kB 5.95kB 100.0% 🚀
assets/api.index-DPPFg3Fg.js (New) 4.7kB 4.7kB 100.0% 🚀
assets/docs-BETvgXpZ.js (New) 2.7kB 2.7kB 100.0% 🚀
assets/api-DiOaQ19w.js (New) 2.69kB 2.69kB 100.0% 🚀
assets/docs-page-C3Fhc46Z.js (New) 2.1kB 2.1kB 100.0% 🚀
assets/table-Bv1338s_.js (New) 1.75kB 1.75kB 100.0% 🚀
assets/app.workbench-CZnNaiHu.js (New) 1.58kB 1.58kB 100.0% 🚀
assets/tabs-CYJ3N9FE.js (New) 1.39kB 1.39kB 100.0% 🚀
assets/app.repos-vet5si0G.js (New) 1.07kB 1.07kB 100.0% 🚀
assets/input-Cmu1ocjr.js (New) 796 bytes 796 bytes 100.0% 🚀
assets/file-cog-2oHsLwk6.js (New) 758 bytes 758 bytes 100.0% 🚀
assets/app.maintainer-BwNHuVKL.js (New) 502 bytes 502 bytes 100.0% 🚀
assets/app.owner-CSfsqlov.js (New) 474 bytes 474 bytes 100.0% 🚀
assets/app.commands-BtOP0jPS.js (New) 455 bytes 455 bytes 100.0% 🚀
assets/app.playground-BzYn0Xwd.js (New) 442 bytes 442 bytes 100.0% 🚀
assets/index-BPBk3bod.js (New) 438 bytes 438 bytes 100.0% 🚀
assets/app.digest-D7TQmknz.js (New) 430 bytes 430 bytes 100.0% 🚀
assets/eye-off-DFWYwQHn.js (New) 430 bytes 430 bytes 100.0% 🚀
assets/app.miner-FW94CuGr.js (New) 422 bytes 422 bytes 100.0% 🚀
assets/key-round-Bf47khQa.js (New) 355 bytes 355 bytes 100.0% 🚀
assets/bot-DaJULD9c.js (New) 328 bytes 328 bytes 100.0% 🚀
assets/trash-2-BPDBn-jV.js (New) 328 bytes 328 bytes 100.0% 🚀
assets/save-DGDZI0bb.js (New) 327 bytes 327 bytes 100.0% 🚀
assets/git-pull-request-arrow-B4fNJL5x.js (New) 321 bytes 321 bytes 100.0% 🚀
assets/list-checks-D4E68ExU.js (New) 279 bytes 279 bytes 100.0% 🚀
assets/compass-BvyqHKPd.js (New) 251 bytes 251 bytes 100.0% 🚀
assets/history-CANcsOs3.js (New) 237 bytes 237 bytes 100.0% 🚀
assets/message-square-DR1pJk_4.js (New) 233 bytes 233 bytes 100.0% 🚀
assets/lock-hYiPwyK8.js (New) 206 bytes 206 bytes 100.0% 🚀
assets/rotate-cw-Cgmrz7Hb.js (New) 201 bytes 201 bytes 100.0% 🚀
assets/play-C4XH4baf.js (New) 190 bytes 190 bytes 100.0% 🚀
assets/circle-check--NMvNaEc.js (New) 178 bytes 178 bytes 100.0% 🚀
assets/search-gpTP6R1a.js (New) 174 bytes 174 bytes 100.0% 🚀
assets/add-scalar-classes-CpckAJw7.js (Deleted) -2.16MB 0 bytes -100.0% 🗑️
assets/tanstack-vendor-jSG0qOwH.js (Deleted) -929.17kB 0 bytes -100.0% 🗑️
assets/docs.fumadocs-spike-api-reference-CAJ9nwHj.js (Deleted) -443.45kB 0 bytes -100.0% 🗑️
assets/AgentScalarChatInterface.vue-BVG1BGnC.js (Deleted) -201.7kB 0 bytes -100.0% 🗑️
assets/modal-CI3aTtIm.js (Deleted) -184.5kB 0 bytes -100.0% 🗑️
assets/client-Cfx7r9or.js (Deleted) -151.47kB 0 bytes -100.0% 🗑️
assets/maintainer-panel-WCenTlfY.js (Deleted) -78.99kB 0 bytes -100.0% 🗑️
assets/routes-CNYuSS6E.js (Deleted) -35.96kB 0 bytes -100.0% 🗑️
assets/owner-panel-7icsvLKN.js (Deleted) -27.99kB 0 bytes -100.0% 🗑️
assets/app-BBOF3N-i.js (Deleted) -25.78kB 0 bytes -100.0% 🗑️
assets/ui-vendor-Bf_DjUlJ.js (Deleted) -24.57kB 0 bytes -100.0% 🗑️
assets/miner-panel-B_5vhoZZ.js (Deleted) -20.24kB 0 bytes -100.0% 🗑️
assets/app.runs-Dk6f334u.js (Deleted) -20.22kB 0 bytes -100.0% 🗑️
assets/api._op-CAUogDC4.js (Deleted) -17.57kB 0 bytes -100.0% 🗑️
assets/self-hosting-docs-audit-DWvIKAF-.js (Deleted) -16.6kB 0 bytes -100.0% 🗑️
assets/docs._slug-CbLcuCbS.js (Deleted) -15.52kB 0 bytes -100.0% 🗑️
assets/playground-panel-DIodF9--.js (Deleted) -14.42kB 0 bytes -100.0% 🗑️
assets/fairness-DEtlsZg5.js (Deleted) -13.98kB 0 bytes -100.0% 🗑️
assets/app.audit-LvJiqdWC.js (Deleted) -10.08kB 0 bytes -100.0% 🗑️
assets/app.config-generator-HvuleBJc.js (Deleted) -10.06kB 0 bytes -100.0% 🗑️
assets/maintainers-BWAxNIdu.js (Deleted) -8.06kB 0 bytes -100.0% 🗑️
assets/miners-BmyDrhsk.js (Deleted) -7.91kB 0 bytes -100.0% 🗑️
assets/agents-C4r26Vy8.js (Deleted) -7.74kB 0 bytes -100.0% 🗑️
assets/commands-panel-H45BMY7j.js (Deleted) -6.65kB 0 bytes -100.0% 🗑️
assets/maintainer-workflow-Jajy4AWK.js (Deleted) -6.52kB 0 bytes -100.0% 🗑️
assets/digest-panel-CB0jWd4O.js (Deleted) -6.15kB 0 bytes -100.0% 🗑️
assets/repos._owner._repo.quality-Do5Ouyq3.js (Deleted) -6.14kB 0 bytes -100.0% 🗑️
assets/docs-nav-DqKPIPBZ.js (Deleted) -6.01kB 0 bytes -100.0% 🗑️
assets/docs.index-_EHrdDYO.js (Deleted) -5.95kB 0 bytes -100.0% 🗑️
assets/api.index-BrfDtSDi.js (Deleted) -4.7kB 0 bytes -100.0% 🗑️
assets/docs-BTjKzJne.js (Deleted) -2.7kB 0 bytes -100.0% 🗑️
assets/api-BKRI__-Q.js (Deleted) -2.69kB 0 bytes -100.0% 🗑️
assets/docs-page-Cn43ifm4.js (Deleted) -2.1kB 0 bytes -100.0% 🗑️
assets/table-Bc3HSbuf.js (Deleted) -1.75kB 0 bytes -100.0% 🗑️
assets/app.workbench-BSROBbfz.js (Deleted) -1.58kB 0 bytes -100.0% 🗑️
assets/tabs-BX8qkAz4.js (Deleted) -1.39kB 0 bytes -100.0% 🗑️
assets/app.repos-CP2UyF46.js (Deleted) -1.07kB 0 bytes -100.0% 🗑️
assets/input-BqVLAGYv.js (Deleted) -796 bytes 0 bytes -100.0% 🗑️
assets/file-cog-D2Rd_ZC4.js (Deleted) -758 bytes 0 bytes -100.0% 🗑️
assets/app.maintainer-CRc5kNCH.js (Deleted) -502 bytes 0 bytes -100.0% 🗑️
assets/app.owner-_8xr3eil.js (Deleted) -474 bytes 0 bytes -100.0% 🗑️
assets/app.commands-DN52M4_4.js (Deleted) -455 bytes 0 bytes -100.0% 🗑️
assets/app.playground-CpCbnlQp.js (Deleted) -442 bytes 0 bytes -100.0% 🗑️
assets/index-DdJPT2wo.js (Deleted) -438 bytes 0 bytes -100.0% 🗑️
assets/app.digest-CT_kvd9D.js (Deleted) -430 bytes 0 bytes -100.0% 🗑️
assets/eye-off-D8SbS7zy.js (Deleted) -430 bytes 0 bytes -100.0% 🗑️
assets/app.miner-C7yc7W4M.js (Deleted) -422 bytes 0 bytes -100.0% 🗑️
assets/key-round-DYhQr0ag.js (Deleted) -355 bytes 0 bytes -100.0% 🗑️
assets/bot-DI76Rvwk.js (Deleted) -328 bytes 0 bytes -100.0% 🗑️
assets/trash-2-DiCArEGg.js (Deleted) -328 bytes 0 bytes -100.0% 🗑️
assets/save-Dim3-rnd.js (Deleted) -327 bytes 0 bytes -100.0% 🗑️
assets/git-pull-request-arrow-WE2uLd3c.js (Deleted) -321 bytes 0 bytes -100.0% 🗑️
assets/list-checks-CgEt3psO.js (Deleted) -279 bytes 0 bytes -100.0% 🗑️
assets/compass-BjNCaKK8.js (Deleted) -251 bytes 0 bytes -100.0% 🗑️
assets/history-DuummLVJ.js (Deleted) -237 bytes 0 bytes -100.0% 🗑️
assets/message-square-Ck1a9Ocz.js (Deleted) -233 bytes 0 bytes -100.0% 🗑️
assets/lock-DTgZIQSq.js (Deleted) -206 bytes 0 bytes -100.0% 🗑️
assets/rotate-cw-Bn2srQKR.js (Deleted) -201 bytes 0 bytes -100.0% 🗑️
assets/play-BFlmSNLI.js (Deleted) -190 bytes 0 bytes -100.0% 🗑️
assets/circle-check-GbDdJEL5.js (Deleted) -178 bytes 0 bytes -100.0% 🗑️
assets/search-C_CtyCf_.js (Deleted) -174 bytes 0 bytes -100.0% 🗑️

@JSONbored JSONbored self-assigned this Jul 29, 2026
@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 29, 2026
@JSONbored
JSONbored merged commit 94809a8 into main Jul 29, 2026
8 checks passed
@JSONbored
JSONbored deleted the fix/miner-ui-chat-dispatch-type branch July 29, 2026 14:05
JSONbored added a commit that referenced this pull request Jul 29, 2026
…ed (#9846)

main is red on ui:typecheck, which blocks every open PR.

#9659/#9815 correctly tightened ChatActionDispatchResult from a loose
`{ ok: boolean; status: string; ... }` into a union discriminated on `ok`, so the
miner MCP server's refusal -> error-code mapping could finally be checked. But
this miner-UI test mocks the dispatcher with a bare object literal, whose
`ok`/`status` widen to boolean/string on inference -- and a widened literal no
longer satisfies the closed union.

Annotate the mock's return type (and import the real type) so it is validated
against the shipped contract instead of inference. That also stops the mock
drifting from the union the next time it changes -- the widened version would
have kept compiling against any shape at all.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant