Skip to content
This repository was archived by the owner on Aug 6, 2026. It is now read-only.

Commit 0c50d64

Browse files
authored
fix(canvas): align startup and artifact source contracts
Generated-By: PostHog Code Task-Id: 45da9f78-5b15-4cfe-a8a5-9afcbd6b4755
1 parent ab1d0fe commit 0c50d64

4 files changed

Lines changed: 26 additions & 16 deletions

File tree

packages/api-client/src/task-normalization.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ function normalizeTaskRunArtifact(
109109
...(artifact.id === undefined ? {} : { id: artifact.id }),
110110
name: artifact.name,
111111
type: normalizeArtifactType(artifact.type),
112-
...(artifact.source === undefined ? {} : { source: artifact.source }),
112+
...(artifact.source === "agent_output" ||
113+
artifact.source === "user_attachment" ||
114+
artifact.source === "posthog_code_skill"
115+
? { source: artifact.source }
116+
: {}),
113117
...(artifact.size === undefined ? {} : { size: artifact.size }),
114118
...(artifact.content_type === undefined
115119
? {}

packages/shared/src/domain-types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,8 @@ export interface PriorityJudgmentContent {
597597
}
598598

599599
/** Artefact with `type: "actionability_judgment"` — actionability assessment from the agentic report. */
600-
export interface ActionabilityJudgmentArtefact extends SignalReportArtefactBase {
600+
export interface ActionabilityJudgmentArtefact
601+
extends SignalReportArtefactBase {
601602
type: "actionability_judgment";
602603
content: ActionabilityJudgmentContent;
603604
}

packages/ui/src/shell/startupLocation.test.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,31 @@ describe("startup location", () => {
88
it("restores the exact last location", async () => {
99
vi.spyOn(stateStorage, "getItem").mockResolvedValue("/code");
1010
const client = {
11-
getDesktopFileSystemChannels: vi.fn(),
12-
createDesktopFileSystemChannel: vi.fn(),
11+
getTaskChannels: vi.fn(),
1312
};
1413

1514
await expect(resolveStartupLocation("project", client)).resolves.toBe(
1615
"/code",
1716
);
18-
expect(client.getDesktopFileSystemChannels).not.toHaveBeenCalled();
17+
expect(client.getTaskChannels).not.toHaveBeenCalled();
1918
});
2019

2120
it("opens a new task in me when there is no saved location", async () => {
2221
vi.spyOn(stateStorage, "getItem").mockResolvedValue(null);
2322
const client = {
24-
getDesktopFileSystemChannels: vi
25-
.fn()
26-
.mockResolvedValue([{ id: "me-id", path: "me", type: "folder" }]),
27-
createDesktopFileSystemChannel: vi.fn(),
23+
getTaskChannels: vi.fn().mockResolvedValue([
24+
{
25+
id: "me-id",
26+
name: "me",
27+
channel_type: "personal",
28+
starred: false,
29+
},
30+
]),
2831
};
2932

3033
await expect(resolveStartupLocation("project", client)).resolves.toBe(
3134
"/website/me-id/new",
3235
);
33-
expect(client.createDesktopFileSystemChannel).not.toHaveBeenCalled();
36+
expect(client.getTaskChannels).toHaveBeenCalledOnce();
3437
});
3538
});

packages/ui/src/shell/startupLocation.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
import {
2-
ensurePersonalChannelFromClient,
3-
type PersonalChannelClient,
4-
} from "@posthog/ui/features/canvas/ensurePersonalChannel";
1+
import type { PostHogAPIClient } from "@posthog/api-client/posthog-client";
52
import { stateStorage } from "@posthog/ui/shell/rendererStorage";
63

4+
type StartupLocationClient = Pick<PostHogAPIClient, "getTaskChannels">;
5+
76
const storageKey = (identity: string): string => `startup-location:${identity}`;
87

98
export async function resolveStartupLocation(
109
identity: string,
11-
client: PersonalChannelClient,
10+
client: StartupLocationClient,
1211
): Promise<string> {
1312
const saved = await stateStorage.getItem(storageKey(identity));
1413
if (saved) return saved;
15-
const personal = await ensurePersonalChannelFromClient(client);
14+
const personal = (await client.getTaskChannels()).find(
15+
(channel) => channel.channel_type === "personal",
16+
);
17+
if (!personal) throw new Error("Personal channel was not provisioned");
1618
return `/website/${personal.id}/new`;
1719
}
1820

0 commit comments

Comments
 (0)