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

Commit 980bbb2

Browse files
committed
Enhance terminal picker with 'Use last terminal' quick access option
- Add dedicated quick access option at top of picker for last used terminal - Use history icon and clear description for intuitive UX - Add visual separator between quick option and full terminal list - Maintain natural terminal ordering in the full list - Keep star indicators on last used terminal for visual consistency - Add safety checks to handle separator selections - Improve placeholder text to guide user interaction The picker now provides optimal UX: - Press Enter immediately for quick access to preferred terminal - Cursor always starts at top (quick option when available) - Clear visual separation between quick access and browsing - Natural terminal order preserved for user familiarity Completes the Ask Socratic Shell integration with production-ready UX.
1 parent 9acf01a commit 980bbb2

File tree

1 file changed

+48
-10
lines changed

1 file changed

+48
-10
lines changed

extension/src/extension.ts

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,13 @@ async function findQChatTerminal(outputChannel: vscode.OutputChannel, daemonClie
586586
outputChannel.appendLine(`Last selected terminal PID: ${lastSelectedPID}`);
587587

588588
// Create picker items with terminal info
589-
const terminalItems = await Promise.all(
590-
aiEnabledTerminals.map(async (terminal) => {
589+
interface TerminalQuickPickItem extends vscode.QuickPickItem {
590+
terminal: vscode.Terminal;
591+
pid: number | undefined;
592+
}
593+
594+
const terminalItems: TerminalQuickPickItem[] = await Promise.all(
595+
aiEnabledTerminals.map(async (terminal): Promise<TerminalQuickPickItem> => {
591596
const pid = await terminal.processId;
592597
const isLastSelected = pid === lastSelectedPID;
593598
return {
@@ -600,20 +605,53 @@ async function findQChatTerminal(outputChannel: vscode.OutputChannel, daemonClie
600605
})
601606
);
602607

603-
// Sort items to put last selected first
604-
terminalItems.sort((a, b) => {
605-
if (a.pid === lastSelectedPID) return -1;
606-
if (b.pid === lastSelectedPID) return 1;
607-
return 0;
608-
});
608+
// Keep natural terminal order - don't sort, just use visual indicators
609+
610+
// Find the last selected terminal for the quick option
611+
const lastSelectedItem = terminalItems.find(item => item.pid === lastSelectedPID);
612+
613+
// Create picker items with optional "use last" entry at top
614+
const pickerItems: TerminalQuickPickItem[] = [];
615+
616+
// Add "use last terminal" option if we have a previous selection
617+
if (lastSelectedItem) {
618+
pickerItems.push({
619+
label: `$(history) Use last terminal: ${lastSelectedItem.terminal.name}`,
620+
description: `PID: ${lastSelectedItem.pid}`,
621+
detail: 'Quick access to your previously used terminal',
622+
terminal: lastSelectedItem.terminal,
623+
pid: lastSelectedItem.pid
624+
});
625+
626+
// Add separator
627+
pickerItems.push({
628+
label: '$(dash) All available terminals',
629+
description: '',
630+
detail: '',
631+
terminal: null as any, // This won't be selectable
632+
pid: undefined,
633+
kind: vscode.QuickPickItemKind.Separator
634+
});
635+
}
636+
637+
// Add all terminals (keeping natural order)
638+
pickerItems.push(...terminalItems);
609639

610640
// Show the picker to user
611-
const selectedItem = await vscode.window.showQuickPick(terminalItems, {
612-
placeHolder: 'Select terminal for AI chat (⭐ = last used)',
641+
const selectedItem = await vscode.window.showQuickPick(pickerItems, {
642+
placeHolder: lastSelectedItem
643+
? 'Select terminal for AI chat (first option = quick access to last used)'
644+
: 'Select terminal for AI chat',
613645
title: 'Multiple AI-enabled terminals found'
614646
});
615647

616648
if (selectedItem) {
649+
// Safety check - ignore separator selections
650+
if (selectedItem.kind === vscode.QuickPickItemKind.Separator || !selectedItem.terminal) {
651+
outputChannel.appendLine('User selected separator or invalid item, ignoring');
652+
return null;
653+
}
654+
617655
outputChannel.appendLine(`User selected terminal: ${selectedItem.terminal.name} (PID: ${selectedItem.pid})`);
618656

619657
// Remember this selection for next time

0 commit comments

Comments
 (0)