@devries-cameron20 / t3code Mirror · read-only / commits / bd438fb315
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 23, 04:15 UTC

fix(acp): preserve native slash command prompt shape (#19393)

James C committed Oct 18, 2026 at 20:10 UTC bd438fb315ffae6cb42e03d24291983ebe4e75bb
2 files changed +39 -25
apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts
+29 -18
@@ -511,19 +511,19 @@ function rawProtocolRequestParam(
511 return typeof params === "object" && params !== null ? Reflect.get(params, key) : undefined;
512 }
513
514 -function rawProtocolPromptText(event: EffectAcpProtocol.AcpProtocolLogEvent): string {
514 +function rawProtocolPromptTextBlocks(
515 + event: EffectAcpProtocol.AcpProtocolLogEvent,
516 +): Array<{ type: "text"; text: string }> {
517 const prompt = rawProtocolRequestParam(event, "prompt");
516 - if (!Array.isArray(prompt)) return "";
517 - return prompt
518 - .flatMap((block) =>
519 - typeof block === "object" &&
520 - block !== null &&
521 - Reflect.get(block, "type") === "text" &&
522 - typeof Reflect.get(block, "text") === "string"
523 - ? [Reflect.get(block, "text") as string]
524 - : [],
525 - )
526 - .join("\n");
518 + if (!Array.isArray(prompt)) return [];
519 + return prompt.flatMap((block) =>
520 + typeof block === "object" &&
521 + block !== null &&
522 + Reflect.get(block, "type") === "text" &&
523 + typeof Reflect.get(block, "text") === "string"
524 + ? [{ type: "text" as const, text: Reflect.get(block, "text") as string }]
525 + : [],
526 + );
527 }
528
529 const pollProtocolMethods = (events: Queue.Queue<EffectAcpProtocol.AcpProtocolLogEvent>) =>
@@ -841,7 +841,12 @@ describe("AcpAdapterV2", () => {
841 if (method === undefined) continue;
842 methods.push(method);
843 if (method === "session/prompt") {
844 - return { methods, prompt: rawProtocolPromptText(event) };
844 + const promptBlocks = rawProtocolPromptTextBlocks(event);
845 + return {
846 + methods,
847 + prompt: promptBlocks.map((block) => block.text).join("\n"),
848 + textBlockCount: promptBlocks.length,
849 + };
850 }
851 }
852 });
@@ -849,7 +854,13 @@ describe("AcpAdapterV2", () => {
854 const command = yield* runTurn(0, defaultPolicy, "/compact");
855 assert.isTrue(command.prompt.startsWith("/compact"));
856 assert.notInclude(command.prompt, "<t3_code_instructions>");
852 - const firstDefault = yield* runTurn(1, defaultPolicy, "First default request.");
857 + assert.equal(command.textBlockCount, 1);
858 + const whitespaceCommand = yield* runTurn(1, defaultPolicy, " /repro-skill");
859 + assert.equal(whitespaceCommand.prompt, " /repro-skill");
860 + assert.equal(whitespaceCommand.textBlockCount, 1);
861 + assert.notInclude(whitespaceCommand.prompt, "<t3_code_instructions>");
862 + const firstDefault = yield* runTurn(2, defaultPolicy, "First default request.");
863 + assert.equal(firstDefault.textBlockCount, 2);
864 assert.include(firstDefault.prompt, "T3 Code interaction mode: Default");
865 assert.include(firstDefault.prompt, "T3 Code collaborative browser");
866 assert.include(firstDefault.prompt, "T3 Code orchestration");
@@ -859,19 +870,19 @@ describe("AcpAdapterV2", () => {
870 "Build should preserve the agent's advertised mode default",
871 );
872 assert.include(
862 - (yield* runTurn(2, defaultPolicy, "Second default request.")).prompt,
873 + (yield* runTurn(3, defaultPolicy, "Second default request.")).prompt,
874 "Second default request.",
875 );
876
877 const planPolicy = policy("plan");
867 - const firstPlan = yield* runTurn(3, planPolicy, "Plan this change.");
878 + const firstPlan = yield* runTurn(4, planPolicy, "Plan this change.");
879 assert.include(firstPlan.prompt, "T3 Code interaction mode: Plan");
880 assert.include(firstPlan.methods, "session/set_config_option");
881 assert.include(
871 - (yield* runTurn(4, planPolicy, "Continue planning.")).prompt,
882 + (yield* runTurn(5, planPolicy, "Continue planning.")).prompt,
883 "Continue planning.",
884 );
874 - const restoredBuild = yield* runTurn(5, defaultPolicy, "Implement the change.");
885 + const restoredBuild = yield* runTurn(6, defaultPolicy, "Implement the change.");
886 assert.include(restoredBuild.prompt, "T3 Code interaction mode: Default");
887 assert.include(
888 restoredBuild.methods,
packages/provider-acp/src/server/adapter.ts
+10 -7
@@ -6316,6 +6316,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
6316 attachments: turnInput.message.attachments,
6317 resolveAttachmentPath: host.resolveAttachmentPath,
6318 });
6319 + const isNativeSlashCommand = turnInput.message.text.trimStart().startsWith("/");
6320 const text = t3AcpPromptWithInstructions({
6321 prompt: messageText,
6322 state: instructionState,
@@ -6365,13 +6366,15 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
6366 detail: "ACP turn requires non-empty text or attachments",
6367 });
6368 }
6368 - prompt.push({
6369 - type: "text",
6370 - text: buildRuntimeInstructions({
6371 - harness: flavor.runtimeHarness ?? driver,
6372 - model: turnInput.modelSelection.model,
6373 - }),
6374 - });
6369 + if (!isNativeSlashCommand) {
6370 + prompt.push({
6371 + type: "text",
6372 + text: buildRuntimeInstructions({
6373 + harness: flavor.runtimeHarness ?? driver,
6374 + model: turnInput.modelSelection.model,
6375 + }),
6376 + });
6377 + }
6378 return { prompt, instructionState: text === messageText ? undefined : instructionState };
6379 });
6380