Skip to content

Commit bc0930a

Browse files
committed
Handle hyphenated project prefix stripping
1 parent 173e32d commit bc0930a

File tree

7 files changed

+17
-6
lines changed

7 files changed

+17
-6
lines changed

src/components/__tests__/terminal-panel-id.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ describe("splitTerminalTabBeatId", () => {
77
prefix: "foolery",
88
localId: "da96",
99
});
10+
expect(splitTerminalTabBeatId("feature-builder-da96")).toEqual({
11+
prefix: "feature-builder",
12+
localId: "da96",
13+
});
1014
});
1115

1216
it("returns the raw id as localId when no valid prefix is present", () => {

src/components/agent-history-utils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export function workflowStateBadgeLabel(
129129
export function stripIdPrefix(
130130
id: string,
131131
): string {
132-
const idx = id.indexOf("-");
132+
const idx = id.lastIndexOf("-");
133133
return idx > 0 ? id.slice(idx + 1) : id;
134134
}
135135

src/lib/__tests__/beat-display.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ describe("beat-display", () => {
1515
expect(displayBeatLabel("foolery-df3a")).toBe("df3a");
1616
expect(displayBeatLabel("foolery-df3a", [])).toBe("df3a");
1717
expect(stripBeatPrefix("foolery-df3a")).toBe("df3a");
18+
expect(displayBeatLabel("feature-builder-df3a")).toBe("df3a");
19+
expect(stripBeatPrefix("feature-builder-df3a")).toBe("df3a");
1820
});
1921

2022
it("strips project prefixes from hierarchical aliases", () => {
2123
expect(displayBeatLabel("knots-562b.1", ["knots-562b.1"])).toBe("562b.1");
2224
expect(stripHierarchicalPrefix("proj-a.b.c")).toBe("a.b.c");
25+
expect(stripHierarchicalPrefix("feature-builder-a.b.c")).toBe("a.b.c");
2326
});
2427

2528
it("keeps human-friendly aliases unchanged", () => {

src/lib/__tests__/beat-navigation.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ describe("stripBeatPrefix", () => {
1212
expect(stripBeatPrefix("foolery-xmvb")).toBe("xmvb");
1313
});
1414

15+
it("uses the last hyphen for multi-hyphen project names", () => {
16+
expect(stripBeatPrefix("feature-builder-abc")).toBe("abc");
17+
});
18+
1519
it("returns original value when no hyphen exists", () => {
1620
expect(stripBeatPrefix("xmvb")).toBe("xmvb");
1721
});

src/lib/beat-display.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export function stripBeatPrefix(beatId: string): string {
2-
return beatId.replace(/^[^-]+-/, "");
2+
const pivot = beatId.lastIndexOf("-");
3+
return pivot > 0 ? beatId.slice(pivot + 1) : beatId;
34
}
45

56
export function stripHierarchicalPrefix(alias: string): string {

src/lib/beat-navigation.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
const BEAT_PREFIX_PATTERN = /^[^-]+-/;
2-
31
/** Render beat IDs without repo prefix (e.g. "foolery-xmvb" -> "xmvb"). */
42
export function stripBeatPrefix(beatId: string): string {
5-
return beatId.replace(BEAT_PREFIX_PATTERN, "");
3+
const pivot = beatId.lastIndexOf("-");
4+
return pivot > 0 ? beatId.slice(pivot + 1) : beatId;
65
}
76

87
/** Extract the repo-name prefix from a beat ID (e.g. "my-project-xmvb" -> "my-project"). */

src/lib/terminal-tab-id.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export interface TerminalTabBeatIdParts {
44
}
55

66
export function splitTerminalTabBeatId(id: string): TerminalTabBeatIdParts {
7-
const separatorIndex = id.indexOf("-");
7+
const separatorIndex = id.lastIndexOf("-");
88
if (separatorIndex <= 0 || separatorIndex >= id.length - 1) {
99
return { prefix: null, localId: id };
1010
}

0 commit comments

Comments
 (0)