Files
hermes-agent/tests/hermes_cli/test_tui_npm_install.py

106 lines
3.8 KiB
Python
Raw Normal View History

fix(tui): mouse + keyboard text selection in the composer (#16732) * feat(tui): auto copy-on-select for transcript text Drag in the transcript already highlighted but you had to press Cmd+C to land it on the clipboard, and the highlight cleared on copy — most users never realised selection existed. Now drag-release fires copySelectionNoClear so the text is on the clipboard immediately while the highlight stays put, matching iTerm2's "Copy to pasteboard on selection" default. Esc clears. Behaviour: - Single click in the input still positions the cursor (TextInput onClick). - Single click in the transcript still does nothing destructive. - Double / triple click select word / line, then drag extends. - /copyselect [on|off|toggle] (alias /cos) flips the setting at runtime, HERMES_TUI_DISABLE_COPY_ON_SELECT=1 disables at startup, persists via display.tui_copy_on_select in config.yaml. Help overlay now lists drag-select, multi-click, and click-to-position so the gestures are discoverable. Made-with: Cursor * fix(tui): support prompt text selection gestures Add mouse drag selection and Shift+Arrow/Home/End extension inside the TUI composer so prompt text behaves like a normal editable field while keeping click-to-position and right-click paste intact. Made-with: Cursor * Revert "feat(tui): auto copy-on-select for transcript text" This reverts commit 6701288fe07a53af873e1ef53855a9618d733327. * fix(tui): allow composer selection from prompt whitespace Give the composer a one-cell mouse capture pad before the editable text. The prompt glyph/gutter still does not become selectable, but dragging from the edge now anchors at input offset 0 so users do not need to hit the first character precisely. Made-with: Cursor * fix(tui): clear selections from blank composer space Clicking blank space in the transcript or composer now clears active TUI/input selections like a normal text surface. TextInput clicks stop bubbling so cursor placement and selection gestures keep their local behavior. Made-with: Cursor * fix(tui): delegate prompt gutter drags to composer text The prompt gutter is now an input gesture region, not selectable content. Dragging from the whitespace or prompt area anchors the composer selection at offset 0, while selection highlight/copy remains limited to actual input text. Made-with: Cursor * fix(tui): move composer cursor to end on selection clear External clear actions now collapse the composer selection to the end of the input, matching normal text-field behavior after dismissing a selection. Made-with: Cursor * fix(tui): capture composer padding before prompt Add an explicit mouse capture cell over the left padding before the prompt glyph. Drags starting there now delegate to the composer input at offset 0 instead of starting terminal-level selection over the prompt chrome. Made-with: Cursor * fix(tui): avoid npm install on lockfile mtime churn Compare package-lock.json against npm's hidden node_modules lock by content instead of mtimes. Git checkouts and npm lock rewrites can make the root lockfile newer even when installed dependencies already match, causing hermes --tui to print Installing TUI dependencies on every launch. Made-with: Cursor * fix(tui): include prompt leading cell in gesture region Use the prompt box's real layout region to cover the leading whitespace cell before the glyph. The cell now participates in mouse hit testing and delegates to composer selection instead of starting terminal-level selection. Made-with: Cursor * fix(tui): widen prompt-side gesture capture band Capture a wider left-side band around the composer prompt row so drags starting in terminal gutter/padding cells are consumed and delegated to input selection, instead of triggering terminal-level selection chrome. Made-with: Cursor * fix(tui): make pre-prompt spacer non-selectable content Replace the sticky-prompt fallback `Text(' ')` with an empty spacer box so the visual gap remains but no literal space character is rendered/copyable before the composer prompt. Made-with: Cursor * fix(tui): capture pre-prompt spacer without shifting prompt layout Revert the widened negative-margin prompt capture band and instead capture drags on the dedicated spacer row above the prompt. This keeps prompt/text alignment stable while still delegating whitespace-start drags to composer selection. Made-with: Cursor * fix(tui): align prompt with status bar and capture full input row Drop the leading prompt column from 3 to 2 so the input first character lines up with the status bar text. Wrap the prompt+input row in a single mouse-capture box and stop event propagation from TextInput's own handlers so any drag in that row delegates to composer selection without leaking to terminal-level selection. Made-with: Cursor * fix(tui): anchor hardware cursor during composer selection When a composer selection covers a row exactly the column width, the rendered text fills the row and the terminal auto-wraps the hardware cursor to col 0 of the next row, leaving a ghost block beneath the prompt. Park the cursor at the start of the input box during selection so it can't escape the input region. Made-with: Cursor * fix(tui): hide hardware cursor during composer selection Stop fighting auto-wrap by hiding the hardware cursor outright while the composer has an active selection. This prevents both the ghost block under the prompt (cursor wrapping past the last cell) and the parked-cursor block on the first selected character. The cursor restores as soon as the selection clears or focus changes. Made-with: Cursor * chore(tui): /clean — drop dead capture-pad path, dedupe gutter handlers - TextInput: remove unused leftCaptureColumns prop and capture-pad math, drop unused mouseApi.startAt, fold mouse offset into a single offsetAt helper, share a MouseEventLite type across the four handlers. - appLayout: hoist a GutterMouseEvent type and an endInputDrag callback so the spacer/prompt/input rows share one shape. - _tui_need_npm_install: lift the runtime-only key set to a module constant, collapse nested isinstance checks, and document the mtime fallback. Made-with: Cursor * fix(tui): address copilot review on PR #16732 - Split InputSelection.clear() into clear() (cursor-preserving) and collapseToEnd() (clear + jump to end). Cmd+C copy paths keep using clear() so the cursor stays put; the blank-area click in useMainApp switches to collapseToEnd() to match the requested UX. - Spacer-row drags now force row=0 when forwarding into the input, since the spacer's vertical origin doesn't align with the input box and Ink mouse-capture keeps dispatching motion to the original target. Prompt+input row drag keeps localRow because origins match. Made-with: Cursor * fix(tui): give TextInput Box an explicit width After the /clean pass dropped the unused capture-pad math, the wrapping Box also lost its explicit width and started sizing to its rendered content. Clicks past the last character missed TextInput and fell through to the parent prompt-row Box, which collapsed the cursor to offset 0. Pin the Box back to `columns` so the input owns its full column span regardless of value length. Made-with: Cursor * feat(tui): double-click select-all + hide cursor on terminal blur - Track click time/offset in TextInput so a quick second click on the same offset triggers select-all. Ink's screen-level multi-click is bypassed once our onMouseDown captures, so the gesture has to be detected locally. - Extend the cursor-hide effect to also fire when the terminal loses focus, so the hollow-rect ghost most terminals draw at the parked cursor position disappears too. Made-with: Cursor * chore(tui): /clean — extract isMultiClickAt helper Pull the click-recurrence math out of TextInput's onMouseDown into a small isMultiClickAt(offset) helper so the handler reads as the gesture list it actually is (multi-click → select-all, otherwise start). Drop the redundant length>0 guard now that selectAll() already noops on an empty value. Made-with: Cursor * docs(tui): explain _tui_need_npm_install content-vs-mtime comparison Expand the docstring so future readers understand why we parse the lockfiles instead of comparing mtimes, what the optional/peer skip covers, how stale hidden-lock entries are handled, and when we fall back to mtime.
2026-04-27 16:43:48 -07:00
"""_tui_need_npm_install: auto npm when node_modules is behind the lockfile."""
2026-04-15 10:23:15 -05:00
import os
from pathlib import Path
import pytest
@pytest.fixture
def main_mod():
import hermes_cli.main as m
return m
def _touch_ink(root: Path) -> None:
ink = root / "node_modules" / "@hermes" / "ink" / "package.json"
ink.parent.mkdir(parents=True, exist_ok=True)
ink.write_text("{}")
def _touch_tui_entry(root: Path) -> None:
entry = root / "dist" / "entry.js"
entry.parent.mkdir(parents=True, exist_ok=True)
entry.write_text("console.log('tui')")
def _touch_ink_bundle(root: Path) -> None:
bundle = root / "packages" / "hermes-ink" / "dist" / "ink-bundle.js"
bundle.parent.mkdir(parents=True, exist_ok=True)
bundle.write_text("export {}")
2026-04-15 10:23:15 -05:00
def test_need_install_when_ink_missing(tmp_path: Path, main_mod) -> None:
(tmp_path / "package-lock.json").write_text("{}")
assert main_mod._tui_need_npm_install(tmp_path) is True
fix(tui): mouse + keyboard text selection in the composer (#16732) * feat(tui): auto copy-on-select for transcript text Drag in the transcript already highlighted but you had to press Cmd+C to land it on the clipboard, and the highlight cleared on copy — most users never realised selection existed. Now drag-release fires copySelectionNoClear so the text is on the clipboard immediately while the highlight stays put, matching iTerm2's "Copy to pasteboard on selection" default. Esc clears. Behaviour: - Single click in the input still positions the cursor (TextInput onClick). - Single click in the transcript still does nothing destructive. - Double / triple click select word / line, then drag extends. - /copyselect [on|off|toggle] (alias /cos) flips the setting at runtime, HERMES_TUI_DISABLE_COPY_ON_SELECT=1 disables at startup, persists via display.tui_copy_on_select in config.yaml. Help overlay now lists drag-select, multi-click, and click-to-position so the gestures are discoverable. Made-with: Cursor * fix(tui): support prompt text selection gestures Add mouse drag selection and Shift+Arrow/Home/End extension inside the TUI composer so prompt text behaves like a normal editable field while keeping click-to-position and right-click paste intact. Made-with: Cursor * Revert "feat(tui): auto copy-on-select for transcript text" This reverts commit 6701288fe07a53af873e1ef53855a9618d733327. * fix(tui): allow composer selection from prompt whitespace Give the composer a one-cell mouse capture pad before the editable text. The prompt glyph/gutter still does not become selectable, but dragging from the edge now anchors at input offset 0 so users do not need to hit the first character precisely. Made-with: Cursor * fix(tui): clear selections from blank composer space Clicking blank space in the transcript or composer now clears active TUI/input selections like a normal text surface. TextInput clicks stop bubbling so cursor placement and selection gestures keep their local behavior. Made-with: Cursor * fix(tui): delegate prompt gutter drags to composer text The prompt gutter is now an input gesture region, not selectable content. Dragging from the whitespace or prompt area anchors the composer selection at offset 0, while selection highlight/copy remains limited to actual input text. Made-with: Cursor * fix(tui): move composer cursor to end on selection clear External clear actions now collapse the composer selection to the end of the input, matching normal text-field behavior after dismissing a selection. Made-with: Cursor * fix(tui): capture composer padding before prompt Add an explicit mouse capture cell over the left padding before the prompt glyph. Drags starting there now delegate to the composer input at offset 0 instead of starting terminal-level selection over the prompt chrome. Made-with: Cursor * fix(tui): avoid npm install on lockfile mtime churn Compare package-lock.json against npm's hidden node_modules lock by content instead of mtimes. Git checkouts and npm lock rewrites can make the root lockfile newer even when installed dependencies already match, causing hermes --tui to print Installing TUI dependencies on every launch. Made-with: Cursor * fix(tui): include prompt leading cell in gesture region Use the prompt box's real layout region to cover the leading whitespace cell before the glyph. The cell now participates in mouse hit testing and delegates to composer selection instead of starting terminal-level selection. Made-with: Cursor * fix(tui): widen prompt-side gesture capture band Capture a wider left-side band around the composer prompt row so drags starting in terminal gutter/padding cells are consumed and delegated to input selection, instead of triggering terminal-level selection chrome. Made-with: Cursor * fix(tui): make pre-prompt spacer non-selectable content Replace the sticky-prompt fallback `Text(' ')` with an empty spacer box so the visual gap remains but no literal space character is rendered/copyable before the composer prompt. Made-with: Cursor * fix(tui): capture pre-prompt spacer without shifting prompt layout Revert the widened negative-margin prompt capture band and instead capture drags on the dedicated spacer row above the prompt. This keeps prompt/text alignment stable while still delegating whitespace-start drags to composer selection. Made-with: Cursor * fix(tui): align prompt with status bar and capture full input row Drop the leading prompt column from 3 to 2 so the input first character lines up with the status bar text. Wrap the prompt+input row in a single mouse-capture box and stop event propagation from TextInput's own handlers so any drag in that row delegates to composer selection without leaking to terminal-level selection. Made-with: Cursor * fix(tui): anchor hardware cursor during composer selection When a composer selection covers a row exactly the column width, the rendered text fills the row and the terminal auto-wraps the hardware cursor to col 0 of the next row, leaving a ghost block beneath the prompt. Park the cursor at the start of the input box during selection so it can't escape the input region. Made-with: Cursor * fix(tui): hide hardware cursor during composer selection Stop fighting auto-wrap by hiding the hardware cursor outright while the composer has an active selection. This prevents both the ghost block under the prompt (cursor wrapping past the last cell) and the parked-cursor block on the first selected character. The cursor restores as soon as the selection clears or focus changes. Made-with: Cursor * chore(tui): /clean — drop dead capture-pad path, dedupe gutter handlers - TextInput: remove unused leftCaptureColumns prop and capture-pad math, drop unused mouseApi.startAt, fold mouse offset into a single offsetAt helper, share a MouseEventLite type across the four handlers. - appLayout: hoist a GutterMouseEvent type and an endInputDrag callback so the spacer/prompt/input rows share one shape. - _tui_need_npm_install: lift the runtime-only key set to a module constant, collapse nested isinstance checks, and document the mtime fallback. Made-with: Cursor * fix(tui): address copilot review on PR #16732 - Split InputSelection.clear() into clear() (cursor-preserving) and collapseToEnd() (clear + jump to end). Cmd+C copy paths keep using clear() so the cursor stays put; the blank-area click in useMainApp switches to collapseToEnd() to match the requested UX. - Spacer-row drags now force row=0 when forwarding into the input, since the spacer's vertical origin doesn't align with the input box and Ink mouse-capture keeps dispatching motion to the original target. Prompt+input row drag keeps localRow because origins match. Made-with: Cursor * fix(tui): give TextInput Box an explicit width After the /clean pass dropped the unused capture-pad math, the wrapping Box also lost its explicit width and started sizing to its rendered content. Clicks past the last character missed TextInput and fell through to the parent prompt-row Box, which collapsed the cursor to offset 0. Pin the Box back to `columns` so the input owns its full column span regardless of value length. Made-with: Cursor * feat(tui): double-click select-all + hide cursor on terminal blur - Track click time/offset in TextInput so a quick second click on the same offset triggers select-all. Ink's screen-level multi-click is bypassed once our onMouseDown captures, so the gesture has to be detected locally. - Extend the cursor-hide effect to also fire when the terminal loses focus, so the hollow-rect ghost most terminals draw at the parked cursor position disappears too. Made-with: Cursor * chore(tui): /clean — extract isMultiClickAt helper Pull the click-recurrence math out of TextInput's onMouseDown into a small isMultiClickAt(offset) helper so the handler reads as the gesture list it actually is (multi-click → select-all, otherwise start). Drop the redundant length>0 guard now that selectAll() already noops on an empty value. Made-with: Cursor * docs(tui): explain _tui_need_npm_install content-vs-mtime comparison Expand the docstring so future readers understand why we parse the lockfiles instead of comparing mtimes, what the optional/peer skip covers, how stale hidden-lock entries are handled, and when we fall back to mtime.
2026-04-27 16:43:48 -07:00
def test_no_install_when_lock_newer_but_hidden_lock_matches(tmp_path: Path, main_mod) -> None:
2026-04-15 10:23:15 -05:00
_touch_ink(tmp_path)
fix(tui): mouse + keyboard text selection in the composer (#16732) * feat(tui): auto copy-on-select for transcript text Drag in the transcript already highlighted but you had to press Cmd+C to land it on the clipboard, and the highlight cleared on copy — most users never realised selection existed. Now drag-release fires copySelectionNoClear so the text is on the clipboard immediately while the highlight stays put, matching iTerm2's "Copy to pasteboard on selection" default. Esc clears. Behaviour: - Single click in the input still positions the cursor (TextInput onClick). - Single click in the transcript still does nothing destructive. - Double / triple click select word / line, then drag extends. - /copyselect [on|off|toggle] (alias /cos) flips the setting at runtime, HERMES_TUI_DISABLE_COPY_ON_SELECT=1 disables at startup, persists via display.tui_copy_on_select in config.yaml. Help overlay now lists drag-select, multi-click, and click-to-position so the gestures are discoverable. Made-with: Cursor * fix(tui): support prompt text selection gestures Add mouse drag selection and Shift+Arrow/Home/End extension inside the TUI composer so prompt text behaves like a normal editable field while keeping click-to-position and right-click paste intact. Made-with: Cursor * Revert "feat(tui): auto copy-on-select for transcript text" This reverts commit 6701288fe07a53af873e1ef53855a9618d733327. * fix(tui): allow composer selection from prompt whitespace Give the composer a one-cell mouse capture pad before the editable text. The prompt glyph/gutter still does not become selectable, but dragging from the edge now anchors at input offset 0 so users do not need to hit the first character precisely. Made-with: Cursor * fix(tui): clear selections from blank composer space Clicking blank space in the transcript or composer now clears active TUI/input selections like a normal text surface. TextInput clicks stop bubbling so cursor placement and selection gestures keep their local behavior. Made-with: Cursor * fix(tui): delegate prompt gutter drags to composer text The prompt gutter is now an input gesture region, not selectable content. Dragging from the whitespace or prompt area anchors the composer selection at offset 0, while selection highlight/copy remains limited to actual input text. Made-with: Cursor * fix(tui): move composer cursor to end on selection clear External clear actions now collapse the composer selection to the end of the input, matching normal text-field behavior after dismissing a selection. Made-with: Cursor * fix(tui): capture composer padding before prompt Add an explicit mouse capture cell over the left padding before the prompt glyph. Drags starting there now delegate to the composer input at offset 0 instead of starting terminal-level selection over the prompt chrome. Made-with: Cursor * fix(tui): avoid npm install on lockfile mtime churn Compare package-lock.json against npm's hidden node_modules lock by content instead of mtimes. Git checkouts and npm lock rewrites can make the root lockfile newer even when installed dependencies already match, causing hermes --tui to print Installing TUI dependencies on every launch. Made-with: Cursor * fix(tui): include prompt leading cell in gesture region Use the prompt box's real layout region to cover the leading whitespace cell before the glyph. The cell now participates in mouse hit testing and delegates to composer selection instead of starting terminal-level selection. Made-with: Cursor * fix(tui): widen prompt-side gesture capture band Capture a wider left-side band around the composer prompt row so drags starting in terminal gutter/padding cells are consumed and delegated to input selection, instead of triggering terminal-level selection chrome. Made-with: Cursor * fix(tui): make pre-prompt spacer non-selectable content Replace the sticky-prompt fallback `Text(' ')` with an empty spacer box so the visual gap remains but no literal space character is rendered/copyable before the composer prompt. Made-with: Cursor * fix(tui): capture pre-prompt spacer without shifting prompt layout Revert the widened negative-margin prompt capture band and instead capture drags on the dedicated spacer row above the prompt. This keeps prompt/text alignment stable while still delegating whitespace-start drags to composer selection. Made-with: Cursor * fix(tui): align prompt with status bar and capture full input row Drop the leading prompt column from 3 to 2 so the input first character lines up with the status bar text. Wrap the prompt+input row in a single mouse-capture box and stop event propagation from TextInput's own handlers so any drag in that row delegates to composer selection without leaking to terminal-level selection. Made-with: Cursor * fix(tui): anchor hardware cursor during composer selection When a composer selection covers a row exactly the column width, the rendered text fills the row and the terminal auto-wraps the hardware cursor to col 0 of the next row, leaving a ghost block beneath the prompt. Park the cursor at the start of the input box during selection so it can't escape the input region. Made-with: Cursor * fix(tui): hide hardware cursor during composer selection Stop fighting auto-wrap by hiding the hardware cursor outright while the composer has an active selection. This prevents both the ghost block under the prompt (cursor wrapping past the last cell) and the parked-cursor block on the first selected character. The cursor restores as soon as the selection clears or focus changes. Made-with: Cursor * chore(tui): /clean — drop dead capture-pad path, dedupe gutter handlers - TextInput: remove unused leftCaptureColumns prop and capture-pad math, drop unused mouseApi.startAt, fold mouse offset into a single offsetAt helper, share a MouseEventLite type across the four handlers. - appLayout: hoist a GutterMouseEvent type and an endInputDrag callback so the spacer/prompt/input rows share one shape. - _tui_need_npm_install: lift the runtime-only key set to a module constant, collapse nested isinstance checks, and document the mtime fallback. Made-with: Cursor * fix(tui): address copilot review on PR #16732 - Split InputSelection.clear() into clear() (cursor-preserving) and collapseToEnd() (clear + jump to end). Cmd+C copy paths keep using clear() so the cursor stays put; the blank-area click in useMainApp switches to collapseToEnd() to match the requested UX. - Spacer-row drags now force row=0 when forwarding into the input, since the spacer's vertical origin doesn't align with the input box and Ink mouse-capture keeps dispatching motion to the original target. Prompt+input row drag keeps localRow because origins match. Made-with: Cursor * fix(tui): give TextInput Box an explicit width After the /clean pass dropped the unused capture-pad math, the wrapping Box also lost its explicit width and started sizing to its rendered content. Clicks past the last character missed TextInput and fell through to the parent prompt-row Box, which collapsed the cursor to offset 0. Pin the Box back to `columns` so the input owns its full column span regardless of value length. Made-with: Cursor * feat(tui): double-click select-all + hide cursor on terminal blur - Track click time/offset in TextInput so a quick second click on the same offset triggers select-all. Ink's screen-level multi-click is bypassed once our onMouseDown captures, so the gesture has to be detected locally. - Extend the cursor-hide effect to also fire when the terminal loses focus, so the hollow-rect ghost most terminals draw at the parked cursor position disappears too. Made-with: Cursor * chore(tui): /clean — extract isMultiClickAt helper Pull the click-recurrence math out of TextInput's onMouseDown into a small isMultiClickAt(offset) helper so the handler reads as the gesture list it actually is (multi-click → select-all, otherwise start). Drop the redundant length>0 guard now that selectAll() already noops on an empty value. Made-with: Cursor * docs(tui): explain _tui_need_npm_install content-vs-mtime comparison Expand the docstring so future readers understand why we parse the lockfiles instead of comparing mtimes, what the optional/peer skip covers, how stale hidden-lock entries are handled, and when we fall back to mtime.
2026-04-27 16:43:48 -07:00
(tmp_path / "package-lock.json").write_text('{"packages":{"node_modules/foo":{"version":"1.0.0"}}}')
(tmp_path / "node_modules" / ".package-lock.json").write_text(
'{"packages":{"node_modules/foo":{"version":"1.0.0","ideallyInert":true}}}'
)
2026-04-15 10:23:15 -05:00
os.utime(tmp_path / "package-lock.json", (200, 200))
os.utime(tmp_path / "node_modules" / ".package-lock.json", (100, 100))
fix(tui): mouse + keyboard text selection in the composer (#16732) * feat(tui): auto copy-on-select for transcript text Drag in the transcript already highlighted but you had to press Cmd+C to land it on the clipboard, and the highlight cleared on copy — most users never realised selection existed. Now drag-release fires copySelectionNoClear so the text is on the clipboard immediately while the highlight stays put, matching iTerm2's "Copy to pasteboard on selection" default. Esc clears. Behaviour: - Single click in the input still positions the cursor (TextInput onClick). - Single click in the transcript still does nothing destructive. - Double / triple click select word / line, then drag extends. - /copyselect [on|off|toggle] (alias /cos) flips the setting at runtime, HERMES_TUI_DISABLE_COPY_ON_SELECT=1 disables at startup, persists via display.tui_copy_on_select in config.yaml. Help overlay now lists drag-select, multi-click, and click-to-position so the gestures are discoverable. Made-with: Cursor * fix(tui): support prompt text selection gestures Add mouse drag selection and Shift+Arrow/Home/End extension inside the TUI composer so prompt text behaves like a normal editable field while keeping click-to-position and right-click paste intact. Made-with: Cursor * Revert "feat(tui): auto copy-on-select for transcript text" This reverts commit 6701288fe07a53af873e1ef53855a9618d733327. * fix(tui): allow composer selection from prompt whitespace Give the composer a one-cell mouse capture pad before the editable text. The prompt glyph/gutter still does not become selectable, but dragging from the edge now anchors at input offset 0 so users do not need to hit the first character precisely. Made-with: Cursor * fix(tui): clear selections from blank composer space Clicking blank space in the transcript or composer now clears active TUI/input selections like a normal text surface. TextInput clicks stop bubbling so cursor placement and selection gestures keep their local behavior. Made-with: Cursor * fix(tui): delegate prompt gutter drags to composer text The prompt gutter is now an input gesture region, not selectable content. Dragging from the whitespace or prompt area anchors the composer selection at offset 0, while selection highlight/copy remains limited to actual input text. Made-with: Cursor * fix(tui): move composer cursor to end on selection clear External clear actions now collapse the composer selection to the end of the input, matching normal text-field behavior after dismissing a selection. Made-with: Cursor * fix(tui): capture composer padding before prompt Add an explicit mouse capture cell over the left padding before the prompt glyph. Drags starting there now delegate to the composer input at offset 0 instead of starting terminal-level selection over the prompt chrome. Made-with: Cursor * fix(tui): avoid npm install on lockfile mtime churn Compare package-lock.json against npm's hidden node_modules lock by content instead of mtimes. Git checkouts and npm lock rewrites can make the root lockfile newer even when installed dependencies already match, causing hermes --tui to print Installing TUI dependencies on every launch. Made-with: Cursor * fix(tui): include prompt leading cell in gesture region Use the prompt box's real layout region to cover the leading whitespace cell before the glyph. The cell now participates in mouse hit testing and delegates to composer selection instead of starting terminal-level selection. Made-with: Cursor * fix(tui): widen prompt-side gesture capture band Capture a wider left-side band around the composer prompt row so drags starting in terminal gutter/padding cells are consumed and delegated to input selection, instead of triggering terminal-level selection chrome. Made-with: Cursor * fix(tui): make pre-prompt spacer non-selectable content Replace the sticky-prompt fallback `Text(' ')` with an empty spacer box so the visual gap remains but no literal space character is rendered/copyable before the composer prompt. Made-with: Cursor * fix(tui): capture pre-prompt spacer without shifting prompt layout Revert the widened negative-margin prompt capture band and instead capture drags on the dedicated spacer row above the prompt. This keeps prompt/text alignment stable while still delegating whitespace-start drags to composer selection. Made-with: Cursor * fix(tui): align prompt with status bar and capture full input row Drop the leading prompt column from 3 to 2 so the input first character lines up with the status bar text. Wrap the prompt+input row in a single mouse-capture box and stop event propagation from TextInput's own handlers so any drag in that row delegates to composer selection without leaking to terminal-level selection. Made-with: Cursor * fix(tui): anchor hardware cursor during composer selection When a composer selection covers a row exactly the column width, the rendered text fills the row and the terminal auto-wraps the hardware cursor to col 0 of the next row, leaving a ghost block beneath the prompt. Park the cursor at the start of the input box during selection so it can't escape the input region. Made-with: Cursor * fix(tui): hide hardware cursor during composer selection Stop fighting auto-wrap by hiding the hardware cursor outright while the composer has an active selection. This prevents both the ghost block under the prompt (cursor wrapping past the last cell) and the parked-cursor block on the first selected character. The cursor restores as soon as the selection clears or focus changes. Made-with: Cursor * chore(tui): /clean — drop dead capture-pad path, dedupe gutter handlers - TextInput: remove unused leftCaptureColumns prop and capture-pad math, drop unused mouseApi.startAt, fold mouse offset into a single offsetAt helper, share a MouseEventLite type across the four handlers. - appLayout: hoist a GutterMouseEvent type and an endInputDrag callback so the spacer/prompt/input rows share one shape. - _tui_need_npm_install: lift the runtime-only key set to a module constant, collapse nested isinstance checks, and document the mtime fallback. Made-with: Cursor * fix(tui): address copilot review on PR #16732 - Split InputSelection.clear() into clear() (cursor-preserving) and collapseToEnd() (clear + jump to end). Cmd+C copy paths keep using clear() so the cursor stays put; the blank-area click in useMainApp switches to collapseToEnd() to match the requested UX. - Spacer-row drags now force row=0 when forwarding into the input, since the spacer's vertical origin doesn't align with the input box and Ink mouse-capture keeps dispatching motion to the original target. Prompt+input row drag keeps localRow because origins match. Made-with: Cursor * fix(tui): give TextInput Box an explicit width After the /clean pass dropped the unused capture-pad math, the wrapping Box also lost its explicit width and started sizing to its rendered content. Clicks past the last character missed TextInput and fell through to the parent prompt-row Box, which collapsed the cursor to offset 0. Pin the Box back to `columns` so the input owns its full column span regardless of value length. Made-with: Cursor * feat(tui): double-click select-all + hide cursor on terminal blur - Track click time/offset in TextInput so a quick second click on the same offset triggers select-all. Ink's screen-level multi-click is bypassed once our onMouseDown captures, so the gesture has to be detected locally. - Extend the cursor-hide effect to also fire when the terminal loses focus, so the hollow-rect ghost most terminals draw at the parked cursor position disappears too. Made-with: Cursor * chore(tui): /clean — extract isMultiClickAt helper Pull the click-recurrence math out of TextInput's onMouseDown into a small isMultiClickAt(offset) helper so the handler reads as the gesture list it actually is (multi-click → select-all, otherwise start). Drop the redundant length>0 guard now that selectAll() already noops on an empty value. Made-with: Cursor * docs(tui): explain _tui_need_npm_install content-vs-mtime comparison Expand the docstring so future readers understand why we parse the lockfiles instead of comparing mtimes, what the optional/peer skip covers, how stale hidden-lock entries are handled, and when we fall back to mtime.
2026-04-27 16:43:48 -07:00
assert main_mod._tui_need_npm_install(tmp_path) is False
def test_need_install_when_required_package_missing_from_hidden_lock(tmp_path: Path, main_mod) -> None:
_touch_ink(tmp_path)
(tmp_path / "package-lock.json").write_text(
'{"packages":{"node_modules/foo":{"version":"1.0.0"},"node_modules/bar":{"version":"1.0.0"}}}'
)
(tmp_path / "node_modules" / ".package-lock.json").write_text(
'{"packages":{"node_modules/foo":{"version":"1.0.0"}}}'
)
2026-04-15 10:23:15 -05:00
assert main_mod._tui_need_npm_install(tmp_path) is True
fix(tui): mouse + keyboard text selection in the composer (#16732) * feat(tui): auto copy-on-select for transcript text Drag in the transcript already highlighted but you had to press Cmd+C to land it on the clipboard, and the highlight cleared on copy — most users never realised selection existed. Now drag-release fires copySelectionNoClear so the text is on the clipboard immediately while the highlight stays put, matching iTerm2's "Copy to pasteboard on selection" default. Esc clears. Behaviour: - Single click in the input still positions the cursor (TextInput onClick). - Single click in the transcript still does nothing destructive. - Double / triple click select word / line, then drag extends. - /copyselect [on|off|toggle] (alias /cos) flips the setting at runtime, HERMES_TUI_DISABLE_COPY_ON_SELECT=1 disables at startup, persists via display.tui_copy_on_select in config.yaml. Help overlay now lists drag-select, multi-click, and click-to-position so the gestures are discoverable. Made-with: Cursor * fix(tui): support prompt text selection gestures Add mouse drag selection and Shift+Arrow/Home/End extension inside the TUI composer so prompt text behaves like a normal editable field while keeping click-to-position and right-click paste intact. Made-with: Cursor * Revert "feat(tui): auto copy-on-select for transcript text" This reverts commit 6701288fe07a53af873e1ef53855a9618d733327. * fix(tui): allow composer selection from prompt whitespace Give the composer a one-cell mouse capture pad before the editable text. The prompt glyph/gutter still does not become selectable, but dragging from the edge now anchors at input offset 0 so users do not need to hit the first character precisely. Made-with: Cursor * fix(tui): clear selections from blank composer space Clicking blank space in the transcript or composer now clears active TUI/input selections like a normal text surface. TextInput clicks stop bubbling so cursor placement and selection gestures keep their local behavior. Made-with: Cursor * fix(tui): delegate prompt gutter drags to composer text The prompt gutter is now an input gesture region, not selectable content. Dragging from the whitespace or prompt area anchors the composer selection at offset 0, while selection highlight/copy remains limited to actual input text. Made-with: Cursor * fix(tui): move composer cursor to end on selection clear External clear actions now collapse the composer selection to the end of the input, matching normal text-field behavior after dismissing a selection. Made-with: Cursor * fix(tui): capture composer padding before prompt Add an explicit mouse capture cell over the left padding before the prompt glyph. Drags starting there now delegate to the composer input at offset 0 instead of starting terminal-level selection over the prompt chrome. Made-with: Cursor * fix(tui): avoid npm install on lockfile mtime churn Compare package-lock.json against npm's hidden node_modules lock by content instead of mtimes. Git checkouts and npm lock rewrites can make the root lockfile newer even when installed dependencies already match, causing hermes --tui to print Installing TUI dependencies on every launch. Made-with: Cursor * fix(tui): include prompt leading cell in gesture region Use the prompt box's real layout region to cover the leading whitespace cell before the glyph. The cell now participates in mouse hit testing and delegates to composer selection instead of starting terminal-level selection. Made-with: Cursor * fix(tui): widen prompt-side gesture capture band Capture a wider left-side band around the composer prompt row so drags starting in terminal gutter/padding cells are consumed and delegated to input selection, instead of triggering terminal-level selection chrome. Made-with: Cursor * fix(tui): make pre-prompt spacer non-selectable content Replace the sticky-prompt fallback `Text(' ')` with an empty spacer box so the visual gap remains but no literal space character is rendered/copyable before the composer prompt. Made-with: Cursor * fix(tui): capture pre-prompt spacer without shifting prompt layout Revert the widened negative-margin prompt capture band and instead capture drags on the dedicated spacer row above the prompt. This keeps prompt/text alignment stable while still delegating whitespace-start drags to composer selection. Made-with: Cursor * fix(tui): align prompt with status bar and capture full input row Drop the leading prompt column from 3 to 2 so the input first character lines up with the status bar text. Wrap the prompt+input row in a single mouse-capture box and stop event propagation from TextInput's own handlers so any drag in that row delegates to composer selection without leaking to terminal-level selection. Made-with: Cursor * fix(tui): anchor hardware cursor during composer selection When a composer selection covers a row exactly the column width, the rendered text fills the row and the terminal auto-wraps the hardware cursor to col 0 of the next row, leaving a ghost block beneath the prompt. Park the cursor at the start of the input box during selection so it can't escape the input region. Made-with: Cursor * fix(tui): hide hardware cursor during composer selection Stop fighting auto-wrap by hiding the hardware cursor outright while the composer has an active selection. This prevents both the ghost block under the prompt (cursor wrapping past the last cell) and the parked-cursor block on the first selected character. The cursor restores as soon as the selection clears or focus changes. Made-with: Cursor * chore(tui): /clean — drop dead capture-pad path, dedupe gutter handlers - TextInput: remove unused leftCaptureColumns prop and capture-pad math, drop unused mouseApi.startAt, fold mouse offset into a single offsetAt helper, share a MouseEventLite type across the four handlers. - appLayout: hoist a GutterMouseEvent type and an endInputDrag callback so the spacer/prompt/input rows share one shape. - _tui_need_npm_install: lift the runtime-only key set to a module constant, collapse nested isinstance checks, and document the mtime fallback. Made-with: Cursor * fix(tui): address copilot review on PR #16732 - Split InputSelection.clear() into clear() (cursor-preserving) and collapseToEnd() (clear + jump to end). Cmd+C copy paths keep using clear() so the cursor stays put; the blank-area click in useMainApp switches to collapseToEnd() to match the requested UX. - Spacer-row drags now force row=0 when forwarding into the input, since the spacer's vertical origin doesn't align with the input box and Ink mouse-capture keeps dispatching motion to the original target. Prompt+input row drag keeps localRow because origins match. Made-with: Cursor * fix(tui): give TextInput Box an explicit width After the /clean pass dropped the unused capture-pad math, the wrapping Box also lost its explicit width and started sizing to its rendered content. Clicks past the last character missed TextInput and fell through to the parent prompt-row Box, which collapsed the cursor to offset 0. Pin the Box back to `columns` so the input owns its full column span regardless of value length. Made-with: Cursor * feat(tui): double-click select-all + hide cursor on terminal blur - Track click time/offset in TextInput so a quick second click on the same offset triggers select-all. Ink's screen-level multi-click is bypassed once our onMouseDown captures, so the gesture has to be detected locally. - Extend the cursor-hide effect to also fire when the terminal loses focus, so the hollow-rect ghost most terminals draw at the parked cursor position disappears too. Made-with: Cursor * chore(tui): /clean — extract isMultiClickAt helper Pull the click-recurrence math out of TextInput's onMouseDown into a small isMultiClickAt(offset) helper so the handler reads as the gesture list it actually is (multi-click → select-all, otherwise start). Drop the redundant length>0 guard now that selectAll() already noops on an empty value. Made-with: Cursor * docs(tui): explain _tui_need_npm_install content-vs-mtime comparison Expand the docstring so future readers understand why we parse the lockfiles instead of comparing mtimes, what the optional/peer skip covers, how stale hidden-lock entries are handled, and when we fall back to mtime.
2026-04-27 16:43:48 -07:00
def test_no_install_when_only_optional_peer_package_missing_from_hidden_lock(tmp_path: Path, main_mod) -> None:
_touch_ink(tmp_path)
(tmp_path / "package-lock.json").write_text(
'{"packages":{"node_modules/foo":{"version":"1.0.0"},"node_modules/optional":{"version":"1.0.0","optional":true,"peer":true}}}'
)
(tmp_path / "node_modules" / ".package-lock.json").write_text(
'{"packages":{"node_modules/foo":{"version":"1.0.0"}}}'
)
assert main_mod._tui_need_npm_install(tmp_path) is False
2026-04-15 10:23:15 -05:00
def test_no_install_when_lock_older_than_marker(tmp_path: Path, main_mod) -> None:
_touch_ink(tmp_path)
(tmp_path / "package-lock.json").write_text("{}")
(tmp_path / "node_modules" / ".package-lock.json").write_text("{}")
os.utime(tmp_path / "package-lock.json", (100, 100))
os.utime(tmp_path / "node_modules" / ".package-lock.json", (200, 200))
assert main_mod._tui_need_npm_install(tmp_path) is False
def test_need_install_when_marker_missing(tmp_path: Path, main_mod) -> None:
_touch_ink(tmp_path)
(tmp_path / "package-lock.json").write_text("{}")
assert main_mod._tui_need_npm_install(tmp_path) is True
def test_no_install_without_lockfile_when_ink_present(tmp_path: Path, main_mod) -> None:
_touch_ink(tmp_path)
assert main_mod._tui_need_npm_install(tmp_path) is False
def test_build_needed_when_local_ink_bundle_missing(tmp_path: Path, main_mod) -> None:
_touch_tui_entry(tmp_path)
_touch_ink(tmp_path)
assert main_mod._tui_need_npm_install(tmp_path) is False
assert main_mod._tui_build_needed(tmp_path) is True
def test_build_not_needed_when_entry_and_ink_bundle_present(tmp_path: Path, main_mod) -> None:
_touch_tui_entry(tmp_path)
_touch_ink(tmp_path)
_touch_ink_bundle(tmp_path)
assert main_mod._tui_build_needed(tmp_path) is False