mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-29 01:31:41 +00:00
refactor(tui): turn elapsed lives in FaceTicker; emit done-in sys line
Drops `lastUserAt` plumbing and the right-edge idle ticker. Matches the
claude-code / opencode convention: elapsed rides with the busy indicator
(spinner verb), nothing at idle.
- `turnStartedAt` driven by a useEffect on `ui.busy` — stamps on rising
edge, clears on falling edge. Covers agent turns and !shell alike.
- FaceTicker renders ` · {fmtDuration}` while busy; 1 s clock for the
counter, existing 2500 ms cycle for face/verb rotation.
- On busy → idle, if the block ran ≥ 1 s, emit a one-shot
`done in {fmtDuration}` sys line (≡ claude-code's `thought for Ns`).
This commit is contained in:
parent
9910681b85
commit
2de1aad028
8 changed files with 43 additions and 50 deletions
|
|
@ -4,7 +4,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|||
|
||||
import { STARTUP_RESUME_ID } from '../config/env.js'
|
||||
import { MAX_HISTORY, WHEEL_SCROLL_STEP } from '../config/limits.js'
|
||||
import { imageTokenMeta } from '../domain/messages.js'
|
||||
import { fmtDuration, imageTokenMeta } from '../domain/messages.js'
|
||||
import { fmtCwdBranch } from '../domain/paths.js'
|
||||
import { type GatewayClient } from '../gatewayClient.js'
|
||||
import type {
|
||||
|
|
@ -102,7 +102,7 @@ export function useMainApp(gw: GatewayClient) {
|
|||
const [voiceRecording, setVoiceRecording] = useState(false)
|
||||
const [voiceProcessing, setVoiceProcessing] = useState(false)
|
||||
const [sessionStartedAt, setSessionStartedAt] = useState(() => Date.now())
|
||||
const [lastUserAt, setLastUserAt] = useState<null | number>(null)
|
||||
const [turnStartedAt, setTurnStartedAt] = useState<null | number>(null)
|
||||
const [goodVibesTick, setGoodVibesTick] = useState(0)
|
||||
const [bellOnComplete, setBellOnComplete] = useState(false)
|
||||
|
||||
|
|
@ -276,7 +276,6 @@ export function useMainApp(gw: GatewayClient) {
|
|||
rpc,
|
||||
scrollRef,
|
||||
setHistoryItems,
|
||||
setLastUserAt,
|
||||
setLastUserMsg,
|
||||
setSessionStartedAt,
|
||||
setStickyPrompt,
|
||||
|
|
@ -285,6 +284,26 @@ export function useMainApp(gw: GatewayClient) {
|
|||
sys
|
||||
})
|
||||
|
||||
// Drive turnStartedAt from the busy edge and emit a one-shot "done in Xs"
|
||||
// line on the idle edge. Covers agent turns and `!shell` alike — only
|
||||
// suppresses when the block is under ~1s (too quick to matter).
|
||||
useEffect(() => {
|
||||
if (ui.busy && turnStartedAt === null) {
|
||||
setTurnStartedAt(Date.now())
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if (!ui.busy && turnStartedAt !== null) {
|
||||
const elapsed = Date.now() - turnStartedAt
|
||||
setTurnStartedAt(null)
|
||||
|
||||
if (elapsed >= 1000) {
|
||||
sys(`done in ${fmtDuration(elapsed)}`)
|
||||
}
|
||||
}
|
||||
}, [sys, turnStartedAt, ui.busy])
|
||||
|
||||
useConfigSync({ gw, setBellOnComplete, setVoiceEnabled, sid: ui.sid })
|
||||
|
||||
// ── Terminal tab title ─────────────────────────────────────────────
|
||||
|
|
@ -376,7 +395,6 @@ export function useMainApp(gw: GatewayClient) {
|
|||
composerState,
|
||||
gw,
|
||||
maybeGoodVibes,
|
||||
setLastUserAt,
|
||||
setLastUserMsg,
|
||||
slashRef,
|
||||
submitRef,
|
||||
|
|
@ -500,7 +518,6 @@ export function useMainApp(gw: GatewayClient) {
|
|||
newSession: session.newSession,
|
||||
resetVisibleHistory: session.resetVisibleHistory,
|
||||
resumeById: session.resumeById,
|
||||
setLastUserAt,
|
||||
setSessionStartedAt
|
||||
},
|
||||
slashFlightRef,
|
||||
|
|
@ -635,20 +652,20 @@ export function useMainApp(gw: GatewayClient) {
|
|||
() => ({
|
||||
cwdLabel: fmtCwdBranch(cwd, gitBranch),
|
||||
goodVibesTick,
|
||||
lastUserAt: ui.sid ? lastUserAt : null,
|
||||
sessionStartedAt: ui.sid ? sessionStartedAt : null,
|
||||
showStickyPrompt: !!stickyPrompt,
|
||||
statusColor: statusColorOf(ui.status, ui.theme.color),
|
||||
stickyPrompt,
|
||||
turnStartedAt: ui.sid ? turnStartedAt : null,
|
||||
voiceLabel: voiceRecording ? 'REC' : voiceProcessing ? 'STT' : `voice ${voiceEnabled ? 'on' : 'off'}`
|
||||
}),
|
||||
[
|
||||
cwd,
|
||||
gitBranch,
|
||||
goodVibesTick,
|
||||
lastUserAt,
|
||||
sessionStartedAt,
|
||||
stickyPrompt,
|
||||
turnStartedAt,
|
||||
ui,
|
||||
voiceEnabled,
|
||||
voiceProcessing,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue