Skip to content

[dashboards] pro dashboard: handle UUID thought ids#47

Open
alanshurafa wants to merge 2 commits into
mainfrom
contrib/alanshurafa/thoughts-uuid-dashboard
Open

[dashboards] pro dashboard: handle UUID thought ids#47
alanshurafa wants to merge 2 commits into
mainfrom
contrib/alanshurafa/thoughts-uuid-dashboard

Conversation

@alanshurafa

Copy link
Copy Markdown
Owner

What

The pro dashboard typed thought ids as number and validated route ids with positive-integer guards. Open Brain uses UUID primary keys for thoughts, so on a real install this breaks at runtime:

  • the thought-detail page ran parseInt(id) and 404'd on every UUID;
  • the connections, duplicates/resolve, and audit/delete routes rejected every UUID with a Number.isInteger(id) && id > 0 guard.

The next dashboard already types thought ids as string; this brings pro to parity.

Changes

All under dashboards/open-brain-dashboard-pro/ (8 files, +46/-37):

  • Types (lib/types.ts, lib/api.ts): Thought.id, CaptureResult.thought_id, AddToBrainResult.thought_id, DuplicatePair.thought_id_a/b, DuplicateResolveResult.survivor_id/loser_id, and the fetchThought/updateThought/deleteThought/resolveDuplicate id params and returns become string.
  • Route guards (thoughts/[id]/connections, duplicates/resolve, audit/delete) and the thought-detail page: positive-integer checks become a UUID regex, forwarding the raw id. The regex matches the one smart-ingest [integrations] smart-ingest: handle UUID thought/job ids #36 uses.
  • Components (ConnectionsPanel, audit/page): Connection.id, the thoughtId prop, and the audit selection Set<number> become string-typed.

Out of scope (intentional)

The ingest flow (IngestionJob/IngestionItem ids, job_id, matched_thought_id/result_thought_id, and the app/api/ingest/[id]/** routes) stays number. Those are integer job ids owned by the smart-ingest PR #36; converting them here would conflict at merge. With #36 also on this base, both flows end up consistent.

Verification

  • tsc --noEmit, npm run lint, and next build all clean (17/17 pages build).
  • Reviewed for security regressions (Claude + Codex): the UUID guard is stricter than the old integer check (rejects "1e3", "0x10", trailing-newline path injection, and similar), and the bulk-delete cap, audit quality re-verification, and duplicate-pair re-verification are unchanged.

Follow-up (not in this PR)

duplicates/page.tsx renders #{thought_id_a}, which now shows the full UUID instead of a short integer. Cosmetic only; truncating to a short prefix is a separate UX tweak.

🤖 Generated with Claude Code

The pro dashboard was ported from a bigint-id codebase and typed thought
ids as `number`, guarding route ids with positive-integer checks. On Open
Brain, where thoughts use UUID primary keys, that breaks at runtime: the
thought-detail page ran parseInt(id) and 404'd on every UUID, and the
connections, duplicates-resolve, and audit-delete routes rejected every
UUID with a positive-integer guard.

Convert every thought-id field from number to string and replace the
positive-integer guards with a UUID regex (the same one smart-ingest
PR #36 uses). The ingest flow — IngestionJob/Item ids, job_id, and the
ingest/[id] routes — is left as-is; those are integer job ids owned by
#36, and converting them here would conflict. Brings the pro dashboard to
parity with the next dashboard, which already types thought ids as string.

Verified with tsc --noEmit, eslint, and next build (all clean).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
AddToBrainResult.thought_id and job_id are both UUID strings, matching
every other thought_id/job_id in lib/types.ts. #47 brought thought_id
-> string; main brought job_id -> string; the merge keeps both string.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant