hermes-agent/ui-tui/src/lib/termux.ts
Brooklyn Nicholson 62fe9fd101 style(desktop,tui): fix all lint/type/formatting issues
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.
2026-06-26 01:04:33 -05:00

31 lines
818 B
TypeScript

const TERMUX_PREFIX = '/data/data/com.termux/files/usr'
const truthy = (value?: string) => /^(?:1|true|yes|on)$/i.test(String(value ?? '').trim())
export const isTermuxEnv = (env: NodeJS.ProcessEnv = process.env): boolean => {
const prefix = String(env.PREFIX ?? '')
return Boolean(env.TERMUX_VERSION) || prefix.includes(TERMUX_PREFIX)
}
/**
* Return true when Hermes should enable Termux-focused TUI defaults.
*
* Defaults to on in Termux, with an explicit opt-out for debugging:
* HERMES_TUI_TERMUX_MODE=0
*/
export const isTermuxTuiMode = (env: NodeJS.ProcessEnv = process.env): boolean => {
if (!isTermuxEnv(env)) {
return false
}
const override = String(env.HERMES_TUI_TERMUX_MODE ?? '')
.trim()
.toLowerCase()
if (override) {
return truthy(override)
}
return true
}