feat(webui): add a host directory picker and refine composer controls

This commit is contained in:
chengyongru authored and chengyongru committed 2026-10-08 20:33:15 +08:00
1 parent 3865bde3fe
commit 66c8d41f66
32 files changed
+1974 -464

No files matched your search

+32 -1
View File
@@ -41,6 +41,8 @@ import {
fetchInstalledCliApps,
fetchMcpPresets,
fetchSettings,
fetchWorkspaces,
fetchWorkspaceDirectories,
fetchWebuiThreadTraceDetail,
listSlashCommands,
} from "@/lib/api";
@@ -66,6 +68,7 @@ import type {
UIMessage,
WorkspaceScopePayload,
WorkspacesPayload,
ProjectDirectory,
} from "@/lib/types";
import { projectThreadEvents } from "@/lib/thread-event-projection";
import { projectWebuiThreadMessages } from "@/lib/thread-display-projection";
@@ -707,6 +710,23 @@ export function ThreadShell({
);
return typeof response.path === "string" ? response.path : null;
}, [client]);
const favoriteWorkspaceProject = useCallback(
async (path: string, pinned: boolean) => {
const response = await client.requestMutation<{ favorite_projects: ProjectDirectory[] }>("workspace.favorite", { path, pinned });
return response.favorite_projects;
},
[client],
);
const resolveWorkspaceProject = useCallback(
(path: string) => client.requestMutation<ProjectDirectory>("workspace.resolve_project", { path }),
[client],
);
const loadWorkspaceProjects = useCallback(() => fetchWorkspaces(getToken()), [getToken]);
const browseWorkspaceDirectories = useCallback(
(path: string, query: string, showHidden: boolean, allowPartial = false) =>
fetchWorkspaceDirectories(getToken(), path, query, showHidden, allowPartial),
[getToken],
);
const [booting, setBooting] = useState(false);
const [slashCommands, setSlashCommands] = useState<SlashCommand[]>([]);
const [mentionCatalogRequestCount, setMentionCatalogRequestCount] = useState(0);
@@ -756,6 +776,7 @@ export function ThreadShell({
}, [draftKey]);
const [composerFocusSignal, setComposerFocusSignal] = useState(0);
const shellRef = useRef<HTMLElement | null>(null);
const [conversationElement, setConversationElement] = useState<HTMLDivElement | null>(null);
const composerSurfaceRef = useRef<HTMLDivElement | null>(null);
const filePreviewWidthRef = useRef(FILE_PREVIEW_DEFAULT_WIDTH);
const filePreviewCloseTimerRef = useRef<number | null>(null);
@@ -1770,6 +1791,11 @@ export function ThreadShell({
onStop={stop}
onTranscribeAudio={transcribeAudio}
goalState={currentGoalState}
onFavoriteWorkspaceProject={favoriteWorkspaceProject}
onResolveWorkspaceProject={resolveWorkspaceProject}
onLoadWorkspaceProjects={loadWorkspaceProjects}
workspacePickerLayoutAnchor={conversationElement}
onBrowseWorkspaceDirectories={browseWorkspaceDirectories}
workspaceScope={workspaceScope}
workspaceControlsHidden={temporary}
workspaceDefaultScope={workspaceDefaultScope}
@@ -1824,6 +1850,11 @@ export function ThreadShell({
surfaceRef={composerSurfaceRef}
onTranscribeAudio={transcribeAudio}
goalState={currentGoalState}
onFavoriteWorkspaceProject={favoriteWorkspaceProject}
onResolveWorkspaceProject={resolveWorkspaceProject}
onLoadWorkspaceProjects={loadWorkspaceProjects}
workspacePickerLayoutAnchor={conversationElement}
onBrowseWorkspaceDirectories={browseWorkspaceDirectories}
workspaceScope={workspaceScope}
workspaceControlsHidden={temporary}
workspaceDefaultScope={workspaceDefaultScope}
@@ -1893,7 +1924,7 @@ export function ThreadShell({
active={composerActive}
enabled={!temporary && !!session?.key.startsWith("websocket:") && webuiCapabilities.includes("webui.subagents.v1")}>
<section ref={shellRef} data-preview-open={previewOpen || undefined} className="thread-preview-layout relative flex min-h-0 flex-1 overflow-hidden">
<div className={cn(
<div ref={setConversationElement} className={cn(
"thread-conversation relative flex min-w-0 flex-1 flex-col overflow-hidden",
headerPortalTarget === undefined && !hideHeader && "thread-workspace",
)}>