Repository navigation
chore: enhance session status indicators in chat hisotry and sessions #1391
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
base: main
Are you sure you want to change the base?
Changes from all commits
6729c66
06cdd9d
74424a5
13247a4
f0d3551
6f5c85e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@truefoundry/trueforge-ui': patch | ||
| --- | ||
|
|
||
| Hide paused status dots after 48 hours of inactivity, and show failed runs with a circle-xmark icon in the agent session list only (no failure chrome in chat history). Session lists poll running and paused rows every 5 seconds, and a poll that sees a new pause also refreshes the activity time so the dot is not stuck hidden. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,13 +9,34 @@ function isTurnStatus(value: unknown): value is TurnStatus { | |
| return typeof value === 'string' && TURN_STATUS_VALUES.has(value); | ||
| } | ||
|
|
||
| /** Orange paused dots older than this are hidden (AGE-2831). */ | ||
| export const PAUSED_STATUS_DOT_MAX_AGE_MS = 48 * 60 * 60 * 1000; | ||
|
|
||
| function isValidActivityDate(date: Date): boolean { | ||
| return !Number.isNaN(date.getTime()); | ||
| } | ||
|
|
||
| /** Tailwind bg class for a last-turn status dot; undefined means hide the dot. */ | ||
| export function lastTurnStatusDotClass(status: TurnStatus | undefined | null): string | undefined { | ||
| export function lastTurnStatusDotClass({ | ||
| status, | ||
| activityAt, | ||
| now = new Date(), | ||
| }: { | ||
| status: TurnStatus | undefined | null; | ||
| activityAt?: Date | null; | ||
| now?: Date; | ||
| }): string | undefined { | ||
| switch (status) { | ||
| case 'paused': | ||
| case 'paused': { | ||
| if ( | ||
| activityAt != null && | ||
| isValidActivityDate(activityAt) && | ||
| now.getTime() - activityAt.getTime() > PAUSED_STATUS_DOT_MAX_AGE_MS | ||
| ) { | ||
| return undefined; | ||
| } | ||
| return 'bg-warning-bg'; | ||
| case 'error': | ||
| return 'bg-failure-bg'; | ||
| } | ||
| default: | ||
| return undefined; | ||
| } | ||
|
|
@@ -101,6 +122,32 @@ export function readThreadIsMutable(custom: unknown): boolean | undefined { | |
| return typeof value === 'boolean' ? value : undefined; | ||
| } | ||
|
|
||
| /** Activity time stamped by the status poll. Newer than `lastMessageAt` after a fresh pause. */ | ||
| export function readThreadLastActivityAt(custom: unknown): Date | undefined { | ||
| if (custom == null || typeof custom !== 'object') return undefined; | ||
| if (!('lastActivityAt' in custom)) return undefined; | ||
| const value = Reflect.get(custom, 'lastActivityAt'); | ||
| if (typeof value !== 'string') return undefined; | ||
| const date = new Date(value); | ||
| return Number.isNaN(date.getTime()) ? undefined : date; | ||
| } | ||
|
|
||
| /** True when `nextIso` is a valid time strictly after `prev`. Missing `prev` counts as newer. */ | ||
| export function isNewerActivityAt(nextIso: string, prev: Date | undefined): boolean { | ||
| const next = new Date(nextIso); | ||
| if (Number.isNaN(next.getTime())) return false; | ||
| if (prev == null || Number.isNaN(prev.getTime())) return true; | ||
| return next.getTime() > prev.getTime(); | ||
| } | ||
|
|
||
| /** Later of the list payload time and a poll stamp. */ | ||
| export function laterActivityAt(left: Date | undefined, right: Date | undefined): Date | undefined { | ||
| if (left == null || Number.isNaN(left.getTime())) | ||
| return right != null && !Number.isNaN(right.getTime()) ? right : undefined; | ||
| if (right == null || Number.isNaN(right.getTime())) return left; | ||
| return right.getTime() > left.getTime() ? right : left; | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Helper takes two positional datesLow Severity New helper Triggered by project rule: TrueForge review rules Reviewed by Cursor Bugbot for commit 6f5c85e. Configure here. |
||
|
|
||
| /** Last-turn status stamped on thread-list custom by `sessionToThreadMetadata`. */ | ||
| export function readThreadLastTurnStatus(custom: unknown): TurnStatus | undefined { | ||
| if (custom == null || typeof custom !== 'object') return undefined; | ||
|
|
@@ -113,6 +160,7 @@ export function readThreadLastTurnStatus(custom: unknown): TurnStatus | undefine | |
| export function threadCustomWithLastTurnStatus( | ||
| custom: unknown, | ||
| status: TurnStatus | null | undefined, | ||
| activityAt?: string, | ||
| ): Record<string, unknown> { | ||
| const base = | ||
| custom != null && typeof custom === 'object' && !Array.isArray(custom) | ||
|
|
@@ -122,6 +170,9 @@ export function threadCustomWithLastTurnStatus( | |
| if (status != null) { | ||
| base.lastTurnStatus = status; | ||
| } | ||
| if (activityAt != null) { | ||
| base.lastActivityAt = activityAt; | ||
| } | ||
| return base; | ||
| } | ||
|
|
||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.