@@ -3134,7 +3134,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
31343134 providerSessionId: ProviderSessionId.make("provider-session-claude-wake"),
31353135 modelSelection: CLAUDE_TEST_MODEL_SELECTION,
31363136 runtimePolicy: CLAUDE_TEST_RUNTIME_POLICY,
3137- promptSuggestions: options?.promptSuggestions === true,
3137+ promptSuggestions: Effect.succeed( options?.promptSuggestions === true) ,
31383138 });
31393139 const providerThread = yield* runtime.ensureThread({
31403140 threadId,
@@ -6804,53 +6804,94 @@ describe("ClaudeAdapterV2 background wake turns", () => {
68046804 ),
68056805 );
68066806
6807- it.effect("offers the prompt suggestion Claude sends after a completed turn", () =>
6808- Effect.gen(function* () {
6809- const harness = yield* makeWakeHarnessWithOptions({ promptSuggestions: true });
6810- const input = makeClaudeTestTurnInput({
6811- threadId: harness.threadId,
6812- providerThread: harness.providerThread,
6813- now: yield* DateTime.now,
6814- attemptId: RunAttemptId.make("attempt-prompt-suggestion"),
6815- text: "Add a subtract function.",
6816- attachments: [],
6817- });
6818- yield* harness.runtime.startTurn(input);
6819- yield* Queue.offer(
6820- harness.sdkMessages,
6821- makeResultFrame({ uuid: "00000000-0000-4000-8000-000000000690", result: "Done." }),
6822- );
6823- yield* Queue.take(harness.terminalReceipts);
6824- yield* Queue.offer(
6825- harness.sdkMessages,
6826- claudeSdkFrame({
6827- type: "prompt_suggestion",
6828- suggestion: " add tests for subtract\n",
6829- uuid: "00000000-0000-4000-8000-000000000691",
6830- session_id: WAKE_NATIVE_SESSION,
6831- }),
6832- );
6833- yield* harness.until(() =>
6834- harness.events.some((event) => event.type === "prompt_suggestion.updated"),
6835- );
6836- assert.equal(harness.getOpenedOptions()?.promptSuggestions, true);
6837- assert.deepEqual(
6838- harness.events.filter((event) => event.type === "prompt_suggestion.updated"),
6839- [
6840- {
6841- type: "prompt_suggestion.updated",
6842- driver: ClaudeAdapterV2.CLAUDE_PROVIDER,
6843- threadId: harness.threadId,
6844- runId: input.runId,
6845- text: "add tests for subtract",
6846- },
6847- ],
6848- );
6849- }).pipe(
6850- Effect.provide(
6851- Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
6807+ it.effect.each(["root", "mcp", "subagent", "remote"] as const)(
6808+ "asks Claude for suggestions only on threads a person drives (%s)",
6809+ (lineage) =>
6810+ Effect.gen(function* () {
6811+ const harness = yield* makeWakeHarnessWithOptions({ promptSuggestions: true });
6812+ const base = makeClaudeTestTurnInput({
6813+ threadId: harness.threadId,
6814+ providerThread: harness.providerThread,
6815+ now: yield* DateTime.now,
6816+ attemptId: RunAttemptId.make("attempt-prompt-suggestion"),
6817+ text: "Add a subtract function.",
6818+ attachments: [],
6819+ });
6820+ const parentThreadId = ThreadId.make("thread-claude-suggestion-parent");
6821+ // MCP-launched root threads carry `delegatedFrom: null` at runtime.
6822+ const offered = lineage === "root" || lineage === "mcp";
6823+ const input =
6824+ lineage === "root"
6825+ ? base
6826+ : lineage === "mcp"
6827+ ? {
6828+ ...base,
6829+ appThread: {
6830+ ...base.appThread,
6831+ delegatedFrom: null as unknown as undefined,
6832+ },
6833+ }
6834+ : lineage === "subagent"
6835+ ? {
6836+ ...base,
6837+ appThread: {
6838+ ...base.appThread,
6839+ lineage: {
6840+ parentThreadId,
6841+ relationshipToParent: "subagent" as const,
6842+ rootThreadId: parentThreadId,
6843+ },
6844+ },
6845+ }
6846+ : {
6847+ ...base,
6848+ appThread: {
6849+ ...base.appThread,
6850+ delegatedFrom: {
6851+ environmentId: EnvironmentId.make("environment-claude-suggestion-parent"),
6852+ threadId: parentThreadId,
6853+ title: "Parent",
6854+ },
6855+ },
6856+ };
6857+ yield* harness.runtime.startTurn(input);
6858+ yield* Queue.offer(
6859+ harness.sdkMessages,
6860+ makeResultFrame({ uuid: "00000000-0000-4000-8000-000000000690", result: "Done." }),
6861+ );
6862+ yield* Queue.take(harness.terminalReceipts);
6863+ // Delegated threads have no one typing, so the SDK is never asked for suggestions.
6864+ assert.equal(harness.getOpenedOptions()?.promptSuggestions, offered);
6865+ if (!offered) return;
6866+ yield* Queue.offer(
6867+ harness.sdkMessages,
6868+ claudeSdkFrame({
6869+ type: "prompt_suggestion",
6870+ suggestion: " add tests for subtract\n",
6871+ uuid: "00000000-0000-4000-8000-000000000691",
6872+ session_id: WAKE_NATIVE_SESSION,
6873+ }),
6874+ );
6875+ yield* harness.until(() =>
6876+ harness.events.some((event) => event.type === "prompt_suggestion.updated"),
6877+ );
6878+ assert.deepEqual(
6879+ harness.events.filter((event) => event.type === "prompt_suggestion.updated"),
6880+ [
6881+ {
6882+ type: "prompt_suggestion.updated",
6883+ driver: ClaudeAdapterV2.CLAUDE_PROVIDER,
6884+ threadId: harness.threadId,
6885+ runId: input.runId,
6886+ text: "add tests for subtract",
6887+ },
6888+ ],
6889+ );
6890+ }).pipe(
6891+ Effect.provide(
6892+ Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
6893+ ),
68526894 ),
6853- ),
68546895 );
68556896
68566897 it.effect("merges cumulative stream usage into the message_start counts", () =>
0 commit comments