Skip to content

feat(api): add single-session status HTTP endpoint#29244

Open
hemanthreddykoduru wants to merge 6 commits into
anomalyco:devfrom
hemanthreddykoduru:fix/session-status-endpoint
Open

feat(api): add single-session status HTTP endpoint#29244
hemanthreddykoduru wants to merge 6 commits into
anomalyco:devfrom
hemanthreddykoduru:fix/session-status-endpoint

Conversation

@hemanthreddykoduru
Copy link
Copy Markdown

@hemanthreddykoduru hemanthreddykoduru commented May 25, 2026

Issue for this PR

Closes #29166

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

SessionStatus.Service already had a get(sessionID) method but no dedicated HTTP endpoint. Only GET /session/status existed (returns all sessions). This adds GET /session/:sessionID/status that calls get() directly and returns 404 when the session doesn't exist.

How did you verify your code works?

Built locally and confirmed the new route registers correctly in the HTTP API group alongside the other single-session endpoints.

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Copilot AI review requested due to automatic review settings May 25, 2026 16:09
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 25, 2026
@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

I found a potential duplicate:

PR #29165: fix(opencode): expose single session status endpoint
#29165

This PR appears to be directly related to the current PR #29244. Both are about exposing/adding a single session status endpoint. PR #29165 uses the fix type while #29244 uses feat, but they're likely addressing the same functionality. You should check if #29165 is still open and whether it fully addresses the requirements, or if there's overlap that needs to be resolved.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a new API route to fetch the status for a single session by ID, complementing the existing “all sessions status” endpoint.

Changes:

  • Added GET /session/:sessionID/status endpoint definition to the session HTTP API.
  • Implemented singleStatus handler and registered it in the session handler group.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/opencode/src/server/routes/instance/httpapi/handlers/session.ts Adds and wires a singleStatus handler that fetches status for a specific session.
packages/opencode/src/server/routes/instance/httpapi/groups/session.ts Defines the new singleStatus route path and OpenAPI-described endpoint.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 78 to 85
const singleStatus = Effect.fn("SessionHttpApi.singleStatus")(function* (ctx: { params: { sessionID: SessionID } }) {
yield* requireSession(ctx.params.sessionID)
return yield* statusSvc.get(ctx.params.sessionID)
})

const requireSession = Effect.fn("SessionHttpApi.requireSession")(function* (sessionID: SessionID) {
return yield* SessionError.mapStorageNotFound(session.get(sessionID))
})
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment on lines +83 to +84
yield* requireSession(ctx.params.sessionID)
return yield* statusSvc.get(ctx.params.sessionID)
Comment on lines +129 to +140
HttpApiEndpoint.get("singleStatus", SessionPaths.singleStatus, {
params: { sessionID: SessionID },
query: WorkspaceRoutingQuery,
success: described(SessionStatus.Info, "Get single session status"),
error: [HttpApiError.BadRequest, ApiNotFoundError],
}).annotateMerge(
OpenApi.annotations({
identifier: "session.singleStatus",
summary: "Get single session status",
description: "Retrieve the current status of a specific session.",
}),
),
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

})

const getStatus = Effect.fn("SessionHttpApi.getStatus")(function* (ctx: { params: { sessionID: SessionID } }) {
yield* requireSession(ctx.params.sessionID)
export const SessionPaths = {
list: root,
status: `${root}/status`,
singleStatus: `${root}/:sessionID/status`,
Comment on lines +129 to +136
HttpApiEndpoint.get("getStatus", SessionPaths.singleStatus, {
params: { sessionID: SessionID },
query: WorkspaceRoutingQuery,
success: described(SessionStatus.Info, "Get single session status"),
error: [HttpApiError.BadRequest, ApiNotFoundError],
}).annotateMerge(
OpenApi.annotations({
identifier: "session.getStatus",
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 25, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment on lines +83 to +84
yield* requireSession(ctx.params.sessionID)
return yield* statusSvc.get(ctx.params.sessionID)
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session status service has get() method but no single-session HTTP endpoint

2 participants