Drop prompt input Zod statics (#26923)

This commit is contained in:
Kit Langton
2026-05-11 16:49:08 -04:00
committed by GitHub
parent 9067218b74
commit cc95197d72
4 changed files with 16 additions and 52 deletions

View File

@@ -49,7 +49,6 @@ describe("Session.Info", () => {
time: { created: 1, updated: 2 },
}
expect(decode(input)).toEqual(input)
expect(Session.Info.zod.parse(input)).toEqual(input)
})
test("round-trips every optional field", () => {
@@ -80,7 +79,6 @@ describe("Session.Info", () => {
},
}
expect(decode(input)).toEqual(input)
expect(Session.Info.zod.parse(input)).toEqual(input)
})
test("accepts migrated summary diffs without file details", () => {
@@ -100,19 +98,16 @@ describe("Session.Info", () => {
time: { created: 1, updated: 2 },
}
expect(decode(input)).toEqual(input)
expect(Session.Info.zod.parse(input)).toEqual(input)
})
test("rejects unbranded session id", () => {
const bad = { id: "not-a-session-id" } as unknown
expect(() => decode(bad)).toThrow()
expect(() => Session.Info.zod.parse(bad)).toThrow()
})
test("rejects missing required fields", () => {
const bad = { id: sessionID } as unknown
expect(() => decode(bad)).toThrow()
expect(() => Session.Info.zod.parse(bad)).toThrow()
})
})
@@ -124,8 +119,6 @@ describe("Session.ProjectInfo", () => {
const withName = { ...noName, name: "alpha" }
expect(decode(noName)).toEqual(noName)
expect(decode(withName)).toEqual(withName)
expect(Session.ProjectInfo.zod.parse(noName)).toEqual(noName)
expect(Session.ProjectInfo.zod.parse(withName)).toEqual(withName)
})
})
@@ -144,7 +137,6 @@ describe("Session.GlobalInfo", () => {
project: null,
}
expect(decode(input)).toEqual(input)
expect(Session.GlobalInfo.zod.parse(input)).toEqual(input)
})
test("accepts populated project", () => {
@@ -159,7 +151,6 @@ describe("Session.GlobalInfo", () => {
project: { id: projectID, worktree: "/tmp/wt", name: "alpha" },
}
expect(decode(input)).toEqual(input)
expect(Session.GlobalInfo.zod.parse(input)).toEqual(input)
})
})
@@ -167,7 +158,6 @@ describe("Session input schemas", () => {
test("CreateInput accepts undefined and populated forms", () => {
const decode = decodeUnknown(Session.CreateInput)
expect(decode(undefined)).toBeUndefined()
expect(Session.CreateInput.zod.parse(undefined)).toBeUndefined()
const populated = {
parentID: sessionID,
@@ -176,23 +166,19 @@ describe("Session input schemas", () => {
workspaceID,
}
expect(decode(populated)).toEqual(populated)
expect(Session.CreateInput.zod.parse(populated)).toEqual(populated)
})
test("ForkInput round-trips", () => {
const decode = decodeUnknown(Session.ForkInput)
const input = { sessionID, messageID }
expect(decode(input)).toEqual(input)
expect(Session.ForkInput.zod.parse(input)).toEqual(input)
// messageID is optional
const bare = { sessionID }
expect(decode(bare)).toEqual(bare)
expect(Session.ForkInput.zod.parse(bare)).toEqual(bare)
})
test("SetTitleInput rejects missing title", () => {
expect(() => decodeUnknown(Session.SetTitleInput)({ sessionID })).toThrow()
expect(() => Session.SetTitleInput.zod.parse({ sessionID })).toThrow()
})
test("SetArchivedInput accepts both with and without time", () => {
@@ -282,7 +268,6 @@ describe("SessionPrompt input schemas", () => {
test("LoopInput is just sessionID", () => {
const decode = decodeUnknown(SessionPrompt.LoopInput)
expect(decode({ sessionID })).toEqual({ sessionID })
expect(SessionPrompt.LoopInput.zod.parse({ sessionID } as unknown)).toEqual({ sessionID })
})
test("ShellInput requires agent + command", () => {
@@ -290,7 +275,6 @@ describe("SessionPrompt input schemas", () => {
const expected = { sessionID, agent: "build", command: "echo hi" }
const input: unknown = expected
expect(decode(input)).toEqual(expected)
expect(SessionPrompt.ShellInput.zod.parse(input as unknown)).toEqual(expected)
expect(() => decode({ sessionID })).toThrow()
})
@@ -308,9 +292,6 @@ describe("SessionPrompt input schemas", () => {
expect(decoded.parts).toHaveLength(2)
expect(decoded.parts[0]).toMatchObject({ type: "text", text: "hello" })
expect(decoded.parts[1]).toMatchObject({ type: "file", mime: "image/png" })
const viaZod = SessionPrompt.PromptInput.zod.parse(input)
expect(viaZod.parts).toHaveLength(2)
})
test("PromptInput rejects unknown part type", () => {
@@ -320,7 +301,6 @@ describe("SessionPrompt input schemas", () => {
parts: [{ type: "nonsense", payload: 42 }],
}
expect(() => decode(bad)).toThrow()
expect(() => SessionPrompt.PromptInput.zod.parse(bad)).toThrow()
})
test("CommandInput round-trips core fields", () => {
@@ -332,6 +312,5 @@ describe("SessionPrompt input schemas", () => {
}
const input: unknown = expected
expect(decode(input)).toEqual(expected)
expect(SessionPrompt.CommandInput.zod.parse(input)).toEqual(expected)
})
})