fix(tui): gate background shortcut by capability (#32837)
This commit is contained in:
parent
62c746f2e8
commit
2892e97c57
8 changed files with 148 additions and 20 deletions
|
|
@ -25,6 +25,10 @@ const ConsoleStateResponse = Schema.Struct({
|
|||
switchableOrgCount: NonNegativeInt,
|
||||
}).annotate({ identifier: "ConsoleState" })
|
||||
|
||||
const CapabilitiesResponse = Schema.Struct({
|
||||
backgroundSubagents: Schema.Boolean,
|
||||
}).annotate({ identifier: "ExperimentalCapabilities" })
|
||||
|
||||
const ConsoleOrgOption = Schema.Struct({
|
||||
accountID: Schema.String,
|
||||
accountEmail: Schema.String,
|
||||
|
|
@ -84,6 +88,7 @@ export const SessionListQuery = Schema.Struct({
|
|||
})
|
||||
|
||||
export const ExperimentalPaths = {
|
||||
capabilities: "/experimental/capabilities",
|
||||
console: "/experimental/console",
|
||||
consoleOrgs: "/experimental/console/orgs",
|
||||
consoleSwitch: "/experimental/console/switch",
|
||||
|
|
@ -100,6 +105,16 @@ export const ExperimentalApi = HttpApi.make("experimental")
|
|||
.add(
|
||||
HttpApiGroup.make("experimental")
|
||||
.add(
|
||||
HttpApiEndpoint.get("capabilities", ExperimentalPaths.capabilities, {
|
||||
query: WorkspaceRoutingQuery,
|
||||
success: described(CapabilitiesResponse, "Experimental capabilities"),
|
||||
}).annotateMerge(
|
||||
OpenApi.annotations({
|
||||
identifier: "experimental.capabilities.get",
|
||||
summary: "Get experimental capabilities",
|
||||
description: "Get experimental features enabled on the OpenCode server.",
|
||||
}),
|
||||
),
|
||||
HttpApiEndpoint.get("console", ExperimentalPaths.console, {
|
||||
query: WorkspaceRoutingQuery,
|
||||
success: described(ConsoleStateResponse, "Active Console provider metadata"),
|
||||
|
|
|
|||
|
|
@ -36,6 +36,10 @@ export const experimentalHandlers = HttpApiBuilder.group(InstanceHttpApi, "exper
|
|||
const background = yield* BackgroundJob.Service
|
||||
const flags = yield* RuntimeFlags.Service
|
||||
|
||||
const capabilities = Effect.fn("ExperimentalHttpApi.capabilities")(function* () {
|
||||
return { backgroundSubagents: flags.experimentalBackgroundSubagents }
|
||||
})
|
||||
|
||||
const getConsole = Effect.fn("ExperimentalHttpApi.console")(function* () {
|
||||
const [state, groups] = yield* Effect.all(
|
||||
[
|
||||
|
|
@ -171,6 +175,7 @@ export const experimentalHandlers = HttpApiBuilder.group(InstanceHttpApi, "exper
|
|||
})
|
||||
|
||||
return handlers
|
||||
.handle("capabilities", capabilities)
|
||||
.handle("console", getConsole)
|
||||
.handle("consoleOrgs", listConsoleOrgs)
|
||||
.handle("consoleSwitch", switchConsole)
|
||||
|
|
|
|||
|
|
@ -578,6 +578,12 @@ const scenarios: Scenario[] = [
|
|||
.get("/experimental/session", "experimental.session.list")
|
||||
.at((ctx) => ({ path: "/experimental/session?roots=false&archived=false", headers: ctx.headers() }))
|
||||
.json(200, array),
|
||||
http.protected
|
||||
.get("/experimental/capabilities", "experimental.capabilities.get")
|
||||
.json(200, (body) => {
|
||||
check(typeof body === "object" && body !== null, "capabilities should be an object")
|
||||
check("backgroundSubagents" in body, "capabilities should report background subagents")
|
||||
}),
|
||||
http.protected
|
||||
.post("/experimental/session/{sessionID}/background", "experimental.session.background")
|
||||
.mutating()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue