Skip to content

Commit df06b8b

Browse files
fix(server): port #13368 to V2 — OpenCode names its own sessions
OpenCode generates a session title from the first prompt only when session.create leaves the title unset (SessionPrompt.ensureTitle). Main stopped forwarding prompt-seeded titles from the V1 ProviderCommandReactor, which V2 deleted. V2's OpenCode adapter sent a placeholder title, "T3 Code <threadId>", on every session.create, so every V2 OpenCode session in OpenCode's own UI and history was named after an id. session.create no longer sends a title. Main also forwards a title the user renamed by hand. V2 has no title-provenance field on the thread and never sent the thread title, so that part is left out. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 11acae1 commit df06b8b

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

‎apps/server/src/orchestration-v2/Adapters/OpenCodeAdapterV2.test.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1944,6 +1944,7 @@ describe("OpenCodeAdapterV2", () => {
19441944
const idAllocator = yield* IdAllocatorV2;
19451945
const serverConfig = yield* ServerConfig;
19461946
let createCount = 0;
1947+
const createInputs: Array<unknown> = [];
19471948
const fakeClient = {
19481949
event: {
19491950
subscribe: async (_input?: unknown, options?: { readonly signal?: AbortSignal }) => ({
@@ -1961,8 +1962,9 @@ describe("OpenCodeAdapterV2", () => {
19611962
}),
19621963
},
19631964
session: {
1964-
create: async () => {
1965+
create: async (input: unknown) => {
19651966
createCount += 1;
1967+
createInputs.push(input);
19661968
return { data: { id: `ses_native_${createCount}`, time: { created: 1, updated: 1 } } };
19671969
},
19681970
},
@@ -2038,6 +2040,11 @@ describe("OpenCodeAdapterV2", () => {
20382040
});
20392041
assert.notEqual(minted.id, placeholder.id);
20402042
assert.equal(minted.nativeThreadRef?.nativeId, "ses_native_2");
2043+
// OpenCode names a session from its first prompt only when create
2044+
// leaves the title unset, so the adapter never sends one.
2045+
for (const input of createInputs) {
2046+
assert.notProperty(input, "title");
2047+
}
20412048
}).pipe(
20422049
Effect.scoped,
20432050
Effect.provide(

‎apps/server/src/orchestration-v2/Adapters/OpenCodeAdapterV2.ts‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3117,15 +3117,13 @@ export function makeOpenCodeAdapterV2(options: OpenCodeAdapterV2Options): Provid
31173117
providerThread: threadInput.existingProviderThread,
31183118
});
31193119
}
3120+
// No title: OpenCode generates one from the first prompt only when
3121+
// session.create leaves it unset (SessionPrompt.ensureTitle).
31203122
const response = yield* sdkCall(
31213123
"session.create",
3122-
{
3123-
title: `T3 Code ${threadInput.threadId}`,
3124-
permission: openCodePermissionRules(threadInput.runtimePolicy),
3125-
},
3124+
{ permission: openCodePermissionRules(threadInput.runtimePolicy) },
31263125
() =>
31273126
client.session.create({
3128-
title: `T3 Code ${threadInput.threadId}`,
31293127
permission: openCodePermissionRules(threadInput.runtimePolicy),
31303128
}),
31313129
);

0 commit comments

Comments
 (0)