Files
Netcatty/components/terminal/runtime/terminalCommandInjectionReadyRegistry.ts
T
cd0fa39f49 feat(terminal): click archive names to fill extraction command (#3269) (#3787)
* feat(terminal): click archive names to fill extraction command

Paste an absolute tar or unzip command when a Linux session
Ctrl/Cmd-clicks a printed archive name. Cwd comes from OSC 7
markers only, so a later directory change cannot retarget an
old relative name.

Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>

* fix(terminal): anchor wrapped archive links on the continuation row

A token that starts on the next physical row was mapped to the previous
row's exclusive end cell. Inclusive offsets now move to the next segment,
while an end-exclusive offset stays on the row where the match stops.

Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>

* fix(terminal): separate archive fill from text after the cursor

Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>

* fix(terminal): separate archive fill across a wrapped draft

Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>
2026-10-20 16:39:44 +08:00

30 lines
962 B
TypeScript

export interface TerminalCommandInjectionReadyOptions {
/** Keep a typed draft. Sensitive prompts, alt-screen, and non-prompts still block. */
allowDraft?: boolean;
}
const commandInjectionReadyReaders = new Map<
string,
(options?: TerminalCommandInjectionReadyOptions) => boolean
>();
export function registerTerminalCommandInjectionReadyReader(
sessionId: string,
reader: (options?: TerminalCommandInjectionReadyOptions) => boolean,
): () => void {
commandInjectionReadyReaders.set(sessionId, reader);
return () => {
if (commandInjectionReadyReaders.get(sessionId) === reader) {
commandInjectionReadyReaders.delete(sessionId);
}
};
}
/** True when the live terminal reports a shell prompt ready for injection. */
export function isTerminalReadyForCommandInjection(
sessionId: string,
options?: TerminalCommandInjectionReadyOptions,
): boolean {
return commandInjectionReadyReaders.get(sessionId)?.(options) === true;
}