agentHostHeadlessTerminal.ts ×11

Frontier kind: Code frontier

unlabeled · c_7c2aea165f52

1048 tests · 9157 LOC · 40 files · introduces 0 tests · 66 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
11 ranges66 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1461 ranges9157 lines · 40 files · Browse complete extent
All tests (intent)
1048 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 66 introduced LOC across 11 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/agentHostHeadlessTerminal.ts 66 introduced LOC · 11 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- agentHostHeadlessTerminal.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { Emitter, Event } from '../../../base/common/event.js';
7 > import { DeferredPromise } from '../../../base/common/async.js';
8 > import { Disposable, DisposableStore } from '../../../base/common/lifecycle.js';
9 > import type { ILogService } from '../../log/common/log.js';
10 > import pkg from '@xterm/headless';
11 >
12 > type XtermTerminal = pkg.Terminal;
13 > const { Terminal: XtermTerminal } = pkg;
14 >
15 > export interface IAgentHostHeadlessTerminalOptions {
16 > cols: number;
17 > rows: number;
18 > scrollback: number;
19 > logService: ILogService;
20 > terminalFactory?: (options: IXtermTerminalOptions) => XtermTerminal;
21 > }
22 >
23 > /**
24 > * Mirrors an agent-host PTY into xterm's interpreted terminal model.
25 > *
26 > * The mirror is intentionally internal to the agent host. Protocol-visible
27 > * terminal data still flows through the existing OSC 633 parser and content
28 > * model; this class provides terminal responses for programs that query
29 > * terminal state.
30 > */
31 > export class AgentHostHeadlessTerminal extends Disposable {
32 >
33 > private readonly _terminal: XtermTerminal;
34 > private readonly _logService: ILogService;
35 > private readonly _onResponseData = this._register(new Emitter<string>());
36 > readonly onResponseData: Event<string> = this._onResponseData.event;
37 > private _writeBarrier: Promise<void> = Promise.resolve();
38 > private _isDisposed = false;
39 >
40 > constructor(options: IAgentHostHeadlessTerminalOptions) {
41 super();
42 this._logService = options.logService;
64 });
65 }
67 > writePtyData(data: string): Promise<void> {
68 this._writeBarrier = this._writeBarrier.catch(() => undefined).then(() => {
69 if (this._isDisposed) {
80 return this._writeBarrier;
81 }
83 > whenPtyDataFlushed(): Promise<void> {
84 return this._writeBarrier.catch(() => undefined);
85 }
87 > resize(cols: number, rows: number): void {
88 this._terminal.resize(cols, rows);
89 }
91 > isBracketedPasteMode(): boolean {
92 return this._terminal.modes.bracketedPasteMode;
93 }
95 > isInAltBuffer(): boolean {
96 return this._terminal.buffer.active === this._terminal.buffer.alternate;
97 }
99 > createAltBufferPromise(store: DisposableStore): Promise<void> {
100 const deferred = new DeferredPromise<void>();
101 const complete = () => {
118 return deferred.p;
119 }
121 > clear(): void {
122 // xterm.clear() preserves the visible line content; emulate a terminal
123 // clear sequence so future terminal-state reads match a user-visible clear.
124 void this.writePtyData('\x1b[2J\x1b[3J\x1b[H');
125 }
127 > override dispose(): void {
128 this._isDisposed = true;
129 super.dispose();
130 }
132 > private _isCursorPositionReportResponse(data: string): boolean {
133 // Only forward cursor position reports for now. xterm can also answer
134 // device attribute queries, but workbench only forwards those in narrow
136 return /^(?:\x1b\[\??\d+;\d+R)+$/.test(data);
137 }
139 >
140 > interface IXtermTerminalOptions {
141 > cols: number;
142 > rows: number;
143 > scrollback: number;
144 > allowProposedApi: boolean;
145 > }