mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-07 02:51:50 +00:00
chore(tui): clean remaining Ink perf scaffolding
Trim narration comments and collapse small one-off helpers in the remaining ui-tui perf support files while preserving behaviour.
This commit is contained in:
parent
7da2f07641
commit
2e4b65b9f5
8 changed files with 43 additions and 78 deletions
|
|
@ -205,11 +205,6 @@ export default class App extends PureComponent<Props, State> {
|
|||
</TerminalSizeContext.Provider>
|
||||
)
|
||||
}
|
||||
override componentDidMount() {
|
||||
// Keep the native terminal cursor visible. Ink parks it at the declared
|
||||
// input caret after each frame, so the terminal emulator provides the
|
||||
// normal blinking block/bar without React-driven blink re-renders.
|
||||
}
|
||||
override componentWillUnmount() {
|
||||
if (this.props.stdout.isTTY) {
|
||||
this.props.stdout.write(SHOW_CURSOR)
|
||||
|
|
@ -574,9 +569,7 @@ export function handleMouseEvent(app: App, m: ParsedMouse): void {
|
|||
const row = m.row - 1
|
||||
const baseButton = m.button & 0x03
|
||||
|
||||
// Allow disabling app click/selection handling while keeping wheel scroll
|
||||
// and DOM mouse dispatch alive. Put this after coordinate/button decoding
|
||||
// and exempt non-left buttons so scrollbar/right-click handlers still work.
|
||||
// Disable app click handling without blocking wheel/right-click dispatch.
|
||||
if (isMouseClicksDisabled() && baseButton === 0) {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,20 +124,6 @@ function ScrollBox({ children, ref, stickyScroll, ...style }: PropsWithChildren<
|
|||
})
|
||||
}
|
||||
|
||||
const scrollByNow = (dy: number) => {
|
||||
const el = domRef.current
|
||||
|
||||
if (!el) {
|
||||
return
|
||||
}
|
||||
|
||||
el.stickyScroll = false
|
||||
manualScrollAtRef.current = Date.now()
|
||||
el.scrollAnchor = undefined
|
||||
el.pendingScrollDelta = (el.pendingScrollDelta ?? 0) + Math.floor(dy)
|
||||
scrollMutated(el)
|
||||
}
|
||||
|
||||
useImperativeHandle(
|
||||
ref,
|
||||
(): ScrollBoxHandle => ({
|
||||
|
|
@ -173,7 +159,19 @@ function ScrollBox({ children, ref, stickyScroll, ...style }: PropsWithChildren<
|
|||
}
|
||||
scrollMutated(box)
|
||||
},
|
||||
scrollBy: scrollByNow,
|
||||
scrollBy(dy: number) {
|
||||
const el = domRef.current
|
||||
|
||||
if (!el) {
|
||||
return
|
||||
}
|
||||
|
||||
el.stickyScroll = false
|
||||
manualScrollAtRef.current = Date.now()
|
||||
el.scrollAnchor = undefined
|
||||
el.pendingScrollDelta = (el.pendingScrollDelta ?? 0) + Math.floor(dy)
|
||||
scrollMutated(el)
|
||||
},
|
||||
scrollToBottom() {
|
||||
const el = domRef.current
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@ import { nonAlphanumericKeys, type ParsedKey } from '../parse-keypress.js'
|
|||
|
||||
import { Event } from './event.js'
|
||||
|
||||
const inputForSpecialSequence = (name: string): string =>
|
||||
name === 'space' ? ' ' : name === 'return' || name === 'escape' ? '' : name
|
||||
|
||||
export type Key = {
|
||||
upArrow: boolean
|
||||
downArrow: boolean
|
||||
|
|
@ -116,11 +119,7 @@ function parseKey(keypress: ParsedKey): [Key, string] {
|
|||
// so the raw "[57358u" doesn't leak into the prompt. See #38781.
|
||||
input = ''
|
||||
} else {
|
||||
// 'space' → ' '; functional keys like Enter/Escape carry their state
|
||||
// through key.return/key.escape, and processedAsSpecialSequence bypasses
|
||||
// the nonAlphanumericKeys clear below, so clear them explicitly here.
|
||||
input =
|
||||
keypress.name === 'space' ? ' ' : keypress.name === 'return' || keypress.name === 'escape' ? '' : keypress.name
|
||||
input = inputForSpecialSequence(keypress.name)
|
||||
}
|
||||
|
||||
processedAsSpecialSequence = true
|
||||
|
|
@ -138,8 +137,7 @@ function parseKey(keypress: ParsedKey): [Key, string] {
|
|||
// guards against future terminal behavior.
|
||||
input = ''
|
||||
} else {
|
||||
input =
|
||||
keypress.name === 'space' ? ' ' : keypress.name === 'return' || keypress.name === 'escape' ? '' : keypress.name
|
||||
input = inputForSpecialSequence(keypress.name)
|
||||
}
|
||||
|
||||
processedAsSpecialSequence = true
|
||||
|
|
|
|||
|
|
@ -46,16 +46,13 @@ export type FrameEvent = {
|
|||
write: number
|
||||
/** Pre-optimize patch count (proxy for how much changed this frame) */
|
||||
patches: number
|
||||
/** Post-optimize patch count — what was actually written to stdout. */
|
||||
/** Post-optimize patch count. */
|
||||
optimizedPatches: number
|
||||
/** Bytes written to stdout this frame (escape sequences + payload). */
|
||||
/** Bytes written to stdout this frame. */
|
||||
writeBytes: number
|
||||
/** Whether stdout.write returned false (backpressure = outer terminal slow). */
|
||||
/** Whether stdout.write returned false. */
|
||||
backpressure: boolean
|
||||
/** ms from this frame's stdout.write until the write-callback fired.
|
||||
* Populated on the NEXT frame (async), so this field reflects the
|
||||
* PREVIOUS frame's terminal-drain time. 0 = callback already fired
|
||||
* before next frame started (drained in sub-ms). */
|
||||
/** Previous stdout.write callback latency; 0 if drained before next frame. */
|
||||
prevFrameDrainMs: number
|
||||
/** yoga calculateLayout() time (runs in resetAfterCommit, before onRender) */
|
||||
yoga: number
|
||||
|
|
|
|||
|
|
@ -203,13 +203,7 @@ export async function setClipboard(text: string): Promise<ClipboardResult> {
|
|||
|
||||
// Inner OSC uses BEL directly (not osc()) — ST's ESC would need doubling
|
||||
// too, and BEL works everywhere for OSC 52.
|
||||
const sequence = tmuxBufferLoaded
|
||||
? emitSequence
|
||||
? tmuxPassthrough(`${ESC}]52;c;${b64}${BEL}`)
|
||||
: ''
|
||||
: emitSequence
|
||||
? raw
|
||||
: ''
|
||||
const sequence = emitSequence ? (tmuxBufferLoaded ? tmuxPassthrough(`${ESC}]52;c;${b64}${BEL}`) : raw) : ''
|
||||
|
||||
// Success if any path was taken. Native and tmux are fire-and-forget,
|
||||
// so we can't truly confirm the clipboard was written — but if native
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue