mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
refactor(tui): clean up touched files — DRY, KISS, functional
Python (tui_gateway/server.py):
- hoist `_wait_agent` next to `_sess` so `_sess` no longer forward-refs
- simplify `_wait_agent`: `ready.wait()` already returns True when set,
no separate `.is_set()` check, collapse two returns into one expr
- factor `_sess_nowait` for handlers that don't need the agent (currently
`terminal.resize` + `input.detect_drop`) — DRY up the duplicated
`_sessions.get` + "session not found" dance
- inline `session = _sessions[sid]` in the session.create build thread so
agent/worker writes don't re-look-up the dict each time
- rename inline `ready_event` → `ready` (it's never ambiguous)
TS:
- `useSessionLifecycle.newSession`: hoist `r.info ?? null` into `info`
so it's one lookup, drop ceremonial `{ … }` blocks around single-line
bodies
- `createGatewayEventHandler.session.info`: wrap the case in a block,
hoist `ev.payload` into `info`, tighten comments
- `useMainApp` flush effect: collapse two guard returns into one
- `bootBanner.ts`: lift `TAGLINE` + `FALLBACK` to module constants, make
`GRADIENT` readonly, one-liner return via template literal
- `theme.ts`: group `selectionBg` inside the status* block (it's a UI
surface bg, same family), trim the comment
This commit is contained in:
parent
275256cdb4
commit
727f0eaf74
6 changed files with 92 additions and 105 deletions
|
|
@ -161,21 +161,24 @@ export function createGatewayEventHandler(ctx: GatewayEventHandlerContext): (ev:
|
|||
|
||||
return
|
||||
|
||||
case 'session.info':
|
||||
case 'session.info': {
|
||||
const info = ev.payload
|
||||
|
||||
patchUiState(state => ({
|
||||
...state,
|
||||
info: ev.payload,
|
||||
// Flip from 'starting agent…' → 'ready' when the agent is live.
|
||||
// Leave running/interrupted/error statuses alone.
|
||||
info,
|
||||
// agent just came online → flip the 'starting agent…' placeholder.
|
||||
// leave running/interrupted/error statuses alone.
|
||||
status: state.status === 'starting agent…' ? 'ready' : state.status,
|
||||
usage: ev.payload.usage ? { ...state.usage, ...ev.payload.usage } : state.usage
|
||||
usage: info.usage ? { ...state.usage, ...info.usage } : state.usage
|
||||
}))
|
||||
// Agent init is async in session.create, so the intro message may
|
||||
// have been seeded with partial info (just model/cwd). Upgrade it
|
||||
// in-place when the real session.info lands.
|
||||
setHistoryItems(prev => prev.map(m => (m.kind === 'intro' ? { ...m, info: ev.payload } : m)))
|
||||
|
||||
// upgrade the seeded/partial intro row in-place with the real info
|
||||
setHistoryItems(prev => prev.map(m => (m.kind === 'intro' ? { ...m, info } : m)))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
case 'thinking.delta': {
|
||||
const text = ev.payload?.text
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue