mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-26 06:01:49 +00:00
fix(tui): restore clipboard hotkeys in clarify mode
This commit is contained in:
parent
8c9fdedaf5
commit
c3af012a35
4 changed files with 109 additions and 4 deletions
30
ui-tui/src/lib/clipboard.ts
Normal file
30
ui-tui/src/lib/clipboard.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import { spawnSync, type SpawnSyncOptions } from 'node:child_process'
|
||||
|
||||
const DEFAULT_SPAWN_OPTS: SpawnSyncOptions = {
|
||||
stdio: ['ignore', 'pipe', 'ignore'],
|
||||
encoding: 'utf8'
|
||||
}
|
||||
|
||||
/**
|
||||
* Read plain text from the system clipboard.
|
||||
*
|
||||
* On macOS this uses `pbpaste`. On other platforms we intentionally return
|
||||
* null for now; the TUI's text-paste hotkeys are primarily targeted at the
|
||||
* macOS clarify/input flow.
|
||||
*/
|
||||
export function readClipboardText(
|
||||
platform: NodeJS.Platform = process.platform,
|
||||
run = spawnSync
|
||||
): string | null {
|
||||
if (platform !== 'darwin') {
|
||||
return null
|
||||
}
|
||||
|
||||
const result = run('pbpaste', [], DEFAULT_SPAWN_OPTS)
|
||||
|
||||
if (result.status !== 0 || typeof result.stdout !== 'string') {
|
||||
return null
|
||||
}
|
||||
|
||||
return result.stdout
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue