mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
Merge pull request #358 from nwparker/cloud/routines-card-p3
cloud routines: Run now button matches the run status, no redundant line, 'just now' (AG-2)
This commit is contained in:
@@ -127,17 +127,14 @@ export function RoutineRow({
|
||||
setNotice(null)
|
||||
const failure = await onRunNow()
|
||||
setRunning(false)
|
||||
setNotice(
|
||||
failure
|
||||
? { tone: 'error', text: failure }
|
||||
: {
|
||||
tone: 'ok',
|
||||
text: t(
|
||||
'auto.components.settings.cloudRoutines.queued',
|
||||
'Run queued. It shows up in the history below.'
|
||||
)
|
||||
}
|
||||
)
|
||||
if (failure) {
|
||||
setNotice({ tone: 'error', text: failure })
|
||||
return
|
||||
}
|
||||
// The new run's status lives in the pill and the history; open the history so it is in view.
|
||||
if (!expanded) {
|
||||
onToggleHistory()
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -218,7 +215,7 @@ export function RoutineRow({
|
||||
variant="ghost"
|
||||
size="xs"
|
||||
aria-disabled={running && !active}
|
||||
aria-busy={running || active}
|
||||
aria-busy={running}
|
||||
aria-expanded={active ? expanded : undefined}
|
||||
aria-controls={active ? historyId : undefined}
|
||||
onClick={() => void runNow()}
|
||||
@@ -246,14 +243,9 @@ export function RoutineRow({
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{running || active ? (
|
||||
<Loader2 className="animate-spin motion-reduce:animate-none" />
|
||||
) : (
|
||||
<Play />
|
||||
)}
|
||||
{active
|
||||
? t('auto.components.settings.cloudRoutines.runningNow', 'Running…')
|
||||
: t('auto.components.settings.cloudRoutines.runNow', 'Run now')}
|
||||
{/* Spins only while the request is in flight; the run's own status is the pill's job. */}
|
||||
{running ? <Loader2 className="animate-spin motion-reduce:animate-none" /> : <Play />}
|
||||
{t('auto.components.settings.cloudRoutines.runNow', 'Run now')}
|
||||
</Button>
|
||||
<DropdownMenu modal={false}>
|
||||
<DropdownMenuTrigger asChild>
|
||||
|
||||
@@ -283,6 +283,41 @@ export const runHistory = defineFixture({
|
||||
render: () => <CloudRoutinesView {...props} initial={{ historyFor: 'rt_review' }} />
|
||||
})
|
||||
|
||||
/** Right after Run now: the pill and history say Queued; the button is back to Run now. */
|
||||
export const justQueued = defineFixture({
|
||||
width: 820,
|
||||
render: () => (
|
||||
<CloudRoutinesView
|
||||
{...props}
|
||||
routines={{
|
||||
status: 'ok',
|
||||
data: ROUTINES.map((r) =>
|
||||
r.id === 'rt_triage'
|
||||
? { ...r, lastRun: { id: 'run_q', status: 'queued', finishedAt: null } }
|
||||
: r
|
||||
)
|
||||
}}
|
||||
loadRuns={async () => ({
|
||||
ok: true,
|
||||
data: {
|
||||
runs: [
|
||||
run({
|
||||
id: 'run_q',
|
||||
status: 'queued',
|
||||
trigger: 'manual',
|
||||
createdAt: NOW - 3_000,
|
||||
startedAt: null
|
||||
}),
|
||||
...RUNS.runs.slice(1)
|
||||
],
|
||||
nextBefore: null
|
||||
}
|
||||
})}
|
||||
initial={{ historyFor: 'rt_triage' }}
|
||||
/>
|
||||
)
|
||||
})
|
||||
|
||||
export const runHistoryEmpty = defineFixture({
|
||||
width: 820,
|
||||
render: () => (
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
describeRoutineTrigger,
|
||||
formatCountdown,
|
||||
formatKeyPrefix,
|
||||
formatRelativeFromNow,
|
||||
formatRunDuration,
|
||||
presetForScopes,
|
||||
scopesForPreset,
|
||||
@@ -65,6 +66,15 @@ describe('formatting', () => {
|
||||
).toMatch(/^Weekdays at 9:00.* E[SD]T$/)
|
||||
})
|
||||
|
||||
it('says "just now" for the last minute, not "this minute"', () => {
|
||||
const now = 1_000_000_000
|
||||
expect(formatRelativeFromNow(now - 3_000, now, 'en')).toBe('just now')
|
||||
expect(formatRelativeFromNow(now - 59_000, now, 'en')).toBe('just now')
|
||||
expect(formatRelativeFromNow(now - 5 * 60_000, now, 'en')).toBe('5 minutes ago')
|
||||
// Future times (next scheduled run) keep Intl wording.
|
||||
expect(formatRelativeFromNow(now + 10 * 60_000, now, 'en')).toBe('in 10 minutes')
|
||||
})
|
||||
|
||||
it('offers the local zone first', () => {
|
||||
const zones = timeZoneOptions('Asia/Tokyo')
|
||||
expect(zones[0]).toBe('Asia/Tokyo')
|
||||
|
||||
@@ -51,6 +51,10 @@ export function formatKeyPrefix(prefix: string): string {
|
||||
}
|
||||
|
||||
export function formatRelativeFromNow(timestamp: number, now: number, intlLocale?: string): string {
|
||||
// Under a minute ago reads "just now", like the other cloud screens (not Intl's "this minute").
|
||||
if (timestamp <= now && now - timestamp < 60_000) {
|
||||
return translate('auto.components.cloudWorkspaces.justNow', 'just now')
|
||||
}
|
||||
return formatUiRelativeTime(timestamp - now, intlLocale)
|
||||
}
|
||||
|
||||
|
||||
@@ -14601,7 +14601,6 @@
|
||||
"sectionDescription": "For the Orca Cloud API, the orca CLI and MCP clients. Claude or Codex keys go in Cloud secrets."
|
||||
},
|
||||
"cloudRoutines": {
|
||||
"queued": "Run queued. It shows up in the history below.",
|
||||
"pausedSr": "(paused)",
|
||||
"createdByPerson": "by <person></person>",
|
||||
"lastRun": "Last run:",
|
||||
@@ -14610,7 +14609,6 @@
|
||||
"runningShowHistory": "{{routineName}} is running. Show run history",
|
||||
"runNowLabel": "Run {{routineName}} now",
|
||||
"alreadyRunning": "A run is already in progress.",
|
||||
"runningNow": "Running…",
|
||||
"runNow": "Run now",
|
||||
"more": "More actions for {{routineName}}",
|
||||
"hideHistory": "Hide run history",
|
||||
|
||||
Reference in New Issue
Block a user