mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-04 02:21:47 +00:00
chore(tui): fix eslint/prettier nits from npm run fix
- drop inline `import()` type annotation in useSessionLifecycle (import `PanelSection` at the top like everything else) - include `panel` and `session.resumeById` in the useMainApp useMemo deps now that the event handler depends on them - wrap the derived `selected` range in a useMemo so it has stable identity and stops invalidating the TextInput `rendered` memo every render - prettier re-sorting of a couple of export/import lines
This commit is contained in:
parent
a82097e7a2
commit
8f553a55b2
4 changed files with 12 additions and 7 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { useApp, useHasSelection, useSelection, useStdout, type ScrollBoxHandle } from '@hermes/ink'
|
||||
import { type ScrollBoxHandle, useApp, useHasSelection, useSelection, useStdout } from '@hermes/ink'
|
||||
import { useStore } from '@nanostores/react'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
|
||||
|
|
@ -426,9 +426,11 @@ export function useMainApp(gw: GatewayClient) {
|
|||
composerActions,
|
||||
composerRefs,
|
||||
gateway,
|
||||
panel,
|
||||
sendQueued,
|
||||
session.newSession,
|
||||
session.resetSession,
|
||||
session.resumeById,
|
||||
stdout,
|
||||
sys
|
||||
]
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import type {
|
|||
SetupStatusResponse
|
||||
} from '../gatewayTypes.js'
|
||||
import { asRpcResult } from '../lib/rpc.js'
|
||||
import type { Msg, SessionInfo, Usage } from '../types.js'
|
||||
import type { Msg, PanelSection, SessionInfo, Usage } from '../types.js'
|
||||
|
||||
import type { ComposerActions, GatewayRpc, StateSetter } from './interfaces.js'
|
||||
import { patchOverlayState } from './overlayStore.js'
|
||||
|
|
@ -39,7 +39,7 @@ export interface UseSessionLifecycleOptions {
|
|||
colsRef: { current: number }
|
||||
composerActions: ComposerActions
|
||||
gw: GatewayClient
|
||||
panel: (title: string, sections: import('../types.js').PanelSection[]) => void
|
||||
panel: (title: string, sections: PanelSection[]) => void
|
||||
rpc: GatewayRpc
|
||||
setHistoryItems: StateSetter<Msg[]>
|
||||
setLastUserMsg: StateSetter<string>
|
||||
|
|
|
|||
|
|
@ -307,8 +307,11 @@ export function TextInput({
|
|||
const raw = self.current ? vRef.current : value
|
||||
const display = mask ? raw.replace(/[^\n]/g, mask[0] ?? '*') : raw
|
||||
|
||||
const selected =
|
||||
sel && sel.start !== sel.end ? { end: Math.max(sel.start, sel.end), start: Math.min(sel.start, sel.end) } : null
|
||||
const selected = useMemo(
|
||||
() =>
|
||||
sel && sel.start !== sel.end ? { end: Math.max(sel.start, sel.end), start: Math.min(sel.start, sel.end) } : null,
|
||||
[sel]
|
||||
)
|
||||
|
||||
const layout = useMemo(() => cursorLayout(display, cur, columns), [columns, cur, display])
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue