Update Astra/Agent state - 2026-05-10 22:26:50
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
import { SidebarChatProvider } from '../sidebarProvider';
|
||||
import { logInfo } from '../utils';
|
||||
import { resolveScopeForAgent, openKnowledgeMapEditor } from '../skills/agentKnowledgeMap';
|
||||
import { getActiveBrainProfile } from '../utils';
|
||||
|
||||
/**
|
||||
* Handles agent-skill messages: the per-conversation agent picker, agent CRUD,
|
||||
* and persisting the user's last selected agent.
|
||||
* persisting the user's last selected agent, and the knowledge-map dropdown.
|
||||
*/
|
||||
export async function handleAgentMessage(provider: SidebarChatProvider, data: any): Promise<boolean> {
|
||||
switch (data.type) {
|
||||
@@ -26,6 +30,30 @@ export async function handleAgentMessage(provider: SidebarChatProvider, data: an
|
||||
await provider._context.globalState.update(SidebarChatProvider.lastAgentStateKey, data.path || 'none');
|
||||
logInfo(`Agent selection saved: ${data.path}`);
|
||||
return true;
|
||||
case 'getKnowledgeScope': {
|
||||
const view = (provider as any)._view as vscode.WebviewView | undefined;
|
||||
if (!view) return true;
|
||||
const brain = getActiveBrainProfile();
|
||||
const brainRoot = brain?.localBrainPath || '';
|
||||
const scope = resolveScopeForAgent(data.agentPath || '', brainRoot);
|
||||
const folders = scope.folders.map((abs) => ({
|
||||
absolute: abs,
|
||||
relative: brainRoot ? path.relative(brainRoot, abs) || abs : abs,
|
||||
}));
|
||||
view.webview.postMessage({
|
||||
type: 'knowledgeScope',
|
||||
value: {
|
||||
agent: scope.agent?.name ?? null,
|
||||
folders,
|
||||
source: scope.source,
|
||||
brainRoot,
|
||||
},
|
||||
});
|
||||
return true;
|
||||
}
|
||||
case 'editKnowledgeMap':
|
||||
await openKnowledgeMapEditor();
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user