remove stale homeRoot state from file viewer and dashboard creation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@ import { useClient } from 'hooks/useClient';
|
|||||||
import { useUserState } from 'state/useUserState';
|
import { useUserState } from 'state/useUserState';
|
||||||
import { useDashboardState } from 'state/useDashboardState';
|
import { useDashboardState } from 'state/useDashboardState';
|
||||||
import { WorkspaceLayout, WorkspaceView, createDefaultLayout } from '../../components/Workspace';
|
import { WorkspaceLayout, WorkspaceView, createDefaultLayout } from '../../components/Workspace';
|
||||||
import type { LayoutNode, DashboardDefinition, HomeRoot } from '../../components/Workspace';
|
import type { LayoutNode, DashboardDefinition } from '../../components/Workspace';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { generateSlug, slugify } from 'helpers/slug';
|
import { generateSlug, slugify } from 'helpers/slug';
|
||||||
import { FileBrowserApp } from '../FileBrowser';
|
import { FileBrowserApp } from '../FileBrowser';
|
||||||
@@ -276,7 +276,6 @@ const CreatePanel = () => {
|
|||||||
const client = useClient();
|
const client = useClient();
|
||||||
const [name, setName] = useGlobal<string>(NEW_DASH_NAME_KEY, '');
|
const [name, setName] = useGlobal<string>(NEW_DASH_NAME_KEY, '');
|
||||||
const [filePath] = useUserState<string>('files/currentPath', '/');
|
const [filePath] = useUserState<string>('files/currentPath', '/');
|
||||||
const [homeRoot] = useUserState<HomeRoot>('files/homeRoot', 'home');
|
|
||||||
const { value: dashboards, setValue: setDashboards } = useDashboardState<DashboardDefinition[]>('workspaces', []);
|
const { value: dashboards, setValue: setDashboards } = useDashboardState<DashboardDefinition[]>('workspaces', []);
|
||||||
|
|
||||||
const cwd = filePath === '/' ? '~' : `~/${filePath.replace(/^\//, '')}`;
|
const cwd = filePath === '/' ? '~' : `~/${filePath.replace(/^\//, '')}`;
|
||||||
@@ -338,7 +337,7 @@ const CreatePanel = () => {
|
|||||||
id,
|
id,
|
||||||
name: trimmed,
|
name: trimmed,
|
||||||
cwd,
|
cwd,
|
||||||
root: homeRoot !== 'home' ? homeRoot : undefined,
|
root: undefined,
|
||||||
description: desc || undefined,
|
description: desc || undefined,
|
||||||
templateIdx,
|
templateIdx,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
import { type ReactNode, useCallback } from 'react';
|
import { type ReactNode, useCallback } from 'react';
|
||||||
import { useSearchParams } from 'react-router';
|
import { useSearchParams } from 'react-router';
|
||||||
import { useUserState } from 'state/useUserState';
|
|
||||||
import { usePanelChannel } from 'hooks/usePanelChannel';
|
import { usePanelChannel } from 'hooks/usePanelChannel';
|
||||||
import { FileViewerProvider } from '../../apps/FileViewer';
|
import { FileViewerProvider } from '../../apps/FileViewer';
|
||||||
import { EmbeddableChat } from '../../apps/Chat/EmbeddableChat';
|
import { EmbeddableChat } from '../../apps/Chat/EmbeddableChat';
|
||||||
|
|
||||||
export function ViewerProvider({ children }: { children: ReactNode }) {
|
export function ViewerProvider({ children }: { children: ReactNode }) {
|
||||||
const [searchParams, setSearchParams] = useSearchParams();
|
const [searchParams, setSearchParams] = useSearchParams();
|
||||||
const [homeRoot] = useUserState<string>('files/homeRoot', 'home');
|
|
||||||
const viewPath = searchParams.get('view') ?? '';
|
const viewPath = searchParams.get('view') ?? '';
|
||||||
const fileName = viewPath.split('/').pop() ?? '';
|
const fileName = viewPath.split('/').pop() ?? '';
|
||||||
|
|
||||||
@@ -21,7 +19,7 @@ export function ViewerProvider({ children }: { children: ReactNode }) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FileViewerProvider filePath={viewPath} fileName={fileName} root={homeRoot} onOpenFile={onOpenFile}>
|
<FileViewerProvider filePath={viewPath} fileName={fileName} onOpenFile={onOpenFile}>
|
||||||
{children}
|
{children}
|
||||||
</FileViewerProvider>
|
</FileViewerProvider>
|
||||||
);
|
);
|
||||||
@@ -66,12 +64,9 @@ export function Ephemeral2Provider({ children }: { children: ReactNode }) {
|
|||||||
|
|
||||||
export const ChatEphemeralBody = () => {
|
export const ChatEphemeralBody = () => {
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const [homeRoot] = useUserState<string>('files/homeRoot', 'home');
|
|
||||||
const [, setRefreshSignal] = usePanelChannel<number>('files:refresh-signal', 0);
|
const [, setRefreshSignal] = usePanelChannel<number>('files:refresh-signal', 0);
|
||||||
const chatContext = searchParams.get('chatContext') ?? '';
|
const chatContext = searchParams.get('chatContext') ?? '';
|
||||||
const chatType = searchParams.get('chatType') as 'file' | 'folder' | null;
|
const chatType = searchParams.get('chatType') as 'file' | 'folder' | null;
|
||||||
const hostRoot = homeRoot === '~' || homeRoot === 'officer.dev';
|
|
||||||
const sandboxed = !hostRoot;
|
|
||||||
|
|
||||||
const cwdPath = chatType === 'file'
|
const cwdPath = chatType === 'file'
|
||||||
? chatContext.substring(0, chatContext.lastIndexOf('/')) || '/'
|
? chatContext.substring(0, chatContext.lastIndexOf('/')) || '/'
|
||||||
@@ -90,8 +85,7 @@ export const ChatEphemeralBody = () => {
|
|||||||
return (
|
return (
|
||||||
<EmbeddableChat
|
<EmbeddableChat
|
||||||
className="h-full"
|
className="h-full"
|
||||||
cwd={{ root: homeRoot, path: cwdPath.replace(/^\//, '') || '/' }}
|
cwd={{ root: 'home', path: cwdPath.replace(/^\//, '') || '/' }}
|
||||||
sandboxed={sandboxed}
|
|
||||||
defaultInput={message}
|
defaultInput={message}
|
||||||
onMessageComplete={handleMessageComplete}
|
onMessageComplete={handleMessageComplete}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user