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