Skip to content

Show Session runtime state in Session server#1481

Closed
gjkim42 wants to merge 1 commit into
mainfrom
agent/show-session-runtime-state
Closed

Show Session runtime state in Session server#1481
gjkim42 wants to merge 1 commit into
mainfrom
agent/show-session-runtime-state

Conversation

@gjkim42

@gjkim42 gjkim42 commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

What type of PR is this?

/kind feature

What this PR does / why we need it:

Ready Sessions currently expose only their infrastructure phase, so users cannot tell whether an agent is actively running a turn or waiting for input.

This PR adds an authoritative runtime status query and exposes Running or Waiting for every ready Session in the Session server API. The sidebar and selected Session header render that state, while non-ready Sessions continue to show their infrastructure phase. WebSocket clients also request a fresh status snapshot when connecting so reloads and reconnects do not retain stale state.

Which issue(s) this PR is related to:

Fixes #1473

Special notes for your reviewer:

The Session list queries ready Session Pods concurrently with a bounded limit and a four-second request timeout. Unit coverage exercises running, idle, and input-waiting states; the existing Session e2e flow now verifies status while disconnected and after reconnecting. The e2e suite is intended to run in CI.

Validation:

  • env -u CODEX_HOME -u CODEX_AUTH_JSON make test
  • make verify

Does this PR introduce a user-facing change?

Show whether ready Sessions are running a turn or waiting for input in the Session server.

Summary by cubic

Show live runtime state for ready Sessions in the Session server and UI (Fixes #1473). Users can see if an agent is Running or Waiting; WebSocket clients refresh status on connect.

  • New Features
    • API returns runtimeState ("Running" | "Waiting") for ready Sessions; non-ready Sessions still expose phase.
    • Runtime adds a status client request and runtime.status event, plus kelos-session-runtime status to query the socket.
    • Session server queries Pods via exec to fetch status, with concurrent requests (limit 8) and a 4s timeout.
    • UI shows status in the session list and header with new dot styles; WS sends a status request on connect and updates on incoming events; unit and e2e tests cover running/waiting and reconnects.

Written for commit e587c1a. Summary will update on new commits.

Review in cubic

@github-actions github-actions Bot added kind/feature Categorizes issue or PR as related to a new feature needs-triage needs-priority needs-actor release-note labels Jul 14, 2026
@gjkim42
gjkim42 marked this pull request as ready for review July 14, 2026 12:10

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2 issues found across 10 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="internal/sessionserver/web/styles.css">

<violation number="1" location="internal/sessionserver/web/styles.css:45">
P3: Running session dots now pulse indefinitely even when a user requests reduced motion. Gate this new animation behind `prefers-reduced-motion: no-preference` while retaining the static running color and halo.</violation>
</file>

<file name="internal/sessionruntime/server.go">

<violation number="1" location="internal/sessionruntime/server.go:538">
P2: A reconnecting client can finish with `Running` after a turn has completed: this snapshot is not ordered with live journal events and may be delivered after `turn.completed`. Serialize status snapshots with the subscription stream, or attach a journal cursor so clients discard snapshots superseded by later events.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

case "subscribe":
subscribe(request.Since)
case "status":
out <- Event{Type: EventRuntimeStatus, RuntimeState: s.runtimeState()}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: A reconnecting client can finish with Running after a turn has completed: this snapshot is not ordered with live journal events and may be delivered after turn.completed. Serialize status snapshots with the subscription stream, or attach a journal cursor so clients discard snapshots superseded by later events.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/sessionruntime/server.go, line 538:

<comment>A reconnecting client can finish with `Running` after a turn has completed: this snapshot is not ordered with live journal events and may be delivered after `turn.completed`. Serialize status snapshots with the subscription stream, or attach a journal cursor so clients discard snapshots superseded by later events.</comment>

<file context>
@@ -516,6 +534,8 @@ func (s *Server) handleConnection(ctx context.Context, connection net.Conn) {
 		case "subscribe":
 			subscribe(request.Since)
+		case "status":
+			out <- Event{Type: EventRuntimeStatus, RuntimeState: s.runtimeState()}
 		case "message":
 			subscribe(0)
</file context>

.session-item.active { background: #fff; box-shadow: 0 4px 14px rgba(35,49,42,.06); }
.phase-dot { width: 7px; height: 7px; margin-top: 5px; border-radius: 50%; background: #9ca69f; }
.phase-dot.ready { background: #4b9a6f; box-shadow: 0 0 0 3px rgba(75,154,111,.12); }
.phase-dot.running { background: #4b9a6f; box-shadow: 0 0 0 3px rgba(75,154,111,.12); animation: pulse 1.1s infinite; }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: Running session dots now pulse indefinitely even when a user requests reduced motion. Gate this new animation behind prefers-reduced-motion: no-preference while retaining the static running color and halo.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/sessionserver/web/styles.css, line 45:

<comment>Running session dots now pulse indefinitely even when a user requests reduced motion. Gate this new animation behind `prefers-reduced-motion: no-preference` while retaining the static running color and halo.</comment>

<file context>
@@ -42,7 +42,8 @@ button { color: inherit; }
 .session-item.active { background: #fff; box-shadow: 0 4px 14px rgba(35,49,42,.06); }
 .phase-dot { width: 7px; height: 7px; margin-top: 5px; border-radius: 50%; background: #9ca69f; }
-.phase-dot.ready { background: #4b9a6f; box-shadow: 0 0 0 3px rgba(75,154,111,.12); }
+.phase-dot.running { background: #4b9a6f; box-shadow: 0 0 0 3px rgba(75,154,111,.12); animation: pulse 1.1s infinite; }
+.phase-dot.waiting { background: #7e9186; box-shadow: 0 0 0 3px rgba(126,145,134,.1); }
 .phase-dot.failed { background: #c55b5b; }
</file context>
Suggested change
.phase-dot.running { background: #4b9a6f; box-shadow: 0 0 0 3px rgba(75,154,111,.12); animation: pulse 1.1s infinite; }
.phase-dot.running { background: #4b9a6f; box-shadow: 0 0 0 3px rgba(75,154,111,.12); }
@media (prefers-reduced-motion: no-preference) { .phase-dot.running { animation: pulse 1.1s infinite; } }

@gjkim42 gjkim42 closed this Jul 18, 2026
@gjkim42
gjkim42 deleted the agent/show-session-runtime-state branch July 18, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session server: Show running and waiting status for each Session

1 participant