Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 33 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,18 @@
"title": "ACP: Attach File to Prompt",
"icon": "$(attach)"
},
{
"command": "acp.enableEditorContextLink",
"title": "ACP: Enable Editor Context Link",
"icon": "$(pin)",
"when": "!acp.editorContextLinked"
},
{
"command": "acp.disableEditorContextLink",
"title": "ACP: Disable Editor Context Link",
"icon": "$(pinned)",
"when": "acp.editorContextLinked"
},
Comment thread
maurice30120 marked this conversation as resolved.
{
"command": "acp.refreshAgents",
"title": "Refresh",
Expand Down Expand Up @@ -176,6 +188,14 @@
{
"command": "acp.forgetSession",
"when": "false"
},
{
"command": "acp.enableEditorContextLink",
"when": "!acp.editorContextLinked"
},
{
"command": "acp.disableEditorContextLink",
"when": "acp.editorContextLinked"
}
],
"view/title": [
Expand Down Expand Up @@ -203,15 +223,25 @@
"when": "view == acp-chat",
"group": "navigation@2"
},
{
"command": "acp.enableEditorContextLink",
"when": "view == acp-chat && !acp.editorContextLinked",
"group": "navigation@3"
},
{
"command": "acp.disableEditorContextLink",
"when": "view == acp-chat && acp.editorContextLinked",
"group": "navigation@3"
},
{
"command": "acp.cancelTurn",
"when": "view == acp-chat && acp.turnInProgress",
"group": "navigation@3"
"group": "navigation@4"
},
{
"command": "acp.disconnectAgent",
"when": "view == acp-chat",
"group": "navigation@4"
"group": "navigation@5"
},
{
"command": "acp.showLog",
Expand Down Expand Up @@ -397,6 +427,7 @@
"compile": "webpack",
"watch": "webpack --watch",
"package": "webpack --mode production --devtool hidden-source-map",
"vsx": "vsce package",
"compile-tests": "tsc -p . --outDir out",
"watch-tests": "tsc -p . -w --outDir out",
"lint": "eslint src --max-warnings 0",
Expand Down
34 changes: 34 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ import { SessionUpdateHandler } from './handlers/SessionUpdateHandler';
import { SessionTreeProvider } from './ui/SessionTreeProvider';
import { StatusBarManager } from './ui/StatusBarManager';
import { ChatWebviewProvider } from './ui/ChatWebviewProvider';
import { captureEditorContext, captureOpenEditorPaths, initializeOpenEditorsTracker } from './ui/EditorContext';
import { getAgentNames } from './config/AgentConfig';
import { fetchRegistry } from './config/RegistryClient';
import { log, logError, disposeChannels, getOutputChannel, getTrafficChannel } from './utils/Logger';
import { initTelemetry, sendEvent } from './utils/TelemetryManager';

const EDITOR_CONTEXT_LINK_STATE_KEY = 'acp.editorContextLinked';

export function activate(context: vscode.ExtensionContext): void {
log('ACP Client extension activating...');

Expand All @@ -21,6 +24,7 @@ export function activate(context: vscode.ExtensionContext): void {
context.subscriptions.push(telemetryReporter);

// --- Core services ---
context.subscriptions.push(...initializeOpenEditorsTracker());
const sessionUpdateHandler = new SessionUpdateHandler();
const agentManager = new AgentManager();
const connectionManager = new ConnectionManager(sessionUpdateHandler);
Expand Down Expand Up @@ -48,7 +52,17 @@ export function activate(context: vscode.ExtensionContext): void {
context.extensionUri,
sessionManager,
sessionUpdateHandler,
() => captureEditorContext(
vscode.window.activeTextEditor,
captureOpenEditorPaths(vscode.window.tabGroups.all),
),
);
const initialEditorContextLinked = context.workspaceState.get<boolean>(
EDITOR_CONTEXT_LINK_STATE_KEY,
false,
);
chatWebviewProvider.setEditorContextLinked(initialEditorContextLinked);
void vscode.commands.executeCommand('setContext', EDITOR_CONTEXT_LINK_STATE_KEY, initialEditorContextLinked);
const chatViewRegistration = vscode.window.registerWebviewViewProvider(
ChatWebviewProvider.viewType,
chatWebviewProvider,
Expand Down Expand Up @@ -470,6 +484,24 @@ export function activate(context: vscode.ExtensionContext): void {
}
});

const setEditorContextLinked = async (linked: boolean) => {
chatWebviewProvider.setEditorContextLinked(linked);
await context.workspaceState.update(EDITOR_CONTEXT_LINK_STATE_KEY, linked);
await vscode.commands.executeCommand('setContext', EDITOR_CONTEXT_LINK_STATE_KEY, linked);
vscode.window.setStatusBarMessage(
linked ? 'ACP editor context link enabled.' : 'ACP editor context link disabled.',
2500,
);
};

const enableEditorContextLinkCmd = vscode.commands.registerCommand('acp.enableEditorContextLink', async () => {
await setEditorContextLinked(true);
});

const disableEditorContextLinkCmd = vscode.commands.registerCommand('acp.disableEditorContextLink', async () => {
await setEditorContextLinked(false);
});

// Browse Registry
const browseRegistryCmd = vscode.commands.registerCommand('acp.browseRegistry', async () => {
sendEvent('registry/browse');
Expand Down Expand Up @@ -518,6 +550,8 @@ export function activate(context: vscode.ExtensionContext): void {
addAgentCmd,
removeAgentCmd,
attachFileCmd,
enableEditorContextLinkCmd,
disableEditorContextLinkCmd,
browseRegistryCmd,
{
dispose: () => {
Expand Down
Loading