Skip to content

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

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

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

Conversation

@hemanthreddykoduru

@hemanthreddykoduru hemanthreddykoduru commented May 25, 2026 •

Copy link
Copy Markdown

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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))
})

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.",
}),
),

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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. 👍

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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

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