chore(app): use schema ID minting instead of hand-rolled encoder - #43542
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Deletes the web app's hand-rolled ID generator.
packages/app/src/utils/id.tsreimplemented the schema identifier's entire encoding — same 6-byte hex timestamp+counter, same base62 randomness, samemsg_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 viaSessionMessage.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.promptmints a client ID when none is supplied, so the fallback mint, the caller pre-mint, and themessageIDplumbing throughsendFollowupDraftare all removed.packages/app/src/pages/session.tsx— the queued-followup list key mints viaSessionMessage.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 (idundefined 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 typecheckgreen.utils/id/Identifierreferences.