Skip to content
This repository was archived by the owner on Sep 23, 2025. It is now read-only.

Commit da609f1

Browse files
nikomatsakisClaude
andcommitted
Refactor Ask Socratic Shell to use new sendToActiveTerminal method
- Replace existing Ask Socratic Shell logic with Bus.sendToActiveTerminal() call - Remove duplicate terminal finding and reference creation code - Simplify error handling with try-catch pattern - Maintain same functionality with consolidated implementation This eliminates ~200 lines of duplicate terminal detection logic by using the new consolidated method in the Bus class. Co-authored-by: Claude <[email protected]>
1 parent 73d9286 commit da609f1

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

extension/src/extension.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,18 +1064,20 @@ function setupSelectionDetection(bus: Bus): void {
10641064
outputChannel.appendLine(`Selected: "${selectedText}"`);
10651065
outputChannel.appendLine(`Location: ${filePath}:${startLine}:${startColumn}-${endLine}:${endColumn}`);
10661066

1067-
// 💡: Use new compact reference system instead of verbose XML
1068-
const targetTerminal = await findQChatTerminal(bus);
1069-
if (targetTerminal) {
1070-
const compactMessage = await createCompactSelectionReference(
1071-
selectedText, filePath, startLine, startColumn, endLine, endColumn, bus
1072-
);
1073-
targetTerminal.sendText(compactMessage, false); // false = don't execute, just insert text
1074-
targetTerminal.show(); // Bring terminal into focus
1075-
outputChannel.appendLine(`Compact reference injected into terminal: ${targetTerminal.name}`);
1076-
} else {
1077-
outputChannel.appendLine('No suitable Q chat terminal found');
1078-
vscode.window.showWarningMessage('No suitable terminal found. Please ensure you have a terminal with an active MCP server (like Q chat) running.');
1067+
// Use new consolidated sendToActiveTerminal method
1068+
try {
1069+
const relativePath = vscode.workspace.asRelativePath(filePath);
1070+
const referenceData = {
1071+
file: relativePath,
1072+
line: startLine,
1073+
selection: selectedText.length > 0 ? selectedText : undefined
1074+
};
1075+
1076+
await bus.sendToActiveTerminal(referenceData);
1077+
outputChannel.appendLine(`Compact reference sent for ${relativePath}:${startLine}`);
1078+
} catch (error) {
1079+
outputChannel.appendLine(`Failed to send reference: ${error}`);
1080+
vscode.window.showErrorMessage('Failed to send reference to terminal');
10791081
}
10801082
} else {
10811083
outputChannel.appendLine('Chat action triggered but no current selection found');

0 commit comments

Comments
 (0)