The best way to control Claude Code, Codex and more from any computer or phone
fix(shared): thread search ignores the t3 prefix of flat temporary branches (#35430)
Julius Marminge committed
Nov 12, 2026 at 09:50 UTC
55081a1f7bcfed8a5ace034f03e6f39017b71979
2 files changed
+22
-3
packages/shared/src/paletteSearch.test.ts
+8
@@ -333,6 +333,14 @@ describe("scoreThreadSearch beyond Latin text and titles", () => {
333
ranges: [{ start: 0, end: 7 }],
334
});
335
expect(scoreThreadSearch("trim", subject, NOW)?.explain?.()).toBeUndefined();
336
+ // Nor is it in the flat t3-<hex> form used when a `t3` branch blocks nested refs.
337
+ const flat = thread("Add search", { branch: "t3-abcd1234" });
338
+ expect(scoreThreadSearch("t3", flat, NOW)).toBeNull();
339
+ expect(scoreThreadSearch("t3 connect", flat, NOW)).toBeNull();
340
+ expect(scoreThreadSearch("abcd1234", flat, NOW)).not.toBeNull();
341
+ for (const query of ["t3-abcd", "t3-abcd1234 connect", "connect t3-abcd1234"]) {
342
+ expect(scoreThreadSearch(query, { ...flat, projectTitle: "connect" }, NOW)).not.toBeNull();
343
+ }
344
});
345
346
it("reads letters and numbers typed together, without forgiving typos in numbers", () => {
packages/shared/src/paletteSearch.ts
+14
-3
@@ -923,9 +923,19 @@ export interface SearchMatchHint {
923
}
924
925
// Most threads' branches start with the app's own worktree prefix ("t3/", and
926
-// "t3code/" before it), so "t3 connect" would match nearly every thread.
926
+// "t3code/" before it, "t3-<hex>" when a "t3" branch blocks nested refs), so
927
+// "t3 connect" would match nearly every thread.
928
// Only before more text, so typing "t3/" does not empty the list for a keystroke.
928
-const WORKTREE_BRANCH_PREFIX_PATTERN = new RegExp(`^(?:${WORKTREE_BRANCH_PREFIX}|t3code)/(?=\\S)`);
929
+const WORKTREE_BRANCH_PREFIX_PATTERN = new RegExp(
930
+ `^(?:(?:${WORKTREE_BRANCH_PREFIX}|t3code)/(?=\\S)|${WORKTREE_BRANCH_PREFIX}-(?=[0-9a-f]{8}$))`,
931
+);
932
+
933
+// The flat prefix anywhere in a query, while its hex is still being typed, so
934
+// "t3-abcd" and "connect t3-abcd1234" still reach the stripped branch field.
935
+const FLAT_BRANCH_QUERY_PREFIX_PATTERN = new RegExp(
936
+ `(^| )${WORKTREE_BRANCH_PREFIX}-(?=[0-9a-f]{1,8}(?: |$))`,
937
+ "g",
938
+);
939
940
function searchableBranch(branch: string | null | undefined): string | null {
941
return branch ? branch.replace(WORKTREE_BRANCH_PREFIX_PATTERN, "") : null;
@@ -1005,7 +1015,8 @@ function threadFieldQuery(normalizedQuery: string): string {
1015
fieldQuery: normalizedQuery
1016
.replace(/^(?:pr|pull request|pull)\s*(?=#?\d)/, "")
1017
.replace(/^#\s*/, "")
1008
- .replace(WORKTREE_BRANCH_PREFIX_PATTERN, ""),
1018
+ .replace(WORKTREE_BRANCH_PREFIX_PATTERN, "")
1019
+ .replace(FLAT_BRANCH_QUERY_PREFIX_PATTERN, "$1"),
1020
};
1021
}
1022
return lastFieldQuery.fieldQuery;