Skip to content

chore(app): use schema ID minting instead of hand-rolled encoder - #43542

Merged
kitlangton merged 1 commit into
v2from
id-mint-dedup
Aug 20, 2026
Merged

chore(app): use schema ID minting instead of hand-rolled encoder#43542
kitlangton merged 1 commit into
v2from
id-mint-dedup

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

What

Deletes the web app's hand-rolled ID generator. packages/app/src/utils/id.ts reimplemented the schema identifier's entire encoding — same 6-byte hex timestamp+counter, same base62 randomness, same msg_ prefix — plus prefix kinds (session, permission, user, part, pty) that had no callers. A byte-for-byte parallel implementation like this only ever gets to drift silently.

Net: −98 lines, one source of truth for ID minting.

How

  • packages/app/src/components/prompt-input/submit.ts — the two command sends mint via SessionMessage.ID.create() from @opencode-ai/schema. The prompt path stops pre-minting entirely: since feat(client): optimistic prompt admission with client-minted IDs #43520, data.session.prompt mints a client ID when none is supplied, so the fallback mint, the caller pre-mint, and the messageID plumbing through sendFollowupDraft are all removed.
  • packages/app/src/pages/session.tsx — the queued-followup list key mints via SessionMessage.ID.create() (currently a client-local key; the send path behind it is TODO-stubbed).
  • packages/app/src/utils/id.ts — deleted.
  • submit.test.ts — the prompt-input assertion now pins the delegation (id undefined at the data-layer boundary); the mint itself is covered by the data-layer tests in packages/tui.

Scope

No behavior change. Prompt sends still get client-minted idempotent IDs — the mint just happens in one place (the data layer) instead of two.

Testing

  • packages/app: 551 unit + 44 browser tests pass, bun typecheck green.
  • Repo-wide grep confirms no remaining utils/id / Identifier references.

packages/app/src/utils/id.ts reimplemented the schema identifier's
entire timestamp+base62 encoding (plus five prefix kinds nothing used).
Replace the live call sites with SessionMessage.ID.create() from
@opencode-ai/schema and delete the parallel implementation before it
can drift.

The prompt path no longer pre-mints at all: the data layer mints a
client ID when none is supplied, so the fallback mint, the caller
pre-mint, and the messageID plumbing through sendFollowupDraft are
removed. Command sends keep an explicit client-minted ID.
@kitlangton
kitlangton merged commit 30db9dd into v2 Aug 20, 2026
10 checks passed
@kitlangton
kitlangton deleted the id-mint-dedup branch August 20, 2026 00:59
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