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 21, 08:30 UTC
fix(client): a subagent prompt that opens with comment dividers no longer freezes the thread (#38368)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Martin Bergo committed
Nov 18, 2026 at 01:28 UTC
24467d671d182bdac5915088bed23a4d34a46dfe
2 files changed
+15
-1
packages/client-runtime/src/state/subagentRuntime.test.ts
+12
@@ -316,5 +316,17 @@ describe("resolveWorkflowOpening", () => {
316
false,
317
);
318
expect(isWorkflowScriptMessage({ role: "assistant", text: SCRIPT })).toBe(false);
319
+ expect(
320
+ isWorkflowScriptMessage({ role: "user", text: `// a\r// b\u2028/* c\n * d */\r\n${SCRIPT}` }),
321
+ ).toBe(true);
322
+ expect(isWorkflowScriptMessage({ role: "user", text: "// export const meta = {}" })).toBe(
323
+ false,
324
+ );
325
+ // Divider comments ahead of ordinary code must reject without catastrophic backtracking.
326
+ const dividers = `${"/".repeat(40)}\n`.repeat(40);
327
+ expect(isWorkflowScriptMessage({ role: "user", text: `${dividers}const x = 1;` })).toBe(false);
328
+ expect(
329
+ isWorkflowScriptMessage({ role: "user", text: `${"/**/".repeat(200)}const x = 1;` }),
330
+ ).toBe(false);
331
});
332
});
packages/client-runtime/src/state/subagentRuntime.ts
+3
-1
@@ -325,7 +325,9 @@ export function deriveWorkflowGroups(
325
}
326
327
// Workflow scripts open with their `meta` export, after any leading comments.
328
-const WORKFLOW_SCRIPT_START = /^\s*(?:(?:\/\/[^\n]*|\/\*[\s\S]*?\*\/)\s*)*export\s+const\s+meta\b/;
328
+// Each comment has one way to match, so a prompt of `////` divider lines cannot backtrack.
329
+const WORKFLOW_SCRIPT_START =
330
+ /^\s*(?:(?:\/\/[^\r\n\u2028\u2029]*(?:[\r\n\u2028\u2029]|$)|\/\*(?:[^*]|\*(?!\/))*\*\/)\s*)*export\s+const\s+meta\b/;
331
332
/**
333
* Whether a user message is the script a provider-native workflow runs. Servers mark every