mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-04 09:47:54 +08:00
chore: formatting etc
This commit is contained in:
@@ -14,8 +14,15 @@ interface SessionItem {
|
||||
|
||||
function age(ts: number): string {
|
||||
const d = (Date.now() / 1000 - ts) / 86400
|
||||
if (d < 1) return 'today'
|
||||
if (d < 2) return 'yesterday'
|
||||
|
||||
if (d < 1) {
|
||||
return 'today'
|
||||
}
|
||||
|
||||
if (d < 2) {
|
||||
return 'yesterday'
|
||||
}
|
||||
|
||||
return `${Math.floor(d)}d ago`
|
||||
}
|
||||
|
||||
@@ -46,16 +53,32 @@ export function SessionPicker({
|
||||
}, [gw])
|
||||
|
||||
useInput((ch, key) => {
|
||||
if (key.escape) return onCancel()
|
||||
if (key.upArrow && sel > 0) setSel(s => s - 1)
|
||||
if (key.downArrow && sel < items.length - 1) setSel(s => s + 1)
|
||||
if (key.return && items[sel]) onSelect(items[sel]!.id)
|
||||
if (key.escape) {
|
||||
return onCancel()
|
||||
}
|
||||
|
||||
if (key.upArrow && sel > 0) {
|
||||
setSel(s => s - 1)
|
||||
}
|
||||
|
||||
if (key.downArrow && sel < items.length - 1) {
|
||||
setSel(s => s + 1)
|
||||
}
|
||||
|
||||
if (key.return && items[sel]) {
|
||||
onSelect(items[sel]!.id)
|
||||
}
|
||||
|
||||
const n = parseInt(ch)
|
||||
if (n >= 1 && n <= Math.min(9, items.length)) onSelect(items[n - 1]!.id)
|
||||
|
||||
if (n >= 1 && n <= Math.min(9, items.length)) {
|
||||
onSelect(items[n - 1]!.id)
|
||||
}
|
||||
})
|
||||
|
||||
if (loading) return <Text color={t.color.dim}>loading sessions…</Text>
|
||||
if (loading) {
|
||||
return <Text color={t.color.dim}>loading sessions…</Text>
|
||||
}
|
||||
|
||||
if (!items.length) {
|
||||
return (
|
||||
@@ -71,10 +94,13 @@ export function SessionPicker({
|
||||
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Text bold color={t.color.amber}>Resume Session</Text>
|
||||
{off > 0 && <Text color={t.color.dim}> ↑ {off} more</Text>}
|
||||
<Text bold color={t.color.amber}>
|
||||
Resume Session
|
||||
</Text>
|
||||
{off > 0 && <Text color={t.color.dim}> ↑ {off} more</Text>}
|
||||
{visible.map((s, vi) => {
|
||||
const i = off + vi
|
||||
|
||||
return (
|
||||
<Text key={s.id}>
|
||||
<Text color={sel === i ? t.color.label : t.color.dim}>{sel === i ? '▸ ' : ' '}</Text>
|
||||
@@ -82,12 +108,13 @@ export function SessionPicker({
|
||||
{i + 1}. {s.title || s.preview || s.id.slice(0, 8)}
|
||||
</Text>
|
||||
<Text color={t.color.dim}>
|
||||
{' '}({s.message_count} msgs, {age(s.started_at)})
|
||||
{' '}
|
||||
({s.message_count} msgs, {age(s.started_at)})
|
||||
</Text>
|
||||
</Text>
|
||||
)
|
||||
})}
|
||||
{off + VISIBLE < items.length && <Text color={t.color.dim}> ↓ {items.length - off - VISIBLE} more</Text>}
|
||||
{off + VISIBLE < items.length && <Text color={t.color.dim}> ↓ {items.length - off - VISIBLE} more</Text>}
|
||||
<Text color={t.color.dim}>↑/↓ select · Enter resume · 1-9 quick · Esc cancel</Text>
|
||||
</Box>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user