mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-08 13:12:08 +00:00
Bring apps/desktop and ui-tui to a clean state for typecheck, eslint,
and prettier:
- Run prettier across both trees (printWidth/wrap drift; prettier is not
CI-enforced for these JS projects, so main had accumulated drift).
- Apply eslint --fix for padding-line-between-statements and perfectionist
import/export sorting.
- Manual fixes for non-auto-fixable rules:
- remove unused node:net import in electron/main.cjs (uses Electron net)
- replace inline `typeof import(...)` annotations with top-level
`import type * as EnvModule` in two ui-tui test files
- scoped eslint-disable no-control-regex on intentional sentinel/ANSI
regexes (mathUnicode.ts, text.ts)
- resolve react-hooks/exhaustive-deps per-case: correct swapped/missing
deps, collapse redundant session.* members, and justified disables on
settings mount-only data-load effects to preserve run-once behavior
No behavior changes; test pass/fail counts are unchanged from the main
baseline.
52 lines
2.5 KiB
TypeScript
52 lines
2.5 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { shouldPassThroughToGlobalHandler, shouldPreserveCtrlJNewline } from '../components/textInput.js'
|
|
import { DEFAULT_VOICE_RECORD_KEY, parseVoiceRecordKey } from '../lib/platform.js'
|
|
|
|
const key = (overrides: Record<string, unknown> = {}) => ({ ctrl: false, meta: false, ...overrides }) as any
|
|
|
|
describe('shouldPreserveCtrlJNewline', () => {
|
|
it('preserves Ctrl+J as newline in Ghostty even when tmux masks TERM/TERM_PROGRAM', () => {
|
|
expect(
|
|
shouldPreserveCtrlJNewline({
|
|
GHOSTTY_RESOURCES_DIR: '/usr/share/ghostty',
|
|
TERM: 'tmux-256color',
|
|
TERM_PROGRAM: 'tmux'
|
|
})
|
|
).toBe(true)
|
|
})
|
|
|
|
it('keeps bare local POSIX LF-compatible prompts submitting on Ctrl+J', () => {
|
|
expect(shouldPreserveCtrlJNewline({ TERM: 'xterm-256color' })).toBe(false)
|
|
})
|
|
})
|
|
|
|
describe('shouldPassThroughToGlobalHandler', () => {
|
|
it('passes through the configured voice shortcut while composer is focused', () => {
|
|
expect(shouldPassThroughToGlobalHandler('o', key({ ctrl: true }), parseVoiceRecordKey('ctrl+o'))).toBe(true)
|
|
expect(shouldPassThroughToGlobalHandler('r', key({ meta: true }), parseVoiceRecordKey('alt+r'))).toBe(true)
|
|
expect(shouldPassThroughToGlobalHandler(' ', key({ ctrl: true }), parseVoiceRecordKey('ctrl+space'))).toBe(true)
|
|
expect(
|
|
shouldPassThroughToGlobalHandler('', key({ ctrl: true, return: true }), parseVoiceRecordKey('ctrl+enter'))
|
|
).toBe(true)
|
|
})
|
|
|
|
it('keeps the legacy default pass-through when no custom key is provided', () => {
|
|
expect(shouldPassThroughToGlobalHandler('b', key({ ctrl: true }), DEFAULT_VOICE_RECORD_KEY)).toBe(true)
|
|
expect(shouldPassThroughToGlobalHandler('b', key({ ctrl: true }))).toBe(true)
|
|
})
|
|
|
|
it('does not swallow ordinary typing keys', () => {
|
|
expect(shouldPassThroughToGlobalHandler('h', key(), parseVoiceRecordKey('ctrl+o'))).toBe(false)
|
|
expect(shouldPassThroughToGlobalHandler('o', key(), parseVoiceRecordKey('ctrl+o'))).toBe(false)
|
|
})
|
|
|
|
it('always passes through non-voice global control keys', () => {
|
|
expect(shouldPassThroughToGlobalHandler('c', key({ ctrl: true }))).toBe(true)
|
|
expect(shouldPassThroughToGlobalHandler('x', key({ ctrl: true }))).toBe(true)
|
|
expect(shouldPassThroughToGlobalHandler('', key({ escape: true }))).toBe(true)
|
|
expect(shouldPassThroughToGlobalHandler('', key({ tab: true }))).toBe(true)
|
|
expect(shouldPassThroughToGlobalHandler('', key({ pageUp: true }))).toBe(true)
|
|
expect(shouldPassThroughToGlobalHandler('', key({ pageDown: true }))).toBe(true)
|
|
})
|
|
})
|