Repository navigation
A client-named session id, and a user message stored in one transaction - #4
Merged
Merged
Conversation
…nsaction A session under the id the client names: ACP newSession passes a _meta.opencode.sessionId with the "ses" prefix to session.create as id, and Session.create takes an optional id. An id that names an existing session is refused and that session is left as it was. ACP clients that send no _meta, or an id without the prefix, keep opencode-minted ids. A user message and its parts in one transaction: Session.saveMessage publishes a message and its parts inside one transaction, and createUserMessage uses it. Each part was its own commit, so on Postgres a reader between them saw a user message holding its context part without its text. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 72 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
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.
Two fork changes for DocuMentor's first prompt in a new chat (design:
docs/superpowers/specs/2026-10-11-first-prompt-stable-ids-design.mdin TheFabFab/KPG, F4 and F5).F4: create a session under the id the client names
newSessionpasses_meta.opencode.sessionId(prefixses) tosession.createasid.Session.CreateInputandSession.createtake an optionalid.onConflictDoNothingthenSessionAlreadyProjected);createchecks first so the error names the id._meta, or an id without the prefix, keep opencode-minted ids.idonsession.create(packages/sdk/js/script/build.ts, no hand edits).Why: DocuMentor shows a new chat as a temporary
new-…thread untilsession/newanswers (~3.5 s on a cold spawn), then switches toses_…. With the id chosen up front the chat has its final id from the first keystroke.F5: store a user message and its parts in one transaction
Session.saveMessagepublishes a message and its parts inside onedb.transaction, the same patternSession.patchuses.createUserMessageuses it.Why: each part was its own commit. On Postgres, DocuMentor's catch-up read a user message between the commits and saw only its
<system-message>context part; the user's text disappeared from the live chat until a reload (production bug report2026-10-11-19-31-37-831-snapshot).Tests (
documentor: …)test/acp/service-session.test.ts: the_metaid is used; no_metaor a UUID gets a minted id.test/session/session.test.ts:createunder a chosen id; an existing id is refused and the session keeps its title;saveMessagestores every part; a part that cannot be stored leaves no message row. That last test fails without the transaction (checked by removing it).Run locally against Postgres 18:
service-session47/47,session12/12,httpapi-session21/21,httpapi-instance7/7.prompt.test.ts61/62:cancel finalizes interrupted bash tool output through normal truncationfails in a full-file run with and without this change, and passes alone. Typecheck shows the same 14 errors before and after (they come from installing with--ignore-scriptshere).Release after merge: tag
v1.18.34-documentor-pg.4, then bump the digest pin in DocuMentor'sDockerfileandDockerfile.dev.🤖 Generated with Claude Code