Skip to content

Commit e6915d0

Browse files
authored
fix(cli): reject missing transcript summary paths (#128589)
1 parent 10050cb commit e6915d0

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

‎src/cli/program/register.transcripts.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,17 @@ describe("transcripts CLI", () => {
130130
session: { sessionId: "active-session" },
131131
summary: null,
132132
});
133+
expect(JSON.parse(await runTranscriptsCli(["path", "active-session", "--json"]))).toMatchObject(
134+
{
135+
exists: false,
136+
},
137+
);
133138
await expect(runTranscriptsCli(["show", "active-session"])).rejects.toThrow(
134139
"summary.md not found",
135140
);
141+
await expect(runTranscriptsCli(["path", "active-session"])).rejects.toThrow(
142+
"summary.md not found",
143+
);
136144
});
137145

138146
it("sanitizes stored summary control bytes at the show boundary", async () => {

‎src/cli/program/register.transcripts.ts‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,6 @@ function formatSessionLine(entry: TranscriptsSessionEntry): string {
5050
return `${entry.selector}\t${started}\t${title}\t${summary}`;
5151
}
5252

53-
async function requireStoredSession(selector: string): Promise<TranscriptsSessionEntry> {
54-
const session = await createStore().readSessionEntry(selector);
55-
if (!session) {
56-
throw new Error(`transcripts session not found: ${selector}`);
57-
}
58-
return session;
59-
}
60-
6153
async function listCommand(options: TranscriptsCliOptions): Promise<void> {
6254
const sessions = await createStore().listSessionEntries();
6355
if (options.json) {
@@ -132,7 +124,10 @@ function selectedArtifactKind(options: TranscriptsPathOptions): TranscriptArtifa
132124

133125
async function pathCommand(selector: string, options: TranscriptsPathOptions): Promise<void> {
134126
const store = createStore();
135-
const entry = await requireStoredSession(selector);
127+
const entry = await store.readSessionEntry(selector);
128+
if (!entry) {
129+
throw new Error(`transcripts session not found: ${selector}`);
130+
}
136131
const kind = selectedArtifactKind(options);
137132
const artifacts = await store.materializeSessionArtifacts(entry.session, kind);
138133
const selectedPath = options.dir
@@ -152,6 +147,9 @@ async function pathCommand(selector: string, options: TranscriptsPathOptions): P
152147
});
153148
return;
154149
}
150+
if (!exists) {
151+
throw new Error(`summary.md not found for transcripts session: ${selector}`);
152+
}
155153
writeLine(selectedPath);
156154
}
157155

0 commit comments

Comments
 (0)