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
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const PermissionResponsePayload = Schema.Struct({
export const SessionPaths = {
list: root,
status: `${root}/status`,
getStatus: `${root}/:sessionID/status`,
get: `${root}/:sessionID`,
children: `${root}/:sessionID/children`,
todo: `${root}/:sessionID/todo`,
Expand Down Expand Up @@ -125,6 +126,18 @@ export const SessionApi = HttpApi.make("session")
description: "Retrieve the current status of all sessions, including active, idle, and completed states.",
}),
),
HttpApiEndpoint.get("getStatus", SessionPaths.getStatus, {
params: { sessionID: SessionID },
query: WorkspaceRoutingQuery,
success: described(SessionStatus.Info, "Get single session status"),
error: [HttpApiError.BadRequest, ApiNotFoundError],
}).annotateMerge(
OpenApi.annotations({
identifier: "session.getStatus",
summary: "Get single session status",
description: "Retrieve the current status of a specific session.",
}),
),
HttpApiEndpoint.get("get", SessionPaths.get, {
params: { sessionID: SessionID },
query: WorkspaceRoutingQuery,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ export const sessionHandlers = HttpApiBuilder.group(InstanceHttpApi, "session",
return yield* SessionError.mapStorageNotFound(session.get(sessionID))
})

const getStatus = Effect.fn("SessionHttpApi.getStatus")(function* (ctx: { params: { sessionID: SessionID } }) {
yield* requireSession(ctx.params.sessionID)
return yield* statusSvc.get(ctx.params.sessionID)
Comment on lines +83 to +84
Comment on lines +83 to +84
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping requireSession intentionally. statusSvc.get() reads from an in-memory Map (via InstanceState.get) and always returns { type: "idle" } for any unknown sessionID — it never fails. Removing requireSession would cause this endpoint to return 200 idle for completely non-existent sessions instead of a proper 404. The two calls serve different purposes: requireSession validates session existence against storage, statusSvc.get reads runtime status from memory.

})

const get = Effect.fn("SessionHttpApi.get")(function* (ctx: { params: { sessionID: SessionID } }) {
return yield* requireSession(ctx.params.sessionID)
})
Expand Down Expand Up @@ -406,6 +411,7 @@ export const sessionHandlers = HttpApiBuilder.group(InstanceHttpApi, "session",
return handlers
.handle("list", list)
.handle("status", status)
.handle("getStatus", getStatus)
.handle("get", get)
.handle("children", children)
.handle("todo", todo)
Expand Down
Loading