The best way to control Claude Code, Codex and more from any computer or phone
fix(server): imported Claude sessions are titled after the prompt inside a wake envelope (#37257)
Julius Marminge committed
Nov 15, 2026 at 08:08 UTC
09fc222fed646458dacc2badd40fb111c0c92699
2 files changed
+29
-1
apps/server/src/project/AgentSessionScanner.test.ts
+21
@@ -3634,6 +3634,27 @@ describe("parseAgentSessionTranscript", () => {
3634
expect(thread?.messages.map((message) => message.text)).toEqual([prompt]);
3635
});
3636
3637
+ it("titles a Claude session after the prompt inside a wake envelope", () => {
3638
+ const thread = AgentSessionScanner.parseAgentSessionTranscript({
3639
+ contents: JSON.stringify({
3640
+ type: "user",
3641
+ sessionId: "claude-session",
3642
+ timestamp: "2026-08-25T08:00:00.000Z",
3643
+ message: {
3644
+ role: "user",
3645
+ content:
3646
+ '<wake reason="mention" current-time="2026-08-25T08:00:00Z">\nFix the flaky login test\n</wake>',
3647
+ },
3648
+ }),
3649
+ source: "claudeAgent",
3650
+ providerInstanceId: ProviderInstanceId.make("claudeAgent"),
3651
+ fallbackSessionId: "fallback",
3652
+ lastActiveAtMs: Date.parse("2026-08-25T08:00:00.000Z"),
3653
+ });
3654
+
3655
+ expect(thread?.title).toBe("Fix the flaky login test");
3656
+ });
3657
+
3658
it.each([
3659
"Explain <external_codex_apps_open_page> in this transcript",
3660
"<external_codex_apps_open_page>Keep this incomplete example",
apps/server/src/project/AgentSessionScanner.ts
+8
-1
@@ -397,8 +397,15 @@ function codexHistoryBase(records: ReadonlyArray<DecodedTranscriptRecord>) {
397
: undefined;
398
}
399
400
+// Agent-started sessions wrap the prompt in a `<wake reason=… current-time=…>`
401
+// envelope; title them after the prompt inside it.
402
+const WAKE_ENVELOPE = /^\s*<wake(?:\s[^>]*)?>([\s\S]*?)(?:<\/wake>|$)/;
403
+
404
function deriveTitle(source: AgentSessionSource, text: string): string | undefined {
401
- const request = source === "codex" ? text.replace(CODEX_TITLE_PREAMBLE, "") : text;
405
+ const request = (source === "codex" ? text.replace(CODEX_TITLE_PREAMBLE, "") : text).replace(
406
+ WAKE_ENVELOPE,
407
+ "$1",
408
+ );
409
return request.trim().split("\n")[0]?.slice(0, 100).trim() || undefined;
410
}
411