mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
refactor(tui): /clean pass on tui-polish — data tables, tighter title
- normalizeStatusBar: replace Set + early-returns + cast with a single
alias lookup table. Handles legacy `false`, trims/lowercases strings,
maps `on` → `top` in one pass. One expression, no `as` hacks.
- Tab title block: drop the narrative comment, fold
blockedOnInput/titleStatus/cwdTag/terminalTitle into inline expressions
inside useTerminalTitle. Avoids shadowing the outer `cwd`.
- tui_gateway statusbar set branch: read `display` once instead of
`cfg0.get("display")` twice.
This commit is contained in:
parent
8410ac05a9
commit
103c71ac36
3 changed files with 20 additions and 28 deletions
|
|
@ -14,23 +14,16 @@ import type { StatusBarMode } from './interfaces.js'
|
|||
import { turnController } from './turnController.js'
|
||||
import { patchUiState } from './uiStore.js'
|
||||
|
||||
const STATUSBAR_MODES = new Set<StatusBarMode>(['bottom', 'off', 'top'])
|
||||
|
||||
export const normalizeStatusBar = (raw: unknown): StatusBarMode => {
|
||||
if (raw === false) {
|
||||
return 'off'
|
||||
}
|
||||
|
||||
if (typeof raw !== 'string') {
|
||||
return 'top'
|
||||
}
|
||||
|
||||
const v = raw.trim().toLowerCase()
|
||||
const mode = (v === 'on' ? 'top' : v) as StatusBarMode
|
||||
|
||||
return STATUSBAR_MODES.has(mode) ? mode : 'top'
|
||||
const STATUSBAR_ALIAS: Record<string, StatusBarMode> = {
|
||||
bottom: 'bottom',
|
||||
off: 'off',
|
||||
on: 'top',
|
||||
top: 'top'
|
||||
}
|
||||
|
||||
export const normalizeStatusBar = (raw: unknown): StatusBarMode =>
|
||||
raw === false ? 'off' : typeof raw === 'string' ? STATUSBAR_ALIAS[raw.trim().toLowerCase()] ?? 'top' : 'top'
|
||||
|
||||
const MTIME_POLL_MS = 5000
|
||||
|
||||
const quietRpc = async <T extends Record<string, any> = Record<string, any>>(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { type ScrollBoxHandle, useApp, useHasSelection, useSelection, useStdout, useTerminalTitle } from '@hermes/ink'
|
||||
import { useApp, useHasSelection, useSelection, useStdout, useTerminalTitle, type ScrollBoxHandle } from '@hermes/ink'
|
||||
import { useStore } from '@nanostores/react'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
|
||||
|
|
@ -314,16 +314,15 @@ export function useMainApp(gw: GatewayClient) {
|
|||
|
||||
useConfigSync({ gw, setBellOnComplete, setVoiceEnabled, sid: ui.sid })
|
||||
|
||||
// ── Terminal tab title ─────────────────────────────────────────────
|
||||
// model + cwd + 3-state marker so multi-instance users can spot which tab
|
||||
// is working, which is idle, and which is waiting on them.
|
||||
// `⚠` blocked on approval/sudo/secret/clarify, `⏳` busy, `✓` idle.
|
||||
const shortModel = ui.info?.model?.replace(/^.*\//, '') ?? ''
|
||||
const blockedOnInput = !!(overlay.approval || overlay.sudo || overlay.secret || overlay.clarify)
|
||||
const titleStatus = blockedOnInput ? '⚠' : ui.busy ? '⏳' : '✓'
|
||||
const cwdTag = ui.info?.cwd ? ` · ${shortCwd(ui.info.cwd, 24)}` : ''
|
||||
const terminalTitle = shortModel ? `${titleStatus} ${shortModel}${cwdTag}` : 'Hermes'
|
||||
useTerminalTitle(terminalTitle)
|
||||
// Tab title: `⚠` waiting on approval/sudo/secret/clarify, `⏳` busy, `✓` idle.
|
||||
const model = ui.info?.model?.replace(/^.*\//, '') ?? ''
|
||||
const marker =
|
||||
overlay.approval || overlay.sudo || overlay.secret || overlay.clarify ? '⚠' : ui.busy ? '⏳' : '✓'
|
||||
const tabCwd = ui.info?.cwd
|
||||
|
||||
useTerminalTitle(
|
||||
model ? `${marker} ${model}${tabCwd ? ` · ${shortCwd(tabCwd, 24)}` : ''}` : 'Hermes'
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (!ui.sid || !stdout) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue