mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-20 15:19:16 +00:00
* feat #1005: add live-preview keystroke calculator for popup autocomplete Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat #1005: live-render the selected popup suggestion on arrow navigation Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat #1005: free Tab for the shell; Enter runs the rendered line; Esc reverts Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat #1005: show key hint (→ expand / ↵ run) on the selected popup row Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat #1005: live-render full path while navigating sub-directory panels Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * test #1005: move live-preview test into the npm test glob The test runner only scans components/terminal/*.test.ts (not the autocomplete/ subdir), matching where the other autocomplete-module tests live (e.g. completionEngine.test.ts). Relocate so it actually runs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix #1005: center and refine the popup key-cap hint Use inline-flex centering (the ↵ glyph was vertically off with line-height + padding), softer color-mixed border/background, a system-sans font so the glyph renders consistently regardless of the terminal font, and the more balanced ⏎ return symbol. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix #1005: record the actual executed line on Enter, not the stale suggestion Codex review (P2): the popup Enter handler recorded selected.text and suppressed handleInput's recorder, so editing a previewed command (select docker, type ' ps', Enter before the re-query) logged the stale 'docker' instead of 'docker ps'. Delegate to handleInput's Enter path, which records lastAcceptedCommandRef on a clean select and falls back to the live buffer after an edit (typing nulls that ref). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix #1005: don't revert user edits when Escape closes the popup Codex review (P2): previewActiveRef stayed true after the user edited a previewed command, so Escape (before the debounced re-query reset state) called renderPreviewSelection(-1) and rewrote the line back to the stale baseline, dropping the edits. Clear previewActiveRef when the user types (alongside the existing lastAcceptedCommandRef reset), so Escape only reverts a pristine preview and otherwise just dismisses the popup. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
25 lines
998 B
TypeScript
25 lines
998 B
TypeScript
/**
|
|
* Compute the keystrokes to send so the terminal input line becomes exactly
|
|
* `candidate`, given what is currently on the line. Drives the popup
|
|
* autocomplete live-preview (#1005): moving the selection renders the chosen
|
|
* suggestion into the command line, and switching / reverting rewrites it.
|
|
*
|
|
* - Forward prefix (candidate continues the line): append only the new tail.
|
|
* - Otherwise: clear the current input, then write the full candidate. POSIX
|
|
* shells use Ctrl-U (kill-line); Windows (cmd/PowerShell) uses backspaces
|
|
* sized to the current line length.
|
|
*/
|
|
export function computeLivePreviewWrite(input: {
|
|
currentLine: string;
|
|
candidate: string;
|
|
os: string;
|
|
}): string {
|
|
const { currentLine, candidate, os } = input;
|
|
if (candidate === currentLine) return "";
|
|
if (candidate.startsWith(currentLine)) {
|
|
return candidate.slice(currentLine.length);
|
|
}
|
|
const clear = os === "windows" ? "\b".repeat(currentLine.length) : "\x15";
|
|
return clear + candidate;
|
|
}
|