Skip to content

A client-named session id, and a user message stored in one transaction - #4

Merged
TheFabFab merged 1 commit into
documentor-pgfrom
documentor-first-prompt-ids
Oct 11, 2026
Merged

TheFabFab merged 1 commit into
documentor-pgfrom
documentor-first-prompt-ids

Conversation

@TheFabFab

Copy link
Copy Markdown
Owner

Two fork changes for DocuMentor's first prompt in a new chat (design: docs/superpowers/specs/2026-10-11-first-prompt-stable-ids-design.md in TheFabFab/KPG, F4 and F5).

F4: create a session under the id the client names

  • ACP newSession passes _meta.opencode.sessionId (prefix ses) to session.create as id. Session.CreateInput and Session.create take an optional id.
  • An id that names an existing session is refused, and that session is left as it was. The projector already refused a duplicate row (onConflictDoNothing then SessionAlreadyProjected); create checks first so the error names the id.
  • ACP clients that send no _meta, or an id without the prefix, keep opencode-minted ids.
  • The generated v2 SDK gains id on session.create (packages/sdk/js/script/build.ts, no hand edits).

Why: DocuMentor shows a new chat as a temporary new-… thread until session/new answers (~3.5 s on a cold spawn), then switches to ses_…. 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.saveMessage publishes a message and its parts inside one db.transaction, the same pattern Session.patch uses. createUserMessage uses 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 report 2026-10-11-19-31-37-831-snapshot).

Tests (documentor: …)

  • test/acp/service-session.test.ts: the _meta id is used; no _meta or a UUID gets a minted id.
  • test/session/session.test.ts: create under a chosen id; an existing id is refused and the session keeps its title; saveMessage stores 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-session 47/47, session 12/12, httpapi-session 21/21, httpapi-instance 7/7. prompt.test.ts 61/62: cancel finalizes interrupted bash tool output through normal truncation fails 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-scripts here).

Release after merge: tag v1.18.34-documentor-pg.4, then bump the digest pin in DocuMentor's Dockerfile and Dockerfile.dev.

🤖 Generated with Claude Code

…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>
@github-actions

Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

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.

@github-actions

Copy link
Copy Markdown

Hey! Your PR title A client-named session id, and a user message stored in one transaction doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@TheFabFab
TheFabFab merged commit 3cd827a into documentor-pg Oct 11, 2026
6 of 11 checks passed
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