-
Notifications
You must be signed in to change notification settings - Fork 240
feat(cli): show live session status in the /session picker #3441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
1625567290
wants to merge
1
commit into
apache:main
Choose a base branch
from
1625567290:codex/issue-3384-session-status
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+230
−7
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import assert from 'node:assert/strict'; | ||
| import { describe, test } from 'node:test'; | ||
| import type { SessionSummary } from '@maka/core/session'; | ||
| import { sessionStatusBadge } from '../tui-session-status.js'; | ||
|
|
||
| describe('TUI Session status badge', () => { | ||
| test('only marks running when the Runtime Host reports a live Turn', () => { | ||
| assert.equal(sessionStatusBadge(session({ status: 'running' }), 'en'), undefined); | ||
| assert.equal( | ||
| sessionStatusBadge(session({ status: 'running', runningTurnIds: [] }), 'en'), | ||
| undefined, | ||
| ); | ||
| assert.equal( | ||
| sessionStatusBadge(session({ status: 'running', runningTurnIds: ['turn-1'] }), 'en'), | ||
| 'running', | ||
| ); | ||
| }); | ||
|
|
||
| test('distinguishes user questions from permission requests with localized copy', () => { | ||
| assert.equal( | ||
| sessionStatusBadge(session({ status: 'waiting_for_user' }), 'en'), | ||
| 'waiting for you', | ||
| ); | ||
| assert.equal( | ||
| sessionStatusBadge( | ||
| session({ status: 'waiting_for_user', blockedReason: 'permission_required' }), | ||
| 'en', | ||
| ), | ||
| 'needs permission', | ||
| ); | ||
| assert.equal(sessionStatusBadge(session({ status: 'waiting_for_user' }), 'zh'), '等你确认'); | ||
| }); | ||
|
|
||
| test('marks only actionable blocked reasons and keeps resting rows unmarked', () => { | ||
| assert.equal( | ||
| sessionStatusBadge(session({ status: 'blocked', blockedReason: 'NO_REAL_CONNECTION' }), 'en'), | ||
| 'needs connection', | ||
| ); | ||
| assert.equal( | ||
| sessionStatusBadge(session({ status: 'blocked', blockedReason: 'auth' }), 'en'), | ||
| 'needs sign-in', | ||
| ); | ||
| assert.equal( | ||
| sessionStatusBadge( | ||
| session({ status: 'blocked', blockedReason: 'permission_required' }), | ||
| 'en', | ||
| ), | ||
| 'needs permission', | ||
| ); | ||
| for (const blockedReason of ['tool_failed', 'unknown'] as const) { | ||
| assert.equal( | ||
| sessionStatusBadge(session({ status: 'blocked', blockedReason }), 'en'), | ||
| undefined, | ||
| ); | ||
| } | ||
| assert.equal(sessionStatusBadge(session({ status: 'active' }), 'en'), undefined); | ||
| assert.equal(sessionStatusBadge(session({ status: 'aborted' }), 'en'), 'stopped'); | ||
| assert.equal(sessionStatusBadge(session({ status: 'aborted' }), 'zh'), '已中止'); | ||
| }); | ||
| }); | ||
|
|
||
| function session( | ||
| overrides: Partial<Pick<SessionSummary, 'status' | 'blockedReason' | 'runningTurnIds'>> = {}, | ||
| ): Pick<SessionSummary, 'status' | 'blockedReason' | 'runningTurnIds'> { | ||
| return { status: 'active', ...overrides }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import type { SessionSummary } from '@maka/core/session'; | ||
| import type { UiCatalog, UiLocale } from '@maka/core/ui-locale'; | ||
|
|
||
| interface TuiSessionStatusCopy { | ||
| readonly running: string; | ||
| readonly waitingForUser: string; | ||
| readonly permissionRequired: string; | ||
| readonly connectionRequired: string; | ||
| readonly signInRequired: string; | ||
| readonly stopped: string; | ||
| } | ||
|
|
||
| const TUI_SESSION_STATUS_COPY = { | ||
| zh: { | ||
| running: '进行中', | ||
| waitingForUser: '等你确认', | ||
| permissionRequired: '需要权限', | ||
| connectionRequired: '需要连接', | ||
| signInRequired: '需要重新登录', | ||
| stopped: '已中止', | ||
| }, | ||
| en: { | ||
| running: 'running', | ||
| waitingForUser: 'waiting for you', | ||
| permissionRequired: 'needs permission', | ||
| connectionRequired: 'needs connection', | ||
| signInRequired: 'needs sign-in', | ||
| stopped: 'stopped', | ||
| }, | ||
| } satisfies UiCatalog<TuiSessionStatusCopy>; | ||
|
|
||
| /** | ||
| * Present the runtime Session state as compact picker copy. | ||
| * | ||
| * Persisted `running` is only credible when the Runtime Host also reports a | ||
| * live Turn. Non-actionable blocked reasons remain ordinary resumable rows, | ||
| * matching Desktop's display projection rather than exposing bookkeeping | ||
| * noise as a broken Session. | ||
| */ | ||
| export function sessionStatusBadge( | ||
| session: Pick<SessionSummary, 'status' | 'blockedReason' | 'runningTurnIds'>, | ||
| locale: UiLocale, | ||
| ): string | undefined { | ||
| const copy = TUI_SESSION_STATUS_COPY[locale]; | ||
| switch (session.status) { | ||
| case 'active': | ||
| return undefined; | ||
| case 'running': | ||
| return session.runningTurnIds?.length ? copy.running : undefined; | ||
| case 'waiting_for_user': | ||
| return session.blockedReason === 'permission_required' | ||
| ? copy.permissionRequired | ||
| : copy.waitingForUser; | ||
| case 'blocked': | ||
| switch (session.blockedReason) { | ||
| case 'NO_REAL_CONNECTION': | ||
| return copy.connectionRequired; | ||
| case 'auth': | ||
| return copy.signInRequired; | ||
| case 'permission_required': | ||
| return copy.permissionRequired; | ||
| case 'tool_failed': | ||
| case 'unknown': | ||
| case undefined: | ||
| return undefined; | ||
| } | ||
| case 'aborted': | ||
| return copy.stopped; | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Keep the live-status badge visible when resume availability is false
Reachability: ② reasonable failure/recovery path. If a Session's local working directory has been removed or is otherwise unavailable,
getSessionResumeAvailability()returnsavailable: false. Even when the Host has authoritatively returned a liverunningTurnIdsvalue, this branch renders only the short id and the availability reason, so the picker hides the fact that a Turn is still running.Could we build the shared description prefix from
shortSessionId+statusDetailand use it in both branches, appending the availability reason only for the unavailable case? That keeps the Host-owned live state visible while still explaining why the Session cannot be resumed locally. Please add one focused picker regression covering an unavailable Session with a live Turn.This is non-blocking; it only affects status visibility on the recovery path.