MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / getOrCreateTerminal

Function getOrCreateTerminal

vscode-extension/src/extension.ts:43–65  ·  view source on GitHub ↗

* Find an existing QodeX terminal or create a new one. We reuse terminals so * repeated commands don't pile up tabs.

(cwd: string)

Source from the content-addressed store, hash-verified

41 * repeated commands don't pile up tabs.
42 */
43function getOrCreateTerminal(cwd: string): vscode.Terminal {
44 const cfg = getConfig();
45 const existing = vscode.window.terminals.find(t => t.name === cfg.terminalName);
46 if (existing) {
47 existing.show();
48 return existing;
49 }
50 const terminal = vscode.window.createTerminal({
51 name: cfg.terminalName,
52 cwd,
53 env: {
54 ...process.env,
55 // Force HOME to a sane value. Some macOS launch paths (Spotlight,
56 // Applications folder, Finder double-click) leave HOME unset or set
57 // to '/' in the extension host, which propagates into the spawned
58 // terminal and breaks ~/.qodex resolution.
59 HOME: process.env.HOME && process.env.HOME !== '/' ? process.env.HOME : os.homedir(),
60 QODEX_LAUNCHED_FROM: 'vscode',
61 },
62 });
63 terminal.show();
64 return terminal;
65}
66
67/** Determine the right working directory: workspace folder if available, else file's dir, else home. */
68function getCwd(): string {

Callers 7

openInTerminalFunction · 0.85
askAboutSelectionFunction · 0.85
editCurrentFileFunction · 0.85
runPlanFunction · 0.85
networkDiagFunction · 0.85
fixDiagnosticsFunction · 0.85
explainDiagnosticFunction · 0.85

Calls 1

getConfigFunction · 0.85

Tested by

no test coverage detected