Skip to content

fix(acp): forward session title updates to clients via session_info_update - #61315

Open
davidfunn wants to merge 3 commits into
anomalyco:devfrom
davidfunn:fix-acp-session-title-updates
Open

davidfunn wants to merge 3 commits into
anomalyco:devfrom
davidfunn:fix-acp-session-title-updates

Conversation

@davidfunn

Copy link
Copy Markdown

Issue for this PR

Closes #56894

Type of change

  • Bug fix

What does this PR do?

opencode acp never told clients about generated session titles. Core generates a title after the first user message (SessionTitle.generate, durable event session.renamed), and session/list returns stored titles, but nothing pushed title changes mid-session. ACP clients that display dynamic session names from session_info_update (e.g. the ACP Pro extension) were stuck with a fallback label like opencode - Session xxxx until they re-listed sessions.

Changes:

  • packages/cli/src/acp/sessions.ts: the existing global event subscription now also handles session.renamed and forwards it for attached sessions as {sessionUpdate: "session_info_update", title}. This is global rather than per-turn because title generation runs in a detached fiber that can settle after the triggering turn has ended; it also covers renames from other sources (e.g. session/fork). Renames for sessions the adapter does not have attached are ignored.
  • packages/cli/src/acp/service.ts: loading, resuming, or forking a session that already carries a non-fallback title now announces it once via session_info_update. A titled session never triggers title generation again, so without this the client would never learn the stored title. Fallback titles (New session - <timestamp>) are left alone so clients can replace them on the first rename.

How did you verify your code works?

New wire tests in packages/cli/test/acp/session.test.ts:

  • a rename of an attached session produces a session_info_update with the title
  • a title arriving mid-turn (through session/prompt) is forwarded
  • renames for unattached sessions are dropped
  • load/resume/fork of a titled session announces the stored title, while a fallback-titled session announces nothing

Adjusted replay.test.ts and the command-ordering expectations to account for the new notification. bun test test/acp/ (104 tests), tsc -b, and the repo's lint + typecheck all pass.

Screenshots / recordings

N/A — protocol-level change, no UI.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I ran opencode acp from source on the base and with this PR. After renaming a session through the HTTP API, session/resume and session/load sent no session_info_update on the base. With the PR, each sent one carrying the stored title, before the response. The live-rename path needs a real model, so I didn't run it end to end, but the new wire tests cover it. bun test test/acp/ passes (104 tests) and tsc -b is clean.

Public API impact: no SDK, HTTP, config or CLI changes. The only change is that the ACP adapter now sends a standard session_info_update notification with title on rename and on load/resume/fork of a titled session. Clients that don't handle this update can ignore it, so it is backwards compatible.

One small robustness point, in the inline comment: a failed rename notification would stop the shared event stream.

Stream.runForEach((event) => {
const entry = sessions.get(event.data.sessionID)
if (!entry) return Effect.void
if (event.type === "session.renamed") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the shared event stream depend on connection.sessionUpdate, which can fail with a RequestError. Before this change, the stream only ran Queue.offer, which can't fail. If one rename notification fails now, the catchCause below logs a warning and the stream ends. After that, model and agent changes made outside the client stop reaching it for every attached session, and so do later renames. Ignoring a failed notification here (for example Effect.ignore, or logging it) keeps the stream running.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — fixed in 32f5eb6. The rename notification is now best-effort: it catches the cause, logs a warning, and keeps the shared stream running, so one failed sessionUpdate can no longer take down selection forwarding for every attached session. Interruption is still allowed through (Cause.hasInterruptsOnly), matching the handling of the other background notifications in this package (usage updates, child session updates). The full ACP suite (104 tests) and typecheck pass.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The earlier point is addressed. A failed rename notification is now caught and logged, so it no longer stops the shared event stream that carries model and agent changes. I re-ran bun test test/acp/ (104 pass) and tsc -b (clean), and loading a renamed session still sends the stored title as a session_info_update. Nothing new to raise. The public API is unchanged by this commit.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new commit only merges dev, and the ACP changes are the same as at my last review. Re-checked on the merged head: bun test test/acp/ passes (104 tests), tsc -b is clean, and resuming a renamed session over opencode acp still sends the stored title as a session_info_update. Nothing new to raise. The public API is unchanged by this commit.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

acp: generated session titles are never pushed to clients (no session_info_update with title)

1 participant