Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 33 additions & 1 deletion packages/opencode/src/server/routes/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const SessionRoutes = lazy(() =>
validator(
"param",
z.object({
sessionID: Session.get.schema,
sessionID: SessionID.zod,
}),
),
async (c) => {
Expand Down Expand Up @@ -185,6 +185,38 @@ export const SessionRoutes = lazy(() =>
return c.json(todos)
},
)
.post(
"/:sessionID/todo",
describeRoute({
summary: "Update session todos",
description: "Update the todo list for a specific session. This triggers a todo.updated event that refreshes the TUI sidebar.",
operationId: "session.todoUpdate",
responses: {
200: {
description: "Todos updated successfully",
content: {
"application/json": {
schema: resolver(Todo.Info.array()),
},
},
},
...errors(400, 404),
},
}),
validator(
"param",
z.object({
sessionID: SessionID.zod,
}),
),
validator("json", z.object({ todos: z.array(Todo.Info) })),
async (c) => {
const sessionID = c.req.valid("param").sessionID
const { todos } = c.req.valid("json")
await Todo.update({ sessionID, todos })
return c.json(todos)
},
)
.post(
"/",
describeRoute({
Expand Down
42 changes: 42 additions & 0 deletions packages/sdk/js/src/v2/gen/sdk.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ import type {
SessionSummarizeResponses,
SessionTodoErrors,
SessionTodoResponses,
SessionTodoUpdateErrors,
SessionTodoUpdateResponses,
SessionUnrevertErrors,
SessionUnrevertResponses,
SessionUnshareErrors,
Expand All @@ -151,6 +153,7 @@ import type {
SessionUpdateResponses,
SubtaskPartInput,
TextPartInput,
Todo,
ToolIdsErrors,
ToolIdsResponses,
ToolListErrors,
Expand Down Expand Up @@ -1527,6 +1530,45 @@ export class Session2 extends HeyApiClient {
})
}

/**
* Update session todos
*
* Update the todo list for a specific session. This triggers a todo.updated event that refreshes the TUI sidebar.
*/
public todoUpdate<ThrowOnError extends boolean = false>(
parameters: {
sessionID: string
directory?: string
workspace?: string
todos?: Array<Todo>
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "path", key: "sessionID" },
{ in: "query", key: "directory" },
{ in: "query", key: "workspace" },
{ in: "body", key: "todos" },
],
},
],
)
return (options?.client ?? this.client).post<SessionTodoUpdateResponses, SessionTodoUpdateErrors, ThrowOnError>({
url: "/session/{sessionID}/todo",
...options,
...params,
headers: {
"Content-Type": "application/json",
...options?.headers,
...params.headers,
},
})
}

/**
* Initialize session
*
Expand Down
36 changes: 36 additions & 0 deletions packages/sdk/js/src/v2/gen/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3032,6 +3032,42 @@ export type SessionTodoResponses = {

export type SessionTodoResponse = SessionTodoResponses[keyof SessionTodoResponses]

export type SessionTodoUpdateData = {
body?: {
todos: Array<Todo>
}
path: {
sessionID: string
}
query?: {
directory?: string
workspace?: string
}
url: "/session/{sessionID}/todo"
}

export type SessionTodoUpdateErrors = {
/**
* Bad request
*/
400: BadRequestError
/**
* Not found
*/
404: NotFoundError
}

export type SessionTodoUpdateError = SessionTodoUpdateErrors[keyof SessionTodoUpdateErrors]

export type SessionTodoUpdateResponses = {
/**
* Todos updated successfully
*/
200: Array<Todo>
}

export type SessionTodoUpdateResponse = SessionTodoUpdateResponses[keyof SessionTodoUpdateResponses]

export type SessionInitData = {
body?: {
modelID: string
Expand Down
Loading