stop the framework carrying file-browser vocabulary
`initialFilePath` and `defaultFileSort` were declared on the workspace context, plumbed through
`WorkspaceView`'s props and read by exactly one panel wrapper — and set by zero callers. The sort
shape in particular (`{field: 'name'|'size'|'type'|'date', direction}`) is file-browser vocabulary
sitting in the framework's type file and re-exported from two barrels, so every app that imports the
context could see it.
Nothing changes at runtime: both were always undefined, which is what the wrapper now passes by
omitting them.
This commit is contained in:
+2
-3
@@ -4,8 +4,7 @@ import { FileBrowserApp } from './FileBrowserApp';
|
|||||||
const cwdToPath = (cwd: string) => (cwd === '~' ? '/' : cwd.slice(1));
|
const cwdToPath = (cwd: string) => (cwd === '~' ? '/' : cwd.slice(1));
|
||||||
|
|
||||||
export const FileBrowserPanelWrapper = () => {
|
export const FileBrowserPanelWrapper = () => {
|
||||||
const { cwd, initialFilePath, defaultFileSort } = useWorkspace();
|
const { cwd } = useWorkspace();
|
||||||
const basePath = cwdToPath(cwd);
|
const basePath = cwdToPath(cwd);
|
||||||
const initialPath = basePath === '/' ? initialFilePath : undefined;
|
return <FileBrowserApp basePath={basePath} rootOverride={basePath !== '/' ? 'home' : undefined} />;
|
||||||
return <FileBrowserApp basePath={basePath} rootOverride={basePath !== '/' ? 'home' : undefined} initialPath={initialPath} defaultSort={defaultFileSort} />;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,18 +4,11 @@ import type { DropPosition } from './layout-utils';
|
|||||||
import type { PanelConfig } from './types';
|
import type { PanelConfig } from './types';
|
||||||
import type { WorkspaceIdentity } from './workspace-identity';
|
import type { WorkspaceIdentity } from './workspace-identity';
|
||||||
|
|
||||||
export type DefaultFileSort = {
|
|
||||||
field: 'name' | 'size' | 'type' | 'date';
|
|
||||||
direction: 'asc' | 'desc';
|
|
||||||
};
|
|
||||||
|
|
||||||
type WorkspaceContextValue = {
|
type WorkspaceContextValue = {
|
||||||
/** Which dashboard or screen this panel is on. Null in a preview or a settings pane. */
|
/** Which dashboard or screen this panel is on. Null in a preview or a settings pane. */
|
||||||
workspace: WorkspaceIdentity | null;
|
workspace: WorkspaceIdentity | null;
|
||||||
cwd: string;
|
cwd: string;
|
||||||
root?: string;
|
root?: string;
|
||||||
initialFilePath?: string;
|
|
||||||
defaultFileSort?: DefaultFileSort;
|
|
||||||
promptPrefix?: string;
|
promptPrefix?: string;
|
||||||
// Per-panel app settings, by panel id. A map rather than a getter so a config change re-renders the
|
// Per-panel app settings, by panel id. A map rather than a getter so a config change re-renders the
|
||||||
// panel that owns it — apps read this through `usePanelConfig`, not directly.
|
// panel that owns it — apps read this through `usePanelConfig`, not directly.
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { ResizablePanel, ResizablePanelGroup, ResizableHandle } from '@/componen
|
|||||||
import { useIsMobile } from 'hooks/useIsMobile';
|
import { useIsMobile } from 'hooks/useIsMobile';
|
||||||
import { useSessionState } from 'hooks/useSessionState';
|
import { useSessionState } from 'hooks/useSessionState';
|
||||||
import type { LayoutNode, DashboardState, EphemeralPanels, PanelComponents, PanelConfig } from './types';
|
import type { LayoutNode, DashboardState, EphemeralPanels, PanelComponents, PanelConfig } from './types';
|
||||||
import type { DefaultFileSort } from './WorkspaceContext';
|
|
||||||
import type { DropPosition } from './layout-utils';
|
import type { DropPosition } from './layout-utils';
|
||||||
import { splitPanel, removePanel, setApp, updateSizes, swapPanels, movePanel, countPanels, setZoom, setPanelConfig, collectPanelConfigs } from './layout-utils';
|
import { splitPanel, removePanel, setApp, updateSizes, swapPanels, movePanel, countPanels, setZoom, setPanelConfig, collectPanelConfigs } from './layout-utils';
|
||||||
import { WorkspaceProvider } from './WorkspaceContext';
|
import { WorkspaceProvider } from './WorkspaceContext';
|
||||||
@@ -17,8 +16,6 @@ type WorkspaceViewProps = {
|
|||||||
locked?: boolean;
|
locked?: boolean;
|
||||||
cwd?: string;
|
cwd?: string;
|
||||||
root?: string;
|
root?: string;
|
||||||
initialFilePath?: string;
|
|
||||||
defaultFileSort?: DefaultFileSort;
|
|
||||||
promptPrefix?: string;
|
promptPrefix?: string;
|
||||||
components?: PanelComponents;
|
components?: PanelComponents;
|
||||||
ephemeral?: EphemeralPanels | null;
|
ephemeral?: EphemeralPanels | null;
|
||||||
@@ -28,7 +25,7 @@ type WorkspaceViewProps = {
|
|||||||
|
|
||||||
const noop = () => {};
|
const noop = () => {};
|
||||||
|
|
||||||
export const WorkspaceView = ({ workspace, locked, cwd = '~', root, initialFilePath, defaultFileSort, promptPrefix, components, ephemeral, mobilePanelId, onMobilePanelChange }: WorkspaceViewProps) => {
|
export const WorkspaceView = ({ workspace, locked, cwd = '~', root, promptPrefix, components, ephemeral, mobilePanelId, onMobilePanelChange }: WorkspaceViewProps) => {
|
||||||
const { registry } = useAppRegistry();
|
const { registry } = useAppRegistry();
|
||||||
const isMobile = useIsMobile();
|
const isMobile = useIsMobile();
|
||||||
|
|
||||||
@@ -193,8 +190,6 @@ export const WorkspaceView = ({ workspace, locked, cwd = '~', root, initialFileP
|
|||||||
workspace: identity,
|
workspace: identity,
|
||||||
cwd,
|
cwd,
|
||||||
root,
|
root,
|
||||||
initialFilePath,
|
|
||||||
defaultFileSort,
|
|
||||||
promptPrefix,
|
promptPrefix,
|
||||||
panelConfigs,
|
panelConfigs,
|
||||||
setPanelConfig: locked ? noop : handleSetPanelConfig,
|
setPanelConfig: locked ? noop : handleSetPanelConfig,
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ export {
|
|||||||
setPanelConfig,
|
setPanelConfig,
|
||||||
collectPanelConfigs,
|
collectPanelConfigs,
|
||||||
} from './layout-utils';
|
} from './layout-utils';
|
||||||
export type { DefaultFileSort } from './WorkspaceContext';
|
|
||||||
export type { WorkspaceIdentity } from './workspace-identity';
|
export type { WorkspaceIdentity } from './workspace-identity';
|
||||||
export { parseWorkspaceKey } from './workspace-identity';
|
export { parseWorkspaceKey } from './workspace-identity';
|
||||||
export { WorkspaceProvider, useWorkspace } from './WorkspaceContext';
|
export { WorkspaceProvider, useWorkspace } from './WorkspaceContext';
|
||||||
|
|||||||
@@ -141,5 +141,4 @@ export type {
|
|||||||
EphemeralPanels,
|
EphemeralPanels,
|
||||||
DropPosition,
|
DropPosition,
|
||||||
HomeRoot,
|
HomeRoot,
|
||||||
DefaultFileSort,
|
|
||||||
} from './components/Workspace';
|
} from './components/Workspace';
|
||||||
|
|||||||
Reference in New Issue
Block a user