fix(session): accept routing params in message list (#26569)
Co-authored-by: Developer <temp@example.com>
This commit is contained in:
@@ -25,8 +25,12 @@ const QueryBoolean = Schema.Literals(["true", "false"]).pipe(
|
|||||||
encode: SchemaGetter.transform((value) => (value ? "true" : "false")),
|
encode: SchemaGetter.transform((value) => (value ? "true" : "false")),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
export const ListQuery = Schema.Struct({
|
const WorkspaceRoutingQuery = {
|
||||||
directory: Schema.optional(Schema.String),
|
directory: Schema.optional(Schema.String),
|
||||||
|
workspace: Schema.optional(Schema.String),
|
||||||
|
}
|
||||||
|
export const ListQuery = Schema.Struct({
|
||||||
|
...WorkspaceRoutingQuery,
|
||||||
scope: Schema.optional(Schema.Literals(["project"])),
|
scope: Schema.optional(Schema.Literals(["project"])),
|
||||||
path: Schema.optional(Schema.String),
|
path: Schema.optional(Schema.String),
|
||||||
roots: Schema.optional(QueryBoolean),
|
roots: Schema.optional(QueryBoolean),
|
||||||
@@ -36,6 +40,7 @@ export const ListQuery = Schema.Struct({
|
|||||||
})
|
})
|
||||||
export const DiffQuery = Schema.Struct(Struct.omit(SessionSummary.DiffInput.fields, ["sessionID"]))
|
export const DiffQuery = Schema.Struct(Struct.omit(SessionSummary.DiffInput.fields, ["sessionID"]))
|
||||||
export const MessagesQuery = Schema.Struct({
|
export const MessagesQuery = Schema.Struct({
|
||||||
|
...WorkspaceRoutingQuery,
|
||||||
limit: Schema.optional(Schema.NumberFromString.check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(0))),
|
limit: Schema.optional(Schema.NumberFromString.check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(0))),
|
||||||
before: Schema.optional(Schema.String),
|
before: Schema.optional(Schema.String),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { afterEach, describe, expect, test } from "bun:test"
|
import { afterEach, describe, expect, test } from "bun:test"
|
||||||
import { Effect } from "effect"
|
import { Effect } from "effect"
|
||||||
import { Instance } from "../../src/project/instance"
|
|
||||||
import { WithInstance } from "../../src/project/with-instance"
|
import { WithInstance } from "../../src/project/with-instance"
|
||||||
import { Server } from "../../src/server/server"
|
import { Server } from "../../src/server/server"
|
||||||
import { Session as SessionNs } from "@/session/session"
|
import { Session as SessionNs } from "@/session/session"
|
||||||
@@ -165,4 +164,28 @@ describe("session messages endpoint", () => {
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("accepts directory query used by workspace routing", async () => {
|
||||||
|
await using tmp = await tmpdir({ git: true })
|
||||||
|
await withoutWatcher(() =>
|
||||||
|
WithInstance.provide({
|
||||||
|
directory: tmp.path,
|
||||||
|
fn: async () => {
|
||||||
|
const session = await svc.create({})
|
||||||
|
await fill(session.id, 1)
|
||||||
|
const app = Server.Default().app
|
||||||
|
|
||||||
|
const res = await app.request(
|
||||||
|
`/session/${session.id}/message?limit=80&directory=${encodeURIComponent(tmp.path)}`,
|
||||||
|
)
|
||||||
|
expect(res.status).toBe(200)
|
||||||
|
const body = await res.json()
|
||||||
|
expect(Array.isArray(body)).toBe(true)
|
||||||
|
expect(body).toHaveLength(1)
|
||||||
|
|
||||||
|
await svc.remove(session.id)
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user