mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-10-09 15:58:34 +00:00
6e9e8fc40d
* feat(autocomplete): add snippet completion source * feat(autocomplete): merge snippets at the command position Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test(autocomplete): place snippet tests where the test runner finds them The npm test glob covers components/terminal/*.test.ts but not the autocomplete/ subdirectory, so the snippet tests added in the previous two commits weren't actually running in the suite. Move them up to components/terminal/ (the existing convention for autocomplete tests) with corrected import paths; the engine snippet cases go in a separate completionEngineSnippets.test.ts to avoid colliding with the existing completionEngine.test.ts. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(autocomplete): snippet ghost-exclusion, preview skip, and accept path Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(autocomplete): wire snippets into the terminal + preview snippet command * fix(autocomplete): show only label in snippet popup row; keep snippet over colliding history The popup row for a snippet now omits the inline command echo — the full command lives in the detail preview only, matching the "label-only row" design. The completion engine pushes snippet suggestions without the early seen-text skip so that when a snippet's label collides with a history entry's text, the higher-scored snippet survives the final dedup. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(autocomplete): broadcast snippet command so popup acceptance mirrors peers In broadcast mode, accepting a snippet from the autocomplete popup cleared peer input (the line-clear keystrokes flow through the broadcast-aware path) but never sent the command, since executeSnippetCommand wrote only to the active session. Broadcast the normalized snippet data (matching the snippet shortkey path) so peers receive both the clear and the command, keeping all sessions in sync. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(autocomplete): broadcast wrapped snippet bytes to preserve noAutoRun Broadcasting the raw normalized command sent un-wrapped newlines to peers, so a multi-line noAutoRun snippet was pasted-but-not-run on the active session yet executed line-by-line on broadcast peers (handleBroadcastInput writes bytes directly without re-wrapping). Broadcast the exact bytes the active session receives instead — bracketed-paste wrapping plus the auto-run \r — so peers mirror the active session and noAutoRun is preserved. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
20 lines
845 B
TypeScript
20 lines
845 B
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import { getCompletions } from "./autocomplete/completionEngine";
|
|
import type { Snippet } from "../../domain/models";
|
|
|
|
const deploySnippet: Snippet = { id: "d", label: "deploy", command: "kubectl apply -f ." };
|
|
|
|
test("getCompletions includes snippet suggestions at the command position", async () => {
|
|
const out = await getCompletions("dep", { snippets: [deploySnippet] });
|
|
const snip = out.find((s) => s.source === "snippet");
|
|
assert.ok(snip, "expected a snippet suggestion");
|
|
assert.equal(snip?.displayText, "deploy");
|
|
});
|
|
|
|
test("getCompletions does not surface snippets past the command position", async () => {
|
|
const out = await getCompletions("git dep", { snippets: [deploySnippet] });
|
|
assert.equal(out.find((s) => s.source === "snippet"), undefined);
|
|
});
|