Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 1 addition & 96 deletions desktop/frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,6 @@ const RIGHT_DOCK_MIN_RENDER_WIDTH = 280;
const RIGHT_DOCK_MAX_WIDTH = 860;

type RightDockMode = "context" | "files" | "changed";
type WorkspaceRevealRequest = { id: number; path: string };
type WorkspaceFileListRequest = { id: number; paths: string[] };
type WorkspaceChangeListEntry = { key: string; path: string; meta: string; time: string; detail: string };
type WorkspaceChangeListRequest = { id: number; changes: WorkspaceChangeListEntry[] };
const SHOW_CONTEXT_DOCK = true;
type HistoryScopeFilter = { scope: "global" | "project"; workspaceRoot: string };
type DesktopPlatform = "darwin" | "windows" | "linux";
Expand Down Expand Up @@ -923,10 +919,6 @@ export default function App() {
const [workspacePanelResizing, setWorkspacePanelResizing] = useState(false);
const [workspacePanelMaximized, setWorkspacePanelMaximized] = useState(false);
const [rightDockMode, setRightDockMode] = useState<RightDockMode>("context");
const [workspaceRevealRequest, setWorkspaceRevealRequest] = useState<WorkspaceRevealRequest | null>(null);
const [workspaceChangeRevealRequest, setWorkspaceChangeRevealRequest] = useState<WorkspaceRevealRequest | null>(null);
const [workspaceFileListRequest, setWorkspaceFileListRequest] = useState<WorkspaceFileListRequest | null>(null);
const [workspaceChangeListRequest, setWorkspaceChangeListRequest] = useState<WorkspaceChangeListRequest | null>(null);
const [dockRefreshKey, setDockRefreshKey] = useState(0);
const [projectRevision, setProjectRevision] = useState(0);
const [activeTopicTurns, setActiveTopicTurns] = useState<number | undefined>(undefined);
Expand Down Expand Up @@ -1851,87 +1843,10 @@ export default function App() {
openWorkspacePanel("context");
}, [closeWorkspacePanel, openWorkspacePanel, pulseWorkspaceToggle, workspacePanelRenderable]);

const clearWorkspaceRequests = useCallback(() => {
setWorkspaceRevealRequest(null);
setWorkspaceChangeRevealRequest(null);
setWorkspaceFileListRequest(null);
setWorkspaceChangeListRequest(null);
}, []);

useEffect(() => {
clearWorkspaceRequests();
}, [activeTabId, clearWorkspaceRequests]);

const openRightDockMode = useCallback(
(mode: RightDockMode) => {
clearWorkspaceRequests();
openWorkspacePanel(mode);
},
[clearWorkspaceRequests, openWorkspacePanel],
);

const openRightDockFile = useCallback(
(path: string) => {
const nextPath = path.trim();
if (!nextPath) return;
setWorkspaceFileListRequest(null);
setWorkspaceChangeListRequest(null);
setWorkspaceChangeRevealRequest(null);
setWorkspaceRevealRequest((current) => ({ id: (current?.id ?? 0) + 1, path: nextPath }));
openWorkspacePanel("files");
},
[openWorkspacePanel],
);

const openRightDockFileList = useCallback(
(paths: string[]) => {
const normalized = Array.from(new Set(paths.map((path) => path.trim()).filter(Boolean)));
setWorkspaceRevealRequest(null);
setWorkspaceChangeRevealRequest(null);
setWorkspaceChangeListRequest(null);
setWorkspaceFileListRequest((current) =>
normalized.length > 0
? { id: (current?.id ?? 0) + 1, paths: normalized }
: null,
);
openWorkspacePanel("files");
},
[openWorkspacePanel],
);

const openRightDockChangeFile = useCallback(
(path: string) => {
const nextPath = path.trim();
if (!nextPath) return;
setWorkspaceRevealRequest(null);
setWorkspaceFileListRequest(null);
setWorkspaceChangeListRequest(null);
setWorkspaceChangeRevealRequest((current) => ({ id: (current?.id ?? 0) + 1, path: nextPath }));
openWorkspacePanel("changed");
},
[openWorkspacePanel],
);

