mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-13 03:52:00 +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
|
|
@ -102,30 +102,25 @@ export function useSessionLifecycle(opts: UseSessionLifecycleOptions) {
|
|||
return patchUiState({ status: 'ready' })
|
||||
}
|
||||
|
||||
const info = r.info ?? null
|
||||
|
||||
resetSession()
|
||||
setSessionStartedAt(Date.now())
|
||||
// Python's `session.create` returns instantly with partial info (no `version`
|
||||
// field); the `session.info` event will flip status to 'ready' once the
|
||||
// agent is fully built (~1s later). Until then prompt.submit will block
|
||||
// server-side on `_wait_agent`.
|
||||
|
||||
// session.create returns instantly with partial info (no `version`);
|
||||
// the `session.info` event flips status to 'ready' once the agent is live.
|
||||
patchUiState({
|
||||
info: r.info ?? null,
|
||||
info,
|
||||
sid: r.session_id,
|
||||
status: r.info?.version ? 'ready' : 'starting agent…',
|
||||
usage: usageFrom(r.info ?? null)
|
||||
status: info?.version ? 'ready' : 'starting agent…',
|
||||
usage: usageFrom(info)
|
||||
})
|
||||
|
||||
if (r.info) {
|
||||
setHistoryItems([introMsg(r.info)])
|
||||
}
|
||||
if (info) setHistoryItems([introMsg(info)])
|
||||
|
||||
if (r.info?.credential_warning) {
|
||||
sys(`warning: ${r.info.credential_warning}`)
|
||||
}
|
||||
if (info?.credential_warning) sys(`warning: ${info.credential_warning}`)
|
||||
|
||||
if (msg) {
|
||||
sys(msg)
|
||||
}
|
||||
if (msg) sys(msg)
|
||||
},
|
||||
[closeSession, colsRef, resetSession, rpc, setHistoryItems, setSessionStartedAt, sys]
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue