feat: add VS Code runtime detection to session sidebar and agent manager components
This commit is contained in:
@@ -57,6 +57,7 @@ import { opencodeClient } from '@/lib/opencode/client';
|
|||||||
import { checkIsGitRepository } from '@/lib/gitApi';
|
import { checkIsGitRepository } from '@/lib/gitApi';
|
||||||
import { getSafeStorage } from '@/stores/utils/safeStorage';
|
import { getSafeStorage } from '@/stores/utils/safeStorage';
|
||||||
import { createWorktreeSession } from '@/lib/worktreeSessionCreator';
|
import { createWorktreeSession } from '@/lib/worktreeSessionCreator';
|
||||||
|
import { isVSCodeRuntime } from '@/lib/desktop';
|
||||||
|
|
||||||
const PROJECT_COLLAPSE_STORAGE_KEY = 'oc.sessions.projectCollapse';
|
const PROJECT_COLLAPSE_STORAGE_KEY = 'oc.sessions.projectCollapse';
|
||||||
const SESSION_EXPANDED_STORAGE_KEY = 'oc.sessions.expandedParents';
|
const SESSION_EXPANDED_STORAGE_KEY = 'oc.sessions.expandedParents';
|
||||||
@@ -377,6 +378,8 @@ export const SessionSidebar: React.FC<SessionSidebarProps> = ({
|
|||||||
return typeof window.opencodeDesktop !== 'undefined';
|
return typeof window.opencodeDesktop !== 'undefined';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const isVSCode = React.useMemo(() => isVSCodeRuntime(), []);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
try {
|
try {
|
||||||
const storedParents = safeStorage.getItem(SESSION_EXPANDED_STORAGE_KEY);
|
const storedParents = safeStorage.getItem(SESSION_EXPANDED_STORAGE_KEY);
|
||||||
@@ -913,7 +916,8 @@ export const SessionSidebar: React.FC<SessionSidebarProps> = ({
|
|||||||
|
|
||||||
const getSessionsForProject = React.useCallback(
|
const getSessionsForProject = React.useCallback(
|
||||||
(project: { normalizedPath: string }) => {
|
(project: { normalizedPath: string }) => {
|
||||||
const worktreesForProject = availableWorktreesByProject.get(project.normalizedPath) ?? [];
|
// In VS Code, only show sessions from the main project directory (skip worktrees)
|
||||||
|
const worktreesForProject = isVSCode ? [] : (availableWorktreesByProject.get(project.normalizedPath) ?? []);
|
||||||
const directories = [
|
const directories = [
|
||||||
project.normalizedPath,
|
project.normalizedPath,
|
||||||
...worktreesForProject
|
...worktreesForProject
|
||||||
@@ -937,7 +941,7 @@ export const SessionSidebar: React.FC<SessionSidebarProps> = ({
|
|||||||
|
|
||||||
return collected;
|
return collected;
|
||||||
},
|
},
|
||||||
[availableWorktreesByProject, getSessionsByDirectory, sessionsByDirectory],
|
[availableWorktreesByProject, getSessionsByDirectory, sessionsByDirectory, isVSCode],
|
||||||
);
|
);
|
||||||
|
|
||||||
const projectSections = React.useMemo(() => {
|
const projectSections = React.useMemo(() => {
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ export const AgentManagerEmptyState: React.FC<AgentManagerEmptyStateProps> = ({
|
|||||||
if (markerIndex > 0) return normalized.slice(0, markerIndex);
|
if (markerIndex > 0) return normalized.slice(0, markerIndex);
|
||||||
if (normalized.endsWith('/.openchamber')) return normalized.slice(0, normalized.length - '/.openchamber'.length);
|
if (normalized.endsWith('/.openchamber')) return normalized.slice(0, normalized.length - '/.openchamber'.length);
|
||||||
return normalized;
|
return normalized;
|
||||||
}, [activeProjectId, projects, currentDirectory, vscodeWorkspaceFolder]);
|
}, [activeProjectId, projects, currentDirectory, vscodeWorkspaceFolder, isVSCodeRuntime]);
|
||||||
|
|
||||||
// Load setup commands from config
|
// Load setup commands from config
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user