const openRightDockChangeList = useCallback(
(changes: WorkspaceChangeListEntry[]) => {
const seen = new Set<string>();
const normalized = changes
.map((change) => ({ ...change, path: change.path.trim() }))
.filter((change) => {
if (!change.path || seen.has(change.path)) return false;
seen.add(change.path);
return true;
});
setWorkspaceRevealRequest(null);
setWorkspaceChangeRevealRequest(null);
setWorkspaceFileListRequest(null);
setWorkspaceChangeListRequest((current) =>
normalized.length > 0
? { id: (current?.id ?? 0) + 1, changes: normalized }
: null,
);
openWorkspacePanel("changed");
},
[openWorkspacePanel],
);

Expand Down Expand Up @@ -1969,11 +1884,10 @@ export default function App() {

const handleTabChange = useCallback(async (id: string) => {
closeTransientOverlays();
clearWorkspaceRequests();
const tabs = await switchTab(id);
if (tabs) setTabMetas(tabs);
setTabRevealSignal((signal) => signal + 1);
}, [clearWorkspaceRequests, closeTransientOverlays, switchTab]);
}, [closeTransientOverlays, switchTab]);

const handleTabClose = useCallback(async (id: string) => {
closeTransientOverlays();
Expand Down Expand Up @@ -3098,11 +3012,6 @@ export default function App() {
sessionCurrency={state.sessionCurrency}
sessionGen={state.sessionGen}
refreshKey={dockRefreshKey}
onOpenWorkspaceMode={openRightDockMode}
onOpenWorkspaceFile={openRightDockFile}
onOpenWorkspaceFileList={openRightDockFileList}
onOpenWorkspaceChangeList={openRightDockChangeList}
onOpenWorkspaceChangeFile={openRightDockChangeFile}
/>
) : (
<WorkspacePanel
Expand All @@ -3121,10 +3030,6 @@ export default function App() {
onRequestPanelWidth={ensureWorkspacePanelWidth}
refreshKey={dockRefreshKey}
initialViewMode={rightDockMode === "changed" ? "changed" : "files"}
revealPathRequest={workspaceRevealRequest}
changeRevealRequest={workspaceChangeRevealRequest}
fileListRequest={workspaceFileListRequest}
changeListRequest={workspaceChangeListRequest}
showViewTabs={false}
/>
)}
Expand Down
34 changes: 34 additions & 0 deletions desktop/frontend/src/__tests__/project-tree-runtime.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Run: tsx src/__tests__/project-tree-runtime.test.ts

import {
projectTreeFolderDisclosure,
defaultExpandedProjectTreeKeys,
projectTreeTopicOpenRequest,
} from "../components/ProjectTree";
Expand Down Expand Up @@ -83,5 +84,38 @@ eq(
"regular project topic still opens by topic",
);

eq(
projectTreeFolderDisclosure(false, true),
{
canExpand: false,
isOpen: false,
ariaExpanded: undefined,
iconStackClassName: "project-tree__icon-stack",
},
"empty project folders are not exposed as expandable disclosure rows",
);

eq(
projectTreeFolderDisclosure(true, false),
{
canExpand: true,
isOpen: false,
ariaExpanded: false,
iconStackClassName: "project-tree__icon-stack project-tree__icon-stack--expandable",
},
"collapsed project folders keep disclosure semantics when children exist",
);

eq(
projectTreeFolderDisclosure(true, true),
{
canExpand: true,
isOpen: true,
ariaExpanded: true,
iconStackClassName: "project-tree__icon-stack project-tree__icon-stack--expandable",
},
"expanded project folders can show the open-folder state only when children exist",
);

console.log(`\n${passed} passed, ${failed} failed`);
if (failed > 0) process.exit(1);
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ for (const selector of [
".context-panel__section-head span",
".context-panel__metric span",
".context-panel__metric strong",
".context-panel__file-copy > span",
".topbar__model",
".composer-modebar__item span",
".composer-more-menu__item span",
Expand Down
Loading