Skip to content

Commit b6d0207

Browse files
authored
Merge pull request #17 from pawelhajduk:feature/vscode-settings
Add Settings panel and auto-open diff setting
2 parents 1e37a59 + db3277d commit b6d0207

9 files changed

Lines changed: 619 additions & 7 deletions

File tree

packages/ui/src/App.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import { MainLayout } from '@/components/layout/MainLayout';
33
import { VSCodeLayout } from '@/components/layout/VSCodeLayout';
44
import { AgentManagerView } from '@/components/views/agent-manager';
5+
import { SettingsView } from '@/components/views/SettingsView';
56
import { FireworksProvider } from '@/contexts/FireworksContext';
67
import { Toaster } from '@/components/ui/sonner';
78
import { MemoryDebugPanel } from '@/components/ui/MemoryDebugPanel';
@@ -230,9 +231,9 @@ function App({ apis }: AppProps) {
230231

231232
// VS Code runtime - simplified layout without git/terminal views
232233
if (isVSCodeRuntime) {
233-
// Check if this is the Agent Manager panel
234+
// Check if this is a specialized panel
234235
const panelType = typeof window !== 'undefined'
235-
? (window as { __OPENCHAMBER_PANEL_TYPE__?: 'chat' | 'agentManager' }).__OPENCHAMBER_PANEL_TYPE__
236+
? (window as { __OPENCHAMBER_PANEL_TYPE__?: 'chat' | 'agentManager' | 'settings' }).__OPENCHAMBER_PANEL_TYPE__
236237
: 'chat';
237238

238239
if (panelType === 'agentManager') {
@@ -247,6 +248,19 @@ function App({ apis }: AppProps) {
247248
</ErrorBoundary>
248249
);
249250
}
251+
252+
if (panelType === 'settings') {
253+
return (
254+
<ErrorBoundary>
255+
<RuntimeAPIProvider apis={apis}>
256+
<div className="h-full text-foreground bg-background">
257+
<SettingsView />
258+
<Toaster />
259+
</div>
260+
</RuntimeAPIProvider>
261+
</ErrorBoundary>
262+
);
263+
}
250264

251265
return (
252266
<ErrorBoundary>

packages/ui/src/components/chat/message/parts/ToolPart.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { toolDisplayStyles } from '@/lib/typography';
1010
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
1111
import { useDirectoryStore } from '@/stores/useDirectoryStore';
1212
import { useSessionStore } from '@/stores/useSessionStore';
13+
import { useUIStore } from '@/stores/useUIStore';
1314
import { ScrollableOverlay } from '@/components/ui/ScrollableOverlay';
1415
import type { ContentChangeReason } from '@/hooks/useChatScrollManager';
1516

@@ -1221,6 +1222,7 @@ const ToolExpandedContent: React.FC<ToolExpandedContentProps> = ({
12211222
const ToolPart: React.FC<ToolPartProps> = ({ part, isExpanded, onToggle, syntaxTheme, isMobile, onContentChange, hasPrevTool = false, hasNextTool = false, isVSCode = false }) => {
12221223
const state = part.state;
12231224
const currentDirectory = useDirectoryStore((s) => s.currentDirectory);
1225+
const autoOpenDiff = useUIStore((s) => s.autoOpenDiff);
12241226

12251227
const isTaskTool = part.tool.toLowerCase() === 'task';
12261228

@@ -1390,6 +1392,7 @@ const ToolPart: React.FC<ToolPartProps> = ({ part, isExpanded, onToggle, syntaxT
13901392
const isNowCompleted = state.status === 'completed';
13911393
previousStatusRef.current = state.status;
13921394

1395+
if (!autoOpenDiff) return;
13931396
if (!isVSCode || !wasNotCompleted || !isNowCompleted) return;
13941397
if (!isEditTool || !diffContent) return;
13951398
if (!runtime?.editor?.openAIDiff) return;
@@ -1406,7 +1409,7 @@ const ToolPart: React.FC<ToolPartProps> = ({ part, isExpanded, onToggle, syntaxT
14061409
diff: diffContent,
14071410
label: `AI Edit: ${filePath.split('/').pop() || filePath}`,
14081411
});
1409-
}, [state.status, isVSCode, isEditTool, diffContent, runtime, input, metadata, currentDirectory]);
1412+
}, [state.status, isVSCode, isEditTool, diffContent, runtime, input, metadata, currentDirectory, autoOpenDiff]);
14101413

14111414
if (!isFinalized && !isTaskTool) {
14121415
return null;

packages/ui/src/components/sections/openchamber/OpenChamberVisualSettings.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const DIFF_VIEW_MODE_OPTIONS: Option<'single' | 'stacked'>[] = [
7575
},
7676
];
7777

78-
export type VisibleSetting = 'theme' | 'colorScheme' | 'fonts' | 'fontSize' | 'spacing' | 'cornerRadius' | 'inputBarOffset' | 'toolOutput' | 'diffLayout' | 'dotfiles' | 'reasoning' | 'queueMode';
78+
export type VisibleSetting = 'theme' | 'colorScheme' | 'fonts' | 'fontSize' | 'spacing' | 'cornerRadius' | 'inputBarOffset' | 'toolOutput' | 'diffLayout' | 'dotfiles' | 'reasoning' | 'queueMode' | 'autoOpenDiff';
7979

8080
const COLOR_SCHEME_OPTIONS: Array<{ id: string; label: string; lightThemeId: string; darkThemeId: string }> = [
8181
{ id: 'vercel', label: 'Vercel', lightThemeId: 'vercel-light', darkThemeId: 'vercel-dark' },
@@ -110,6 +110,8 @@ export const OpenChamberVisualSettings: React.FC<OpenChamberVisualSettingsProps>
110110
const setDiffLayoutPreference = useUIStore(state => state.setDiffLayoutPreference);
111111
const diffViewMode = useUIStore(state => state.diffViewMode);
112112
const setDiffViewMode = useUIStore(state => state.setDiffViewMode);
113+
const autoOpenDiff = useUIStore(state => state.autoOpenDiff);
114+
const setAutoOpenDiff = useUIStore(state => state.setAutoOpenDiff);
113115
const queueModeEnabled = useMessageQueueStore(state => state.queueModeEnabled);
114116
const setQueueMode = useMessageQueueStore(state => state.setQueueMode);
115117
const {
@@ -684,6 +686,25 @@ export const OpenChamberVisualSettings: React.FC<OpenChamberVisualSettingsProps>
684686
</p>
685687
</div>
686688
)}
689+
690+
{shouldShow('autoOpenDiff') && isVSCodeRuntime() && (
691+
<div className="space-y-2">
692+
<label className="flex items-center gap-2 cursor-pointer">
693+
<input
694+
type="checkbox"
695+
className="h-3.5 w-3.5 accent-primary"
696+
checked={autoOpenDiff}
697+
onChange={(event) => setAutoOpenDiff(event.target.checked)}
698+
/>
699+
<span className="typography-ui-header font-semibold text-foreground">
700+
Auto-open diff on file edit
701+
</span>
702+
</label>
703+
<p className="typography-meta text-muted-foreground pl-5">
704+
Automatically open VS Code diff view when AI edits a file.
705+
</p>
706+
</div>
707+
)}
687708
</div>
688709
);
689710
};

packages/ui/src/stores/useUIStore.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ interface UIStore {
6464
diffFileLayout: Record<string, 'inline' | 'side-by-side'>;
6565
diffWrapLines: boolean;
6666
diffViewMode: 'single' | 'stacked';
67+
autoOpenDiff: boolean;
6768
isTimelineDialogOpen: boolean;
6869
nativeNotificationsEnabled: boolean;
6970
notificationMode: 'always' | 'hidden-only';
@@ -115,6 +116,7 @@ interface UIStore {
115116
setDiffFileLayout: (filePath: string, mode: 'inline' | 'side-by-side') => void;
116117
setDiffWrapLines: (wrap: boolean) => void;
117118
setDiffViewMode: (mode: 'single' | 'stacked') => void;
119+
setAutoOpenDiff: (value: boolean) => void;
118120
setMultiRunLauncherOpen: (open: boolean) => void;
119121
setTimelineDialogOpen: (open: boolean) => void;
120122
setNativeNotificationsEnabled: (value: boolean) => void;
@@ -169,6 +171,7 @@ export const useUIStore = create<UIStore>()(
169171
diffFileLayout: {},
170172
diffWrapLines: false,
171173
diffViewMode: 'single',
174+
autoOpenDiff: true,
172175
isTimelineDialogOpen: false,
173176
nativeNotificationsEnabled: false,
174177
notificationMode: 'hidden-only',
@@ -434,6 +437,10 @@ export const useUIStore = create<UIStore>()(
434437
setDiffViewMode: (mode) => {
435438
set({ diffViewMode: mode });
436439
},
440+
441+
setAutoOpenDiff: (value) => {
442+
set({ autoOpenDiff: value });
443+
},
437444

438445
setInputBarOffset: (offset) => {
439446
set({ inputBarOffset: offset });
@@ -580,6 +587,7 @@ export const useUIStore = create<UIStore>()(
580587
diffLayoutPreference: state.diffLayoutPreference,
581588
diffWrapLines: state.diffWrapLines,
582589
diffViewMode: state.diffViewMode,
590+
autoOpenDiff: state.autoOpenDiff,
583591
nativeNotificationsEnabled: state.nativeNotificationsEnabled,
584592
notificationMode: state.notificationMode,
585593
})

packages/vscode/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@
134134
"category": "OpenChamber",
135135
"title": "Settings",
136136
"icon": "$(settings-gear)"
137+
},
138+
{
139+
"command": "openchamber.openSettings",
140+
"category": "OpenChamber",
141+
"title": "Open Settings in Editor",
142+
"icon": "$(settings-gear)"
137143
}
138144
],
139145
"submenus": [

0 commit comments

Comments
 (0)