Skip to content

Commit d655541

Browse files
jom-sqampcode-com
andcommitted
fix: make AmpThreadSummary env/relationships optional for API resilience
Co-authored-by: Amp <amp@ampcode.com>
1 parent 4d7f765 commit d655541

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

server/lib/amp-api.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,12 @@ export interface AmpThreadSummary {
150150
archived: boolean;
151151
creatorUserID: string;
152152
usesDtw: boolean;
153-
env: {
154-
initial: {
155-
trees: AmpThreadTree[];
153+
env?: {
154+
initial?: {
155+
trees?: AmpThreadTree[];
156156
};
157157
};
158-
relationships: Array<{
158+
relationships?: Array<{
159159
type: string;
160160
role: 'parent' | 'child';
161161
threadID: string;

server/lib/threadProvider.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,13 @@ export async function listAllThreads(): Promise<Thread[]> {
4949
}
5050

5151
function toThread(s: AmpThreadSummary): Thread {
52-
const trees = s.env.initial.trees;
53-
const tree = trees[0];
52+
const tree = s.env?.initial?.trees?.[0];
5453
const repoUrl = tree?.repository?.url;
5554

5655
// Extract handoff relationships
5756
let handoffParentId: string | null = null;
5857
const handoffChildIds: string[] = [];
59-
for (const rel of s.relationships) {
58+
for (const rel of s.relationships ?? []) {
6059
if (rel.type === 'handoff') {
6160
if (rel.role === 'child') {
6261
handoffParentId = rel.threadID;

0 commit comments

Comments
 (0)