mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-28 01:21:43 +00:00
fix(tui): address code review findings
Medium fixes: - textInput.tsx: prevent silent data loss when async paste resolves after user types — fall back to raw text insert at current cursor instead of dropping the content entirely - useComposerState.ts: tighten looksLikeDroppedPath to require a second '/' or '.' for bare absolute paths, avoiding unnecessary RPC round-trips for pasted text like /api or /help - useComposerState.ts: add cross-reference comment linking to the canonical _detect_file_drop() in cli.py - osc52.ts: add 500ms timeout via Promise.race so terminals that do not support OSC52 clipboard queries cannot hang paste Low fixes: - terminalSetup.ts: export isRemoteShellSession and reuse in terminalParity.ts and useComposerState.ts (was inlined 3 times) - useComposerState.ts: extract insertAtCursor helper, replacing 3 copies of the lead/tail spacing logic - useComposerState.ts: remove redundant gw from handleTextPaste useCallback dependency array - terminalSetup.test.ts: add EACCES (read-only keybindings.json) and unterminated block comment test coverage
This commit is contained in:
parent
bc9927dc50
commit
c9e8d82ef4
7 changed files with 95 additions and 42 deletions
|
|
@ -48,18 +48,21 @@ export function parseOsc52ClipboardData(data: string): null | string {
|
|||
}
|
||||
}
|
||||
|
||||
export async function readOsc52Clipboard(querier: null | OscQuerier): Promise<null | string> {
|
||||
export async function readOsc52Clipboard(querier: null | OscQuerier, timeoutMs = 500): Promise<null | string> {
|
||||
if (!querier) {
|
||||
return null
|
||||
}
|
||||
|
||||
const response = await querier.send<OscResponse>({
|
||||
const timeout = new Promise<undefined>(resolve => setTimeout(resolve, timeoutMs))
|
||||
const query = querier.send<OscResponse>({
|
||||
request: buildOsc52ClipboardQuery(),
|
||||
match: (r: unknown): r is OscResponse => {
|
||||
return !!r && typeof r === 'object' && (r as OscResponse).type === 'osc' && (r as OscResponse).code === 52
|
||||
}
|
||||
})
|
||||
|
||||
const response = await Promise.race([query, timeout])
|
||||
|
||||
await querier.flush()
|
||||
|
||||
return response ? parseOsc52ClipboardData(response.data) : null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue