Skip to content

The agent that grows with you

feat(tui): render native mode in terminal flow

brooklyn!d03e3aa390ae
diff --git a/ui-tui/src/app/useMainApp.ts b/ui-tui/src/app/useMainApp.ts
index a1bfc10ac22..a9003bafa0d 100644
--- a/ui-tui/src/app/useMainApp.ts
+++ b/ui-tui/src/app/useMainApp.ts
@@ -13,7 +13,7 @@ import { JSON_RPC_METHOD_NOT_FOUND, type ServerRequest } from '@hermes/shared/js
import { useStore } from '@nanostores/react'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
-import { DASHBOARD_TUI_MODE, STARTUP_RESUME_ID } from '../config/env.js'
+import { DASHBOARD_TUI_MODE, NATIVE_MODE, STARTUP_RESUME_ID } from '../config/env.js'
import { WHEEL_SCROLL_STEP } from '../config/limits.js'
import { RESIZE_COALESCE_MS } from '../config/timing.js'
import { hasLeadGap, prevRenderedMsg } from '../domain/blockLayout.js'
@@ -462,6 +462,7 @@ export function useMainApp(gw: GatewayClient) {
generation: historyGeneration,
initialHeights: activeHeightCache,
liveTailActive: turnLiveTailActive,
+ nativeMode: NATIVE_MODE,
onHeightsChange: syncHeightCache
})
diff --git a/ui-tui/src/components/appLayout.tsx b/ui-tui/src/components/appLayout.tsx
index de0f1dd172c..0b080b75100 100644
--- a/ui-tui/src/components/appLayout.tsx
+++ b/ui-tui/src/components/appLayout.tsx
@@ -11,7 +11,7 @@ import { $isBlocked, $overlayState, patchOverlayState } from '../app/overlayStor
import { $petBox } from '../app/petFlashStore.js'
import { $uiState } from '../app/uiStore.js'
import { usePet } from '../app/usePet.js'
-import { INLINE_MODE, SHOW_FPS, TERMUX_TUI_MODE } from '../config/env.js'
+import { INLINE_MODE, NATIVE_MODE, SHOW_FPS, TERMUX_TUI_MODE } from '../config/env.js'
import { PLACEHOLDER } from '../content/placeholders.js'
import { prevRenderedMsg } from '../domain/blockLayout.js'
import {
@@ -140,9 +140,10 @@ const PromptPrefix = memo(function PromptPrefix({
const TranscriptPane = memo(function TranscriptPane({
actions,
composer,
+ nativeMode,
progress,
transcript
-}: Pick<AppLayoutProps, 'actions' | 'composer' | 'progress' | 'transcript'>) {
+}: Pick<AppLayoutProps, 'actions' | 'composer' | 'progress' | 'transcript'> & { nativeMode: boolean }) {
const ui = useStore($uiState)
const petBox = useStore($petBox)
const railCols = useAmbientRailWidth('left') + useAmbientRailWidth('right')
@@ -152,7 +153,7 @@ const TranscriptPane = memo(function TranscriptPane({
// (as long as enough width is left for comfortable reading);
// - narrow terminals: keep full width and reserve bottom rows instead, so
// the newest lines sit above the pet rather than getting cramped.
- const useGutter = !!petBox && composer.cols - railCols - petBox.width >= MIN_GUTTER_BODY_COLS
+ const useGutter = !nativeMode && !!petBox && composer.cols - railCols - petBox.width >= MIN_GUTTER_BODY_COLS
const bodyCols = Math.max(28, (useGutter && petBox ? composer.cols - petBox.width : composer.cols) - railCols)
const petBandRows = petBox && !useGutter ? petBox.height : 0
@@ -180,32 +181,24 @@ const TranscriptPane = memo(function TranscriptPane({
[transcript.historyItems]
)
- return (
- <>
- <ScrollBox
- flexDirection="column"
- flexGrow={1}
- flexShrink={1}
- onClick={(e: { cellIsBlank?: boolean }) => {
- if (e.cellIsBlank) {
- actions.clearSelection()
- }
- }}
- ref={transcript.scrollRef}
- stickyScroll
- >
- <Box flexDirection="column" paddingX={1}>
- {transcript.virtualHistory.topSpacer > 0 ? <Box height={transcript.virtualHistory.topSpacer} /> : null}
-
- {transcript.virtualRows.slice(transcript.virtualHistory.start, transcript.virtualHistory.end).map(row => (
- <Box flexDirection="column" key={row.key} ref={transcript.virtualHistory.measureRef(row.key)}>
- {row.msg.role === 'user' && firstUserIdx >= 0 && row.index > firstUserIdx && (
- <Box marginTop={1}>
- <Text color={ui.theme.color.border}>───</Text>
- </Box>
- )}
+ const transcriptContent = (
+ <Box flexDirection="column" paddingX={1}>
+ {!nativeMode && transcript.virtualHistory.topSpacer > 0 ? (
+ <Box height={transcript.virtualHistory.topSpacer} />
+ ) : null}
+
+ {transcript.virtualRows
+ .slice(nativeMode ? 0 : transcript.virtualHistory.start, nativeMode ? undefined : transcript.virtualHistory.end)
+ .map(row => (
+ <Box flexDirection="column" key={row.key} ref={transcript.virtualHistory.measureRef(row.key)}>
+ {row.msg.role === 'user' && firstUserIdx >= 0 && row.index > firstUserIdx && (
+ <Box marginTop={1}>
+ <Text color={ui.theme.color.border}>───</Text>
+ </Box>
+ )}
- {row.msg.kind === 'intro' ? (
+ {row.msg.kind === 'intro' ? (
+ nativeMode ? null : (
<Box flexDirection="column" paddingTop={1}>
<Banner maxWidth={Math.max(1, composer.cols - 2)} t={ui.theme} />
@@ -218,57 +211,95 @@ const TranscriptPane = memo(function TranscriptPane({
/>
)}
</Box>
- ) : row.msg.kind === 'panel' && row.msg.panelData ? (
- <Panel sections={row.msg.panelData.sections} t={ui.theme} title={row.msg.panelData.title} />
- ) : (
- <MessageLine
- cols={bodyCols}
- compact={ui.compact}
- detailsMode={ui.detailsMode}
- detailsModeCommandOverride={ui.detailsModeCommandOverride}
- msg={row.msg}
- prev={prevRenderedMsg(i => transcript.virtualRows[i]?.msg, row.index, {
- commandOverride: ui.detailsModeCommandOverride,
- detailsMode: ui.detailsMode,
- sections: ui.sections
- })}
- sections={ui.sections}
- t={ui.theme}
- timestamps={ui.timestamps}
- />
- )}
+ )
+ ) : row.msg.kind === 'panel' && row.msg.panelData ? (
+ <Panel sections={row.msg.panelData.sections} t={ui.theme} title={row.msg.panelData.title} />
+ ) : (
+ <MessageLine
+ cols={bodyCols}
+ compact={ui.compact}
+ detailsMode={ui.detailsMode}
+ detailsModeCommandOverride={ui.detailsModeCommandOverride}
+ msg={row.msg}
+ prev={prevRenderedMsg(i => transcript.virtualRows[i]?.msg, row.index, {
+ commandOverride: ui.detailsModeCommandOverride,
+ detailsMode: ui.detailsMode,
+ sections: ui.sections
+ })}
+ sections={ui.sections}
+ t={ui.theme}
+ timestamps={ui.timestamps}
+ />
+ )}
- {row.index === lastUserIdx && <LiveTodoPanel />}
- </Box>
- ))}
-
- {transcript.virtualHistory.bottomSpacer > 0 ? <Box height={transcript.virtualHistory.bottomSpacer} /> : null}
-
- <StreamingAssistant
- cols={bodyCols}
- compact={ui.compact}
- detailsMode={ui.detailsMode}
- detailsModeCommandOverride={ui.detailsModeCommandOverride}
- prevMsg={transcript.historyItems[transcript.historyItems.length - 1]}
- progress={progress}
- sections={ui.sections}
- />
+ {row.index === lastUserIdx && <LiveTodoPanel />}
+ </Box>
+ ))}
+
+ {!nativeMode && transcript.virtualHistory.bottomSpacer > 0 ? (
+ <Box height={transcript.virtualHistory.bottomSpacer} />
+ ) : null}
+
+ <StreamingAssistant
+ cols={bodyCols}
+ compact={ui.compact}
+ detailsMode={ui.detailsMode}
+ detailsModeCommandOverride={ui.detailsModeCommandOverride}
+ prevMsg={transcript.historyItems[transcript.historyItems.length - 1]}
+ progress={progress}
+ sections={ui.sections}
+ />
+
+ {/* Narrow terminals: reserve rows so the newest lines sit above the pet. */}
+ {!nativeMode && petBandRows > 0 ? <Box height={petBandRows} /> : null}
+ </Box>
+ )
- {/* Narrow terminals: reserve rows so the newest lines sit above the pet. */}
- {petBandRows > 0 ? <Box height={petBandRows} /> : null}
+ return (
+ <>
+ {nativeMode ? (
+ <Box
+ flexDirection="column"
+ flexGrow={1}
+ onClick={(e: { cellIsBlank?: boolean }) => {
+ if (e.cellIsBlank) {
+ actions.clearSelection()
+ }
+ }}
+ >
+ {transcriptContent}
</Box>
- </ScrollBox>
+ ) : (
+ <ScrollBox
+ flexDirection="column"
+ flexGrow={1}
+ flexShrink={1}
+ onClick={(e: { cellIsBlank?: boolean }) => {
+ if (e.cellIsBlank) {
+ actions.clearSelection()
+ }
+ }}
+ ref={transcript.scrollRef}
+ stickyScroll
+ >
+ {transcriptContent}
+ </ScrollBox>
+ )}
- <NoSelect flexShrink={0} marginLeft={1}>
- <TranscriptScrollbar scrollRef={transcript.scrollRef} t={ui.theme} />
- </NoSelect>
+ {!nativeMode && (
+ <NoSelect flexShrink={0} marginLeft={1}>
+ <TranscriptScrollbar scrollRef={transcript.scrollRef} t={ui.theme} />
+ </NoSelect>
+ )}
- <StickyPromptTracker
- messages={transcript.historyItems}
- offsets={transcript.virtualHistory.offsets}
- onChange={actions.setStickyPrompt}
- scrollRef={transcript.scrollRef}
- />
+ {!nativeMode && (
+ <StickyPromptTracker
+ messages={transcript.historyItems}
+ offsets={transcript.virtualHistory.offsets}
+ onChange={actions.setStickyPrompt}
+ scrollRef={transcript.scrollRef}
+ />
+ )}
</>
)
})
@@ -277,9 +308,11 @@ const ComposerPane = memo(function ComposerPane({
actions,
composer,
cursorSnapshotRef,
+ nativeMode,
status
}: Pick<AppLayoutProps, 'actions' | 'composer' | 'status'> & {
cursorSnapshotRef: MutableRefObject<InputCursorSnapshot | null>
+ nativeMode: boolean
}) {
const ui = useStore($uiState)
const isBlocked = useStore($isBlocked)
@@ -370,24 +403,31 @@ const ComposerPane = memo(function ComposerPane({
<GoalBar cols={Math.max(1, composer.cols - 2)} />
<LiveAgentsPanel cols={Math.max(1, composer.cols - 2)} />
- <StatusRulePane at="top" composer={composer} status={status} />
+ <StatusRulePane at="top" composer={composer} nativeMode={nativeMode} status={status} />
<AmbientDock placement="dock-top" />
- <Box flexDirection="column" marginTop={ui.statusBar === 'top' ? 0 : 1} position="relative">
- <FloatingOverlays
- cols={composer.cols}
- compIdx={composer.compIdx}
- completions={composer.completions}
- onActiveSessionClose={actions.closeLiveSession}
- onActiveSessionSelect={actions.activateLiveSession}
- onModelSelect={actions.onModelSelect}
- onNewLiveSession={actions.newLiveSession}
- onNewPromptSession={actions.newPromptSession}
- onResumeSelect={actions.resumeById}
- pagerPageSize={composer.pagerPageSize}
- />
+ <Box
+ flexDirection="column"
+ marginTop={nativeMode ? 0 : ui.statusBar === 'top' ? 0 : 1}
+ position={nativeMode ? undefined : 'relative'}
+ >
+ {!nativeMode && (
+ <FloatingOverlays
+ cols={composer.cols}
+ compIdx={composer.compIdx}
+ completions={composer.completions}
+ nativeMode={false}
+ onActiveSessionClose={actions.closeLiveSession}
+ onActiveSessionSelect={actions.activateLiveSession}
+ onModelSelect={actions.onModelSelect}
+ onNewLiveSession={actions.newLiveSession}
+ onNewPromptSession={actions.newPromptSession}
+ onResumeSelect={actions.resumeById}
+ pagerPageSize={composer.pagerPageSize}
+ />
+ )}
- {composer.input === '?' && !composer.inputBuf.length && <HelpHint t={ui.theme} />}
+ {!nativeMode && composer.input === '?' && !composer.inputBuf.length && <HelpHint t={ui.theme} />}
{!isBlocked && (
<>
@@ -453,10 +493,28 @@ const ComposerPane = memo(function ComposerPane({
)}
</Box>
+ {nativeMode && (
+ <FloatingOverlays
+ cols={composer.cols}
+ compIdx={composer.compIdx}
+ completions={composer.completions}
+ nativeMode
+ onActiveSessionClose={actions.closeLiveSession}
+ onActiveSessionSelect={actions.activateLiveSession}
+ onModelSelect={actions.onModelSelect}
+ onNewLiveSession={actions.newLiveSession}
+ onNewPromptSession={actions.newPromptSession}
+ onResumeSelect={actions.resumeById}
+ pagerPageSize={composer.pagerPageSize}
+ />
+ )}
+
+ {nativeMode && composer.input === '?' && !composer.inputBuf.length && <HelpHint nativeMode t={ui.theme} />}
+
{!composer.empty && !ui.sid && <Text color={ui.theme.color.muted}>☤ {ui.status}</Text>}
<AmbientDock placement="dock-bottom" />
- <StatusRulePane at="bottom" composer={composer} status={status} />
+ <StatusRulePane at="bottom" composer={composer} nativeMode={nativeMode} status={status} />
</NoSelect>
)
})
@@ -486,11 +544,12 @@ const JourneyPane = memo(function JourneyPane() {
const StatusRulePane = memo(function StatusRulePane({
at,
composer,
+ nativeMode,
status
-}: Pick<AppLayoutProps, 'composer' | 'status'> & { at: 'bottom' | 'top' }) {
+}: Pick<AppLayoutProps, 'composer' | 'status'> & { at: 'bottom' | 'top'; nativeMode: boolean }) {
const ui = useStore($uiState)
- if (ui.statusBar !== at) {
+ if (ui.statusBar === 'off' || (nativeMode ? at !== 'top' : ui.statusBar !== at)) {
return null
}
@@ -551,7 +610,7 @@ export const AppLayout = memo(function AppLayout({
return (
<Shell {...shellProps}>
- <Box flexDirection="column" flexGrow={1} position="relative">
+ <Box flexDirection="column" flexGrow={1} position={NATIVE_MODE ? undefined : 'relative'}>
<Box flexDirection="row" flexGrow={1}>
{!overlay.agents && !overlay.journey && <AmbientRail side="left" />}
{overlay.agents ? (
@@ -564,7 +623,13 @@ export const AppLayout = memo(function AppLayout({
</PerfPane>
) : (
<PerfPane id="transcript">
- <TranscriptPane actions={actions} composer={composer} progress={progress} transcript={transcript} />
+ <TranscriptPane
+ actions={actions}
+ composer={composer}
+ nativeMode={NATIVE_MODE}
+ progress={progress}
+ transcript={transcript}
+ />
</PerfPane>
)}
{!overlay.agents && !overlay.journey && <AmbientRail side="right" />}
@@ -589,6 +654,7 @@ export const AppLayout = memo(function AppLayout({
actions={actions}
composer={composer}
cursorSnapshotRef={cursorSnapshotRef}
+ nativeMode={NATIVE_MODE}
status={status}
/>
</PerfPane>
@@ -601,7 +667,7 @@ export const AppLayout = memo(function AppLayout({
</>
)}
- {!overlay.agents && <PetPane />}
+ {!overlay.agents && !NATIVE_MODE && <PetPane />}
</Box>
<ActiveWidgetSlot />
diff --git a/ui-tui/src/components/appOverlays.tsx b/ui-tui/src/components/appOverlays.tsx
index 21c66fcd1b8..5da45ffe6ca 100644
--- a/ui-tui/src/components/appOverlays.tsx
+++ b/ui-tui/src/components/appOverlays.tsx
@@ -202,6 +202,7 @@ export function FloatingOverlays({
cols,
compIdx,
completions,
+ nativeMode = false,
onActiveSessionSelect,
onActiveSessionClose,
onModelSelect,
@@ -221,7 +222,7 @@ export function FloatingOverlays({
| 'onNewPromptSession'
| 'onResumeSelect'
| 'pagerPageSize'
->) {
+> & { nativeMode?: boolean }) {
const { gw } = useGateway()
const overlay = useStore($overlayState)
const sid = useStore($uiSessionId)
@@ -412,9 +413,15 @@ export function FloatingOverlays({
})
}
- return (
+ const grid = <WidgetGrid cols={cols} columns={1} gap={0} paddingX={0} paddingY={0} rowGap={0} widgets={widgets} />
+
+ return nativeMode ? (
+ <Box alignItems="flex-start" flexDirection="column" marginBottom={1} width="100%">
+ {grid}
+ </Box>
+ ) : (
<Box alignItems="flex-start" bottom="100%" flexDirection="column" left={0} position="absolute" right={0}>
- <WidgetGrid cols={cols} columns={1} gap={0} paddingX={0} paddingY={0} rowGap={0} widgets={widgets} />
+ {grid}
</Box>
)
}
diff --git a/ui-tui/src/components/helpHint.tsx b/ui-tui/src/components/helpHint.tsx
index 997e093b53b..eb9c7313a78 100644
--- a/ui-tui/src/components/helpHint.tsx
+++ b/ui-tui/src/components/helpHint.tsx
@@ -14,13 +14,17 @@ const COMMON_COMMANDS: [string, string][] = [
const HOTKEY_PREVIEW = HOTKEYS.slice(0, 8)
-export function HelpHint({ t }: { t: Theme }) {
+export function HelpHint({ nativeMode = false, t }: { nativeMode?: boolean; t: Theme }) {
const labelW = Math.max(...COMMON_COMMANDS.map(([k]) => k.length), ...HOTKEY_PREVIEW.map(([k]) => k.length))
const pad = (s: string) => s + ' '.repeat(Math.max(0, labelW - s.length + 2))
return (
- <Box alignItems="flex-start" bottom="100%" flexDirection="column" left={0} position="absolute" right={0}>
+ <Box
+ alignItems="flex-start"
+ {...(nativeMode ? {} : { bottom: '100%', left: 0, position: 'absolute' as const, right: 0 })}
+ flexDirection="column"
+ >
<Box
alignSelf="flex-start"
borderColor={t.color.primary}
diff --git a/ui-tui/src/config/env.ts b/ui-tui/src/config/env.ts
index 90c2f168667..0c4ada42f0d 100644
--- a/ui-tui/src/config/env.ts
+++ b/ui-tui/src/config/env.ts
@@ -47,8 +47,11 @@ export const STARTUP_WORKSPACE_CWD = (process.env.HERMES_TUI_CWD ?? '').trim()
// behavior.
const mouseTrackingOverride = parseToggle(process.env.HERMES_TUI_MOUSE_TRACKING)
const mouseTrackingDisabledLegacy = truthy(process.env.HERMES_TUI_DISABLE_MOUSE)
+export const NATIVE_MODE = truthy(process.env.HERMES_TUI_NATIVE)
-const resolvedBootMouseEnabled = mouseTrackingOverride ?? (TERMUX_TUI_MODE ? false : !mouseTrackingDisabledLegacy)
+const resolvedBootMouseEnabled = NATIVE_MODE
+ ? false
+ : (mouseTrackingOverride ?? (TERMUX_TUI_MODE ? false : !mouseTrackingDisabledLegacy))
export const MOUSE_TRACKING: MouseTrackingMode = resolvedBootMouseEnabled ? 'all' : 'off'
@@ -71,7 +74,7 @@ const inlineOverride = parseToggle(process.env.HERMES_TUI_INLINE)
// On Termux we default this on: users often background/foreground the app,
// and primary-buffer rendering makes long-thread review and copy/paste much
// less fragile. Override explicitly with HERMES_TUI_INLINE=0/1.
-export const INLINE_MODE: boolean = inlineOverride ?? TERMUX_TUI_MODE
+export const INLINE_MODE: boolean = NATIVE_MODE || (inlineOverride ?? TERMUX_TUI_MODE)
// Live FPS counter overlay, fed by ink's onFrame (real render rate, not a
// synthetic timer).
diff --git a/ui-tui/src/entry.tsx b/ui-tui/src/entry.tsx
index 79bc67daf58..b055bbde431 100644
--- a/ui-tui/src/entry.tsx
+++ b/ui-tui/src/entry.tsx
@@ -6,14 +6,14 @@ import './lib/forceTruecolor.js'
import type { FrameEvent } from '@hermes/ink'
import { setRpcErrorLogSink } from './app/userMessages.js'
-import { DASHBOARD_TUI_MODE, TERMUX_TUI_MODE } from './config/env.js'
+import { DASHBOARD_TUI_MODE, NATIVE_MODE, TERMUX_TUI_MODE } from './config/env.js'
import { GatewayClient } from './gatewayClient.js'
import { setupGracefulExit } from './lib/gracefulExit.js'
import { formatBytes, type HeapDumpResult, performHeapDump } from './lib/memory.js'
import { type MemorySnapshot, startMemoryMonitor } from './lib/memoryMonitor.js'
import { openExternalUrl } from './lib/openExternalUrl.js'
import { recordParentLifecycle } from './lib/parentLog.js'
-import { resetTerminalModes } from './lib/terminalModes.js'
+import { NATIVE_TUI_EXIT_RESET, resetTerminalModes } from './lib/terminalModes.js'
if (!process.stdin.isTTY) {
console.log('hermes-tui: no TTY')
@@ -38,12 +38,19 @@ resetTerminalModes()
// graceful-exit cleanups is safe.
process.on('exit', () => {
resetTerminalModes()
+ if (NATIVE_MODE) {
+ try {
+ process.stdout.write(NATIVE_TUI_EXIT_RESET)
+ } catch {
+ // stdout may already be closed during terminal teardown.
+ }
+ }
})
// Desktop terminals benefit from a clean startup slate because the TUI usually
// runs in AlternateScreen. On Termux we keep prior output intact so users can
// review/copy earlier assistant replies after reopening the app.
-if (TERMUX_TUI_MODE) {
+if (TERMUX_TUI_MODE || NATIVE_MODE) {
process.stdout.write('\n')
} else {
process.stdout.write('\x1b[2J\x1b[H\x1b[3J')
diff --git a/ui-tui/src/hooks/useVirtualHistory.ts b/ui-tui/src/hooks/useVirtualHistory.ts
index c9b760a00e8..817a06321ee 100644
--- a/ui-tui/src/hooks/useVirtualHistory.ts
+++ b/ui-tui/src/hooks/useVirtualHistory.ts
@@ -148,7 +148,8 @@ export function useVirtualHistory(
onHeightsChange,
overscan = OVERSCAN,
maxMounted = MAX_MOUNTED,
- coldStartCount = COLD_START
+ coldStartCount = COLD_START,
+ nativeMode = false
}: VirtualHistoryOptions = {}
) {
const nodes = useRef(new Map<string, unknown>())
@@ -325,7 +326,13 @@ export function useVirtualHistory(
let start = 0
let end = n
- if (frozenRange) {
+ if (nativeMode) {
+ // Native mode deliberately leaves the transcript in ordinary document
+ // flow. The terminal owns scrollback; there is no viewport window to
+ // virtualize or reconcile against.
+ start = 0
+ end = n
+ } else if (frozenRange) {
start = frozenRange[0]
end = Math.min(frozenRange[1], n)
} else if (n > 0) {
@@ -360,7 +367,7 @@ export function useVirtualHistory(
}
}
- if (end - start > maxMounted) {
+ if (!nativeMode && end - start > maxMounted) {
sticky ? (start = Math.max(0, end - maxMounted)) : (end = Math.min(n, start + maxMounted))
}
@@ -368,7 +375,7 @@ export function useVirtualHistory(
// viewportH + 2*overscan so the viewport is physically covered even when
// items are tiny. Pessimistic because uncached items use a floor of 1 —
// over-mounts when items are large, never leaves blank spacer showing.
- if (n > 0 && vp > 0 && !frozenRange) {
+ if (!nativeMode && n > 0 && vp > 0 && !frozenRange) {
const needed = vp + 2 * overscan
let coverage = 0
@@ -400,7 +407,7 @@ export function useVirtualHistory(
// PageUp skips this; the clamp holds the viewport at the mounted edge
// during catch-up so there's no blank screen. Only caps range GROWTH;
// shrinking is unbounded.
- if (!frozenRange && prevRange.current && vp > 0) {
+ if (!nativeMode && !frozenRange && prevRange.current && vp > 0) {
const velocity = Math.abs(top - lastScrollTopRef.current) + Math.abs(pendingDelta)
if (velocity > vp * 2) {
@@ -555,6 +562,10 @@ export function useVirtualHistory(
let heightDirty = false
let anchorDelta = 0
+ if (nativeMode) {
+ return
+ }
+
// Give the renderer the mounted-row coverage for passive scroll clamping.
// Clamp MUST use the EFFECTIVE (deferred) range, not the immediate one.
// During fast scroll, immediate [start,end] may already cover the new
@@ -660,7 +671,21 @@ export function useVirtualHistory(
if (heightDirty) {
bumpMeasuredHeightVersion(n => n + 1)
}
- }, [effEnd, effStart, items, liveTailActive, measuredHeightVersion, n, offsets, scrollRef, sticky, top, total, vp])
+ }, [
+ effEnd,
+ effStart,
+ items,
+ liveTailActive,
+ measuredHeightVersion,
+ n,
+ nativeMode,
+ offsets,
+ scrollRef,
+ sticky,
+ top,
+ total,
+ vp
+ ])
return {
bottomSpacer: Math.max(0, total - (offsets[effEnd] ?? total)),
@@ -686,4 +711,5 @@ interface VirtualHistoryOptions {
maxMounted?: number
onHeightsChange?: (heights: ReadonlyMap<string, number>) => void
overscan?: number
+ nativeMode?: boolean
}
diff --git a/ui-tui/src/lib/terminalModes.ts b/ui-tui/src/lib/terminalModes.ts
index 5a7428fa82f..5b7f99bb3b1 100644
--- a/ui-tui/src/lib/terminalModes.ts
+++ b/ui-tui/src/lib/terminalModes.ts
@@ -21,6 +21,8 @@ export const TERMINAL_MODE_RESET =
'\x1b[0m' + // attributes
'\x1b[?25h' // cursor visible
+export const NATIVE_TUI_EXIT_RESET = '\x1b[2J\x1b[H'
+
type ResettableStream = Pick<NodeJS.WriteStream, 'isTTY' | 'write'> & {
fd?: number
}