feat(vscode): add session editor panel (#146)
Add command to open active session in editor panel. Introduce editor view mode for displaying sessions alongside files. Update toolbar navigation for editor and sidebar modes.
This commit is contained in:
committed by
GitHub
parent
c52a5f27a2
commit
032229c7a2
@@ -1,13 +1,18 @@
|
||||
import * as vscode from 'vscode';
|
||||
import { ChatViewProvider } from './ChatViewProvider';
|
||||
import { AgentManagerPanelProvider } from './AgentManagerPanelProvider';
|
||||
import { SessionEditorPanelProvider } from './SessionEditorPanelProvider';
|
||||
import { createOpenCodeManager, type OpenCodeManager } from './opencode';
|
||||
|
||||
let chatViewProvider: ChatViewProvider | undefined;
|
||||
let agentManagerProvider: AgentManagerPanelProvider | undefined;
|
||||
let sessionEditorProvider: SessionEditorPanelProvider | undefined;
|
||||
let openCodeManager: OpenCodeManager | undefined;
|
||||
let outputChannel: vscode.OutputChannel | undefined;
|
||||
|
||||
let activeSessionId: string | null = null;
|
||||
let activeSessionTitle: string | null = null;
|
||||
|
||||
const SETTINGS_KEY = 'openchamber.settings';
|
||||
|
||||
const formatIso = (value: number | null | undefined) => {
|
||||
@@ -153,6 +158,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
|
||||
// Create Agent Manager panel provider
|
||||
agentManagerProvider = new AgentManagerPanelProvider(context, context.extensionUri, openCodeManager);
|
||||
sessionEditorProvider = new SessionEditorPanelProvider(context, context.extensionUri, openCodeManager);
|
||||
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand('openchamber.openAgentManager', () => {
|
||||
@@ -160,6 +166,38 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
})
|
||||
);
|
||||
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand('openchamber.setActiveSession', (sessionId: unknown, title?: unknown) => {
|
||||
if (typeof sessionId === 'string' && sessionId.trim().length > 0) {
|
||||
activeSessionId = sessionId.trim();
|
||||
activeSessionTitle = typeof title === 'string' && title.trim().length > 0 ? title.trim() : null;
|
||||
return;
|
||||
}
|
||||
|
||||
activeSessionId = null;
|
||||
activeSessionTitle = null;
|
||||
})
|
||||
);
|
||||
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand('openchamber.openActiveSessionInEditor', () => {
|
||||
if (!activeSessionId) {
|
||||
vscode.window.showInformationMessage('OpenChamber: No active session');
|
||||
return;
|
||||
}
|
||||
sessionEditorProvider?.createOrShow(activeSessionId, activeSessionTitle ?? undefined);
|
||||
})
|
||||
);
|
||||
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand('openchamber.openSessionInEditor', (sessionId: string, title?: string) => {
|
||||
if (typeof sessionId !== 'string' || sessionId.trim().length === 0) {
|
||||
return;
|
||||
}
|
||||
sessionEditorProvider?.createOrShow(sessionId.trim(), title);
|
||||
})
|
||||
);
|
||||
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand('openchamber.restartApi', async () => {
|
||||
try {
|
||||
@@ -437,6 +475,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
vscode.window.onDidChangeActiveColorTheme((theme) => {
|
||||
chatViewProvider?.updateTheme(theme.kind);
|
||||
agentManagerProvider?.updateTheme(theme.kind);
|
||||
sessionEditorProvider?.updateTheme(theme.kind);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -452,6 +491,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
) {
|
||||
chatViewProvider?.updateTheme(vscode.window.activeColorTheme.kind);
|
||||
agentManagerProvider?.updateTheme(vscode.window.activeColorTheme.kind);
|
||||
sessionEditorProvider?.updateTheme(vscode.window.activeColorTheme.kind);
|
||||
}
|
||||
})
|
||||
);
|
||||
@@ -461,6 +501,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
openCodeManager.onStatusChange((status, error) => {
|
||||
chatViewProvider?.updateConnectionStatus(status, error);
|
||||
agentManagerProvider?.updateConnectionStatus(status, error);
|
||||
sessionEditorProvider?.updateConnectionStatus(status, error);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -474,6 +515,7 @@ export async function deactivate() {
|
||||
openCodeManager = undefined;
|
||||
chatViewProvider = undefined;
|
||||
agentManagerProvider = undefined;
|
||||
sessionEditorProvider = undefined;
|
||||
outputChannel?.dispose();
|
||||
outputChannel = undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user