feat: replace launcher panel with direct tab creation, use directory-based workspace IDs, and add backward-compatible schema fields
This commit is contained in:
@@ -38,8 +38,8 @@ describe("shared messages stream parsing", () => {
|
||||
expect(parsed.payload.entries[0]?.item.type).toBe("assistant_message");
|
||||
});
|
||||
|
||||
it("rejects removed fetch timeline request baggage at the parser boundary", () => {
|
||||
const parsed = FetchAgentTimelineRequestMessageSchema.safeParse({
|
||||
it("parses legacy fetch timeline request baggage at the parser boundary", () => {
|
||||
const parsed = FetchAgentTimelineRequestMessageSchema.parse({
|
||||
type: "fetch_agent_timeline_request",
|
||||
agentId: "agent_live",
|
||||
requestId: "req-legacy",
|
||||
@@ -51,36 +51,41 @@ describe("shared messages stream parsing", () => {
|
||||
projection: "canonical",
|
||||
});
|
||||
|
||||
expect(parsed.success).toBe(false);
|
||||
expect(parsed.cursor?.epoch).toBe("legacy-epoch");
|
||||
expect(parsed.projection).toBe("canonical");
|
||||
});
|
||||
|
||||
it("rejects removed fetch timeline response baggage at the parser boundary", () => {
|
||||
const parsed = FetchAgentTimelineResponseMessageSchema.safeParse({
|
||||
it("parses legacy fetch timeline response baggage at the parser boundary", () => {
|
||||
const parsed = FetchAgentTimelineResponseMessageSchema.parse({
|
||||
type: "fetch_agent_timeline_response",
|
||||
payload: {
|
||||
requestId: "req-1",
|
||||
agentId: "agent_live",
|
||||
agent: null,
|
||||
direction: "tail",
|
||||
startSeq: 1,
|
||||
endSeq: 2,
|
||||
hasOlder: false,
|
||||
hasNewer: false,
|
||||
reset: false,
|
||||
startCursor: { seq: 1 },
|
||||
startCursor: { seq: 1, epoch: "legacy-epoch" },
|
||||
endCursor: { seq: 2, epoch: "legacy-epoch" },
|
||||
projection: "canonical",
|
||||
entries: [
|
||||
{
|
||||
provider: "codex",
|
||||
item: { type: "assistant_message", text: "hello" },
|
||||
timestamp: "2026-02-08T20:10:00.000Z",
|
||||
seq: 2,
|
||||
seqStart: 1,
|
||||
seqEnd: 2,
|
||||
sourceSeqRanges: [{ startSeq: 1, endSeq: 2 }],
|
||||
collapsed: ["assistant_merge"],
|
||||
},
|
||||
],
|
||||
error: null,
|
||||
},
|
||||
});
|
||||
|
||||
expect(parsed.success).toBe(false);
|
||||
expect(parsed.payload.startSeq).toBe(1);
|
||||
expect(parsed.payload.endSeq).toBe(2);
|
||||
expect(parsed.payload.projection).toBe("canonical");
|
||||
expect(parsed.payload.entries[0]?.seq).toBe(2);
|
||||
});
|
||||
|
||||
it("parses explicit shutdown and restart lifecycle request payloads as distinct message types", () => {
|
||||
@@ -135,8 +140,8 @@ describe("shared messages stream parsing", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("rejects removed agent_stream baggage at the parser boundary", () => {
|
||||
const parsed = AgentStreamMessageSchema.safeParse({
|
||||
it("parses legacy agent_stream baggage at the parser boundary", () => {
|
||||
const parsed = AgentStreamMessageSchema.parse({
|
||||
type: "agent_stream",
|
||||
payload: {
|
||||
agentId: "agent_live",
|
||||
@@ -153,7 +158,7 @@ describe("shared messages stream parsing", () => {
|
||||
},
|
||||
});
|
||||
|
||||
expect(parsed.success).toBe(false);
|
||||
expect(parsed.payload.epoch).toBe("legacy-epoch");
|
||||
});
|
||||
|
||||
it("parses representative sub_agent tool_call event", () => {
|
||||
|
||||
@@ -844,8 +844,10 @@ export const ShutdownServerRequestMessageSchema = z.object({
|
||||
export const AgentTimelineCursorSchema = z
|
||||
.object({
|
||||
seq: z.number().int().nonnegative(),
|
||||
// COMPAT(timeline): retain legacy cursor epoch for older clients.
|
||||
epoch: z.string().optional(),
|
||||
})
|
||||
.strict();
|
||||
;
|
||||
|
||||
export const FetchAgentTimelineRequestMessageSchema = z
|
||||
.object({
|
||||
@@ -856,8 +858,10 @@ export const FetchAgentTimelineRequestMessageSchema = z
|
||||
cursor: AgentTimelineCursorSchema.optional(),
|
||||
// 0 means "all matching rows for this query window".
|
||||
limit: z.number().int().nonnegative().optional(),
|
||||
// COMPAT(timeline): retain removed projection so older clients can still send it.
|
||||
projection: z.enum(["canonical", "projected"]).optional(),
|
||||
})
|
||||
.strict();
|
||||
;
|
||||
|
||||
export const SetAgentModeRequestMessageSchema = z.object({
|
||||
type: z.literal("set_agent_mode_request"),
|
||||
@@ -1739,7 +1743,8 @@ export const WorkspaceDescriptorPayloadSchema = z.object({
|
||||
projectRootPath: z.string(),
|
||||
workspaceDirectory: z.string(),
|
||||
projectKind: z.enum(["git", "non_git", "directory"]),
|
||||
workspaceKind: z.enum(["local_checkout", "checkout", "worktree"]),
|
||||
// COMPAT(workspaces): keep legacy directory workspace kind parseable.
|
||||
workspaceKind: z.enum(["directory", "local_checkout", "checkout", "worktree"]),
|
||||
name: z.string(),
|
||||
status: WorkspaceStateBucketSchema,
|
||||
activityAt: z.string().nullable(),
|
||||
@@ -1771,17 +1776,17 @@ export const AgentUpdateMessageSchema = z.object({
|
||||
export const AgentStreamMessageSchema = z
|
||||
.object({
|
||||
type: z.literal("agent_stream"),
|
||||
payload: z
|
||||
.object({
|
||||
agentId: z.string(),
|
||||
event: AgentStreamEventPayloadSchema,
|
||||
timestamp: z.string(),
|
||||
// Present only for committed timeline events.
|
||||
seq: z.number().int().nonnegative().optional(),
|
||||
})
|
||||
.strict(),
|
||||
payload: z.object({
|
||||
agentId: z.string(),
|
||||
event: AgentStreamEventPayloadSchema,
|
||||
timestamp: z.string(),
|
||||
// Present only for committed timeline events.
|
||||
seq: z.number().int().nonnegative().optional(),
|
||||
// COMPAT(timeline): retain removed epoch for older clients.
|
||||
epoch: z.string().optional(),
|
||||
}),
|
||||
})
|
||||
.strict();
|
||||
;
|
||||
|
||||
export const AgentStatusMessageSchema = z.object({
|
||||
type: z.literal("agent_status"),
|
||||
@@ -1908,14 +1913,40 @@ export const FetchAgentResponseMessageSchema = z.object({
|
||||
}),
|
||||
});
|
||||
|
||||
const TimelineProjectionKindSchema = z.enum(["assistant_merge", "tool_lifecycle"]);
|
||||
|
||||
const TimelineSeqRangeSchema = z.object({
|
||||
startSeq: z.number().int().nonnegative(),
|
||||
endSeq: z.number().int().nonnegative(),
|
||||
});
|
||||
|
||||
export const AgentTimelineEntryPayloadSchema = z
|
||||
.object({
|
||||
provider: AgentProviderSchema,
|
||||
item: AgentTimelineItemPayloadSchema,
|
||||
timestamp: z.string(),
|
||||
seq: z.number().int().nonnegative(),
|
||||
seq: z.number().int().nonnegative().optional(),
|
||||
// COMPAT(timeline): retain legacy projected timeline fields.
|
||||
seqStart: z.number().int().nonnegative().optional(),
|
||||
seqEnd: z.number().int().nonnegative().optional(),
|
||||
sourceSeqRanges: z.array(TimelineSeqRangeSchema).optional(),
|
||||
collapsed: z.array(TimelineProjectionKindSchema).optional(),
|
||||
})
|
||||
.strict();
|
||||
.transform((entry, ctx) => {
|
||||
const seq = entry.seq ?? entry.seqEnd ?? entry.seqStart;
|
||||
if (typeof seq !== "number") {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: "Agent timeline entry must include seq or legacy seqStart/seqEnd",
|
||||
});
|
||||
return z.NEVER;
|
||||
}
|
||||
|
||||
return {
|
||||
...entry,
|
||||
seq,
|
||||
};
|
||||
});
|
||||
|
||||
export const FetchAgentTimelineResponseMessageSchema = z
|
||||
.object({
|
||||
@@ -1926,16 +1957,31 @@ export const FetchAgentTimelineResponseMessageSchema = z
|
||||
agentId: z.string(),
|
||||
agent: AgentSnapshotPayloadSchema.nullable(),
|
||||
direction: z.enum(["tail", "before", "after"]),
|
||||
startSeq: z.number().int().nonnegative().nullable(),
|
||||
endSeq: z.number().int().nonnegative().nullable(),
|
||||
hasOlder: z.boolean(),
|
||||
hasNewer: z.boolean(),
|
||||
startSeq: z.number().int().nonnegative().nullable().optional(),
|
||||
endSeq: z.number().int().nonnegative().nullable().optional(),
|
||||
hasOlder: z.boolean().optional(),
|
||||
hasNewer: z.boolean().optional(),
|
||||
entries: z.array(AgentTimelineEntryPayloadSchema),
|
||||
error: z.string().nullable(),
|
||||
// COMPAT(timeline): retain legacy response baggage for older clients.
|
||||
epoch: z.string().optional(),
|
||||
reset: z.boolean().optional(),
|
||||
staleCursor: z.boolean().optional(),
|
||||
gap: z.unknown().optional(),
|
||||
window: z.unknown().optional(),
|
||||
startCursor: AgentTimelineCursorSchema.nullable().optional(),
|
||||
endCursor: AgentTimelineCursorSchema.nullable().optional(),
|
||||
projection: z.enum(["canonical", "projected"]).optional(),
|
||||
})
|
||||
.strict(),
|
||||
.transform((payload) => ({
|
||||
...payload,
|
||||
startSeq: payload.startSeq ?? payload.startCursor?.seq ?? null,
|
||||
endSeq: payload.endSeq ?? payload.endCursor?.seq ?? null,
|
||||
hasOlder: payload.hasOlder ?? false,
|
||||
hasNewer: payload.hasNewer ?? false,
|
||||
})),
|
||||
})
|
||||
.strict();
|
||||
;
|
||||
|
||||
export const SendAgentMessageResponseMessageSchema = z.object({
|
||||
type: z.literal("send_agent_message_response"),
|
||||
|
||||
@@ -96,6 +96,35 @@ describe("workspace message schemas", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
test("parses legacy workspace descriptor enum values", () => {
|
||||
const parsed = SessionOutboundMessageSchema.parse({
|
||||
type: "workspace_update",
|
||||
payload: {
|
||||
kind: "upsert",
|
||||
workspace: {
|
||||
id: "legacy-workspace",
|
||||
projectId: "legacy-project",
|
||||
projectDisplayName: "repo",
|
||||
projectRootPath: "/repo",
|
||||
workspaceDirectory: "/repo",
|
||||
projectKind: "non_git",
|
||||
workspaceKind: "directory",
|
||||
name: "repo",
|
||||
status: "done",
|
||||
activityAt: null,
|
||||
services: [],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(parsed.type).toBe("workspace_update");
|
||||
if (parsed.type !== "workspace_update" || parsed.payload.kind !== "upsert") {
|
||||
throw new Error("Expected workspace_update upsert payload");
|
||||
}
|
||||
expect(parsed.payload.workspace.projectKind).toBe("non_git");
|
||||
expect(parsed.payload.workspace.workspaceKind).toBe("directory");
|
||||
});
|
||||
|
||||
test("parses service_status_update payload", () => {
|
||||
const parsed = SessionOutboundMessageSchema.parse({
|
||||
type: "service_status_update",
|
||||
|
||||
Reference in New Issue
Block a user