Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t.sh

Commit

A session's title is what was typed, not what was pasted (#51): a prompt that began with pasted text titled its session <pasted_content id="5c50">, since Claude Code wraps a paste in that tag and the check for harness turns only knew tags without attributes. The plugin's intentTitle and the site's (lib/coordination.ts) now leave out pasted blocks and image placeholders ([Image #1], [Image: source: …]) and read the words around them; a prompt that is only a paste gives no title, so the next one titles the session. A session already titled with a bare tag shows its first prompt's intent, or "Session on main", instead. Checked: the plugin's tests (50) and the site's coordination tests.

G1t-Session:
ses_01m4ygex20ezftekecszgw2gv5
syntaqxcommitted Parent2b5a0ffBrowse files
4 files+31−40/4 viewed
+3−0
151151
152152 test("a session is never title-less: its title, its first prompt's intent, its branch, or untitled", () => {
153153 assert.equal(sessionTitle({ title: "Rewrite the auth flow", branch: "auth", firstPrompt: "fix it" }), "Rewrite the auth flow");
154+ // A title that is only a pasted block's tag reads as none: the first prompt's words title it.
155+ assert.equal(sessionTitle({ title: '<pasted_content id="5c50">', branch: "main", firstPrompt: '<pasted_content id="5c50">\nlog\n</pasted_content>\nship the runner setup' }), "Ship the runner setup");
156+ assert.equal(sessionTitle({ title: '<pasted_content id="5c50">', branch: "main", firstPrompt: null }), "Session on main");
154157 assert.equal(sessionTitle({ title: null, branch: "auth", firstPrompt: "fix the login redirect. It loops." }), "Fix the login redirect");
155158 assert.equal(sessionTitle({ title: " ", branch: "auth", firstPrompt: "/clear" }), "Session on auth");
156159 assert.equal(sessionTitle({ title: null, branch: null }), "Untitled session");
+12−2
8888 /** The most of a prompt's intent that titles a session. */
8989 export const TITLE_LIMIT = 80;
9090
91+/** A turn the harness starts itself, as a tag: `<command-name>`, `<task-notification>`, one with attributes. */
92+const HARNESS_TAG = /^\s*<[a-z][\w-]*(?:\s[^>]*)?>/i;
93+
9194 /**
9295 * What a prompt is for, as a session's title: its first line or sentence,
9396 * without code blocks or markdown, whitespace collapsed, clipped at
97100 */
98101 export function intentTitle(prompt: string | null | undefined): string | null {
99102 let text = String(prompt ?? "").replace(/^\uFEFF/, "");
100− if (/^\s*\//.test(text) || /^\s*<[a-z][\w-]*>/i.test(text)) return null;
103+ // What the harness pasted in or attached is not what the prompt is for:
104+ // pasted text (Claude Code's <pasted_content id="…">…</pasted_content>)
105+ // and image placeholders ([Image #1], [Image: source: …]) go first.
106+ text = text
107+ .replace(/<pasted_content\b[^>]*>[\s\S]*?(?:<\/pasted_content[^>]*>|$)/gi, "\n")
108+ .replace(/\[Image(?: #\d+)?(?::[^\]\n]*)?\]/g, " ");
109+ if (/^\s*\//.test(text) || HARNESS_TAG.test(text)) return null;
101110 text = text
102111 .replace(/```[\s\S]*?(```|$)/g, "\n")
103112 .replace(/~~~[\s\S]*?(~~~|$)/g, "\n")
130139 session: Pick<WorkSession, "title" | "branch" | "firstPrompt">,
131140 firstPrompt: string | null | undefined = session.firstPrompt,
132141 ): string {
142+ // A title that is only a harness tag (an early plugin's from a pasted prompt) reads as none.
133143 const title = session.title?.trim();
134− if (title) return title;
144+ if (title && !HARNESS_TAG.test(title)) return title;
135145 const intent = intentTitle(firstPrompt);
136146 if (intent) return intent;
137147 return session.branch ? `Session on ${session.branch}` : "Untitled session";
+10−1
209209 .trim();
210210 }
211211
212+/** A turn the harness starts itself, as a tag: `<command-name>`, `<task-notification>`, one with attributes. */
213+const HARNESS_TAG = /^\s*<[a-z][\w-]*(?:\s[^>]*)?>/i;
214+
212215 /**
213216 * What a prompt is for, as a session's title: its first line or sentence,
214217 * without code blocks or markdown, whitespace collapsed, clipped at
219222 */
220223 export function intentTitle(prompt) {
221224 let text = String(prompt ?? "").replace(/^\uFEFF/, "");
222− if (/^\s*\//.test(text) || /^\s*<[a-z][\w-]*>/i.test(text)) return null;
225+ // What the harness pasted in or attached is not what the prompt is for:
226+ // pasted text (Claude Code's <pasted_content id="…">…</pasted_content>)
227+ // and image placeholders ([Image #1], [Image: source: …]) go first.
228+ text = text
229+ .replace(/<pasted_content\b[^>]*>[\s\S]*?(?:<\/pasted_content[^>]*>|$)/gi, "\n")
230+ .replace(/\[Image(?: #\d+)?(?::[^\]\n]*)?\]/g, " ");
231+ if (/^\s*\//.test(text) || HARNESS_TAG.test(text)) return null;
223232 text = text
224233 .replace(/```[\s\S]*?(```|$)/g, "\n")
225234 .replace(/~~~[\s\S]*?(~~~|$)/g, "\n")
+6−1
7979 assert.ok(long.endsWith("…") && !long.endsWith(" …"), long);
8080 assert.ok(long.startsWith("[TEST] Tidy up the README"), long);
8181 assert.ok("[TEST] Tidy up the README and then look at the CI pipeline, which keeps failing on the Windows runners".startsWith(long.slice(0, -1)));
82+ // What was pasted or attached is left out: the words typed around it title the session.
83+ assert.equal(intentTitle('<pasted_content id="5c50">\nUncaught TypeError: x is undefined\n</pasted_content>\nAlso you broke the buttons'), "Also you broke the buttons");
84+ assert.equal(intentTitle("[Image #1] the PR link is missing on Home"), "The PR link is missing on Home");
85+ assert.equal(intentTitle("[Image: source: C:\\tmp\\1.png]\nmake it render"), "Make it render");
86+ assert.equal(intentTitle('<pasted_content id="1">only a paste'), null);
8287 // Not intents: slash commands, turns Claude Code starts, nothing to say.
83− for (const prompt of ["/clear", "/compact keep the plan", "/g1t:status 4", "<command-name>/clear</command-name>", "```\ncode only\n```", "?", "", null]) {
88+ for (const prompt of ["/clear", "/compact keep the plan", "/g1t:status 4", "<command-name>/clear</command-name>", '<local-command-stdout lang="en">ok</local-command-stdout>', "```\ncode only\n```", "?", "", null]) {
8489 assert.equal(intentTitle(prompt), null, String(prompt));
8590 }
8691 });

Comments

Sign in to comment.