From 686215a0b098d9f12a0f64d174028659832ec849 Mon Sep 17 00:00:00 2001 From: BytePioneer-AI <28417416@qq.com> Date: Sat, 28 Nov 2026 13:22:11 +0800 Subject: [PATCH] feat(web-ui): label remote fallback workspaces as Uncategorized and filter from pickers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remote peers synthesize a per-host fallback workspace (path = "") for remote sessions outside any registered project, previously reusing the host's display name (e.g. "C") and rendering with a standard folder icon. Under All Hosts this duplicated the host name ("C / C"), under single-host filtering it looked like a duplicate folder named after the host, and the uncreatable bucket also appeared in new-session workspace pickers. Add a shared frontend predicate isRemoteFallbackWorkspace() (preserving backend contracts, workspaceId, displayOrder, pinning, and host filtering): - Display the localized "未归类" / "Uncategorized" label across sidebar rows, search context, hover cards, and HostScopeFilter. - Render IconQueueOutlineRegular instead of a folder icon so the bucket is visually distinct from real project directories. - Exclude remote fallback workspaces from HeroLocationWorkspacePicker, WorkspacePickFlow, and filterHeroProjects while keeping zero-project remote hosts selectable as locations. --- .../client/HeroLocationWorkspacePicker.tsx | 5 +- .../src/client/WorkspacePicker.tsx | 5 +- .../src/client/hero-picker-model.ts | 16 +++-- .../client/ui-workspace/src/client/locales.ts | 2 + .../src/client/rows/HostScopeFilter.tsx | 8 ++- .../ui-workspace/src/client/rows/Rows.tsx | 25 +++++-- .../src/client/rows/WorkspaceBrowser.tsx | 10 ++- .../src/client/rows/host-scope-filter.ts | 15 ++++ .../test/hero-picker-model.test.ts | 69 +++++++++++++++++++ 9 files changed, 139 insertions(+), 16 deletions(-) diff --git a/apps/web-ui/packages/client/ui-workspace/src/client/HeroLocationWorkspacePicker.tsx b/apps/web-ui/packages/client/ui-workspace/src/client/HeroLocationWorkspacePicker.tsx index 68192093ff..2121476c7a 100644 --- a/apps/web-ui/packages/client/ui-workspace/src/client/HeroLocationWorkspacePicker.tsx +++ b/apps/web-ui/packages/client/ui-workspace/src/client/HeroLocationWorkspacePicker.tsx @@ -43,6 +43,7 @@ import { type ConfiguredRemotePeer, type HeroLocationOption, } from "./hero-picker-model.ts"; +import { isRemoteFallbackWorkspace } from "./rows/host-scope-filter.ts"; import css from "./HeroLocationWorkspacePicker.module.css"; const ADD_REMOTE_WORKSPACE_EVENT = "codexhost:open-add-remote-workspace"; @@ -529,7 +530,9 @@ export function HeroLocationWorkspacePicker({ () => selectedId === undefined ? undefined - : workspaces.find((item) => item.workspaceId === selectedId), + : workspaces.find( + (item) => item.workspaceId === selectedId && !isRemoteFallbackWorkspace(item), + ), [selectedId, workspaces], ); diff --git a/apps/web-ui/packages/client/ui-workspace/src/client/WorkspacePicker.tsx b/apps/web-ui/packages/client/ui-workspace/src/client/WorkspacePicker.tsx index 7234025859..2ae8778c97 100644 --- a/apps/web-ui/packages/client/ui-workspace/src/client/WorkspacePicker.tsx +++ b/apps/web-ui/packages/client/ui-workspace/src/client/WorkspacePicker.tsx @@ -28,6 +28,7 @@ import { workspaceDisplayTitle } from "@deepseek-ai/dsh-api-workspace-controller import type { SnapshotSelectorHook } from "@deepseek-ai/dsh-client-ui-slots"; import type { DirectoryFlowOwnerProps, WorkspacePickerProps } from "./contract/slots.ts"; import { HeroLocationWorkspacePicker } from "./HeroLocationWorkspacePicker.tsx"; +import { isRemoteFallbackWorkspace } from "./rows/host-scope-filter.ts"; import css from "./WorkspacePicker.module.css"; const ADD_WORKSPACE = "::add-workspace"; @@ -87,7 +88,9 @@ export function WorkspacePickFlow({ selectedId, }: WorkspacePickFlowProps) { const workspaceSnapshot = useWorkspaces((state) => state); - const workspaces = workspaceSnapshot.items; + const workspaces = workspaceSnapshot.items.filter( + (workspace) => !isRemoteFallbackWorkspace(workspace), + ); const getAnchorRect = useCallback( () => anchorRef?.current?.getBoundingClientRect() ?? null, [anchorRef], diff --git a/apps/web-ui/packages/client/ui-workspace/src/client/hero-picker-model.ts b/apps/web-ui/packages/client/ui-workspace/src/client/hero-picker-model.ts index 2d8684d32c..13e2874e45 100644 --- a/apps/web-ui/packages/client/ui-workspace/src/client/hero-picker-model.ts +++ b/apps/web-ui/packages/client/ui-workspace/src/client/hero-picker-model.ts @@ -5,7 +5,11 @@ * compact parent-folder hints. */ import type { WorkspaceView } from "@deepseek-ai/dsh-api-workspace-controller/client"; -import { deriveAvailableHosts, type HostSummary } from "./rows/host-scope-filter.ts"; +import { + deriveAvailableHosts, + isRemoteFallbackWorkspace, + type HostSummary, +} from "./rows/host-scope-filter.ts"; export interface ConfiguredRemotePeer { readonly hostId: string; @@ -41,7 +45,10 @@ export function buildHeroLocationOptions( const remoteByHostId = new Map(); for (const host of derived) { if (host.key === "local" || host.hostId === undefined) continue; - remoteByHostId.set(host.hostId, host); + remoteByHostId.set(host.hostId, { + ...host, + workspaces: host.workspaces.filter((workspace) => !isRemoteFallbackWorkspace(workspace)), + }); } for (const peer of configuredPeers) { @@ -103,9 +110,10 @@ export function filterHeroProjects( query: string, titleOf: (workspace: WorkspaceView) => string, ): WorkspaceView[] { + const selectable = projects.filter((workspace) => !isRemoteFallbackWorkspace(workspace)); const needle = query.trim().toLowerCase(); - if (needle === "") return [...projects]; - return projects.filter((workspace) => { + if (needle === "") return selectable; + return selectable.filter((workspace) => { const title = titleOf(workspace).toLowerCase(); const path = (workspace.path ?? "").toLowerCase(); return title.includes(needle) || path.includes(needle); diff --git a/apps/web-ui/packages/client/ui-workspace/src/client/locales.ts b/apps/web-ui/packages/client/ui-workspace/src/client/locales.ts index c4474a44c3..944b30e314 100644 --- a/apps/web-ui/packages/client/ui-workspace/src/client/locales.ts +++ b/apps/web-ui/packages/client/ui-workspace/src/client/locales.ts @@ -67,6 +67,7 @@ export const zh = { "recent.clearAllHint": "关闭所有标签,不删除会话或停止任务", "recent.cache.error": "无法读取或保存会话标签。仍可在本页切换会话,刷新后标签可能丢失。", "group.ungrouped": "最近", + "group.remoteOtherSessions": "未归类", "session.new": "新会话", "session.untitled": "未命名", "session.backToList": "返回会话列表", @@ -311,6 +312,7 @@ export const en = { "recent.cache.error": "Could not read or save session tabs. Switching still works in this page; tabs may be lost on reload.", "group.ungrouped": "Recents", + "group.remoteOtherSessions": "Uncategorized", "session.new": "New Session", "session.untitled": "Untitled", "session.backToList": "Back to session list", diff --git a/apps/web-ui/packages/client/ui-workspace/src/client/rows/HostScopeFilter.tsx b/apps/web-ui/packages/client/ui-workspace/src/client/rows/HostScopeFilter.tsx index 636881e200..92409a5d2d 100644 --- a/apps/web-ui/packages/client/ui-workspace/src/client/rows/HostScopeFilter.tsx +++ b/apps/web-ui/packages/client/ui-workspace/src/client/rows/HostScopeFilter.tsx @@ -23,6 +23,7 @@ import { deriveAvailableHosts, hasRemoteWorkspaces, isHostScopeFiltered, + isRemoteFallbackWorkspace, reconcileHostScopeFilter, resetHostScopeFilter, selectHostScope, @@ -79,6 +80,7 @@ function HostScopeWorkspacesEditor({ [host.workspaces], ); const selectedCount = countSelectedWorkspacesForHost(host, scope); + const hostName = hostDisplayLabel(host, t); return (
@@ -145,11 +147,13 @@ function HostScopeWorkspacesEditor({
{host.workspaces.map((workspace) => { const checked = selectedIds.has(workspace.workspaceId); + const isFallback = isRemoteFallbackWorkspace(workspace); + const label = isFallback ? t("group.remoteOtherSessions") : workspace.title; return ( ); })} diff --git a/apps/web-ui/packages/client/ui-workspace/src/client/rows/Rows.tsx b/apps/web-ui/packages/client/ui-workspace/src/client/rows/Rows.tsx index 91429c2a16..c9a29d907d 100644 --- a/apps/web-ui/packages/client/ui-workspace/src/client/rows/Rows.tsx +++ b/apps/web-ui/packages/client/ui-workspace/src/client/rows/Rows.tsx @@ -24,6 +24,7 @@ import { IconNewChatOutlineRegular, IconPinFillRegular, IconPinOutlineRegular, + IconQueueOutlineRegular, IconTrashOutlineRegular, IconUnarchiveOutlineRegular, Menu, @@ -44,6 +45,7 @@ import { SessionRowContent } from "./SessionRowContent.tsx"; import { sessionStatuses, SessionStatusDots } from "./session-status.tsx"; import css from "./Rows.module.css"; import { HostBadge } from "./HostBadge.tsx"; +import { isRemoteFallbackWorkspace } from "./host-scope-filter.ts"; import { useThreadTreeView } from "./ThreadTreeView.tsx"; import { ThreadTreeSummary, useThreadChildGroup } from "./ThreadTreeControls.tsx"; import { ThreadTreeRing } from "./ThreadTreeRing.tsx"; @@ -228,8 +230,15 @@ export function ProjectRowItem({ ]; const actions = group.remote ? undefined : suppliedActions; const drag = suppliedDrag; - // The ungrouped bucket has no workspace title: its label is dictionary copy. - const label = row.workspaceId === undefined ? t("group.ungrouped") : row.label; + const isRemoteFallback = isRemoteFallbackWorkspace(row); + // The ungrouped bucket has no workspace title; remote fallback groups use the + // localized "Uncategorized" label instead of repeating the remote host name. + const label = + row.workspaceId === undefined + ? t("group.ungrouped") + : isRemoteFallback + ? t("group.remoteOtherSessions") + : row.label; const remoteColor = row.remote !== undefined ? resolveRemotePeerColor(row.remote.hostId, row.remote.color) @@ -291,7 +300,13 @@ export function ProjectRowItem({ onDragEnd={drag?.end} > - {row.expanded ? : } + {isRemoteFallback ? ( + + ) : row.expanded ? ( + + ) : ( + + )} {showRemoteIndicator && row.remote && remoteColor !== undefined && ( )} @@ -364,7 +379,7 @@ export function ProjectRowItem({ } /> )} - {(!row.remote || (row.remote.state === "connected" && !!group.cwd)) && ( + {(!row.remote || (row.remote.state === "connected" && !isRemoteFallback)) && ( state); const storedWorkspaces = useWorkspaces((state) => state.items); const canStartProjectless = useWorkspaces((state) => state.canStartProjectless === true); - // The resolved name, not `t`, is the memo dependency: the bound seat keeps + // The resolved names, not `t`, are the memo dependencies: the bound seat keeps // its identity across a language switch. const defaultWorkspaceName = t("workspace.defaultName"); + const remoteOtherSessionsLabel = t("group.remoteOtherSessions"); const workspaces = useMemo( () => storedWorkspaces.map((workspace) => ({ ...workspace, - title: workspaceDisplayTitle(workspace.title, defaultWorkspaceName), + title: isRemoteFallbackWorkspace(workspace) + ? remoteOtherSessionsLabel + : workspaceDisplayTitle(workspace.title, defaultWorkspaceName), })), - [storedWorkspaces, defaultWorkspaceName], + [storedWorkspaces, defaultWorkspaceName, remoteOtherSessionsLabel], ); const workspacePhase = useWorkspaces((state) => state.phase); const workspaceStreamState = useWorkspaces((state) => state.state); diff --git a/apps/web-ui/packages/client/ui-workspace/src/client/rows/host-scope-filter.ts b/apps/web-ui/packages/client/ui-workspace/src/client/rows/host-scope-filter.ts index 90c89e1f81..41f6508d19 100644 --- a/apps/web-ui/packages/client/ui-workspace/src/client/rows/host-scope-filter.ts +++ b/apps/web-ui/packages/client/ui-workspace/src/client/rows/host-scope-filter.ts @@ -64,6 +64,21 @@ export function hasRemoteWorkspaces(workspaces: readonly WorkspaceView[]): boole return workspaces.some((workspace) => workspace.remote !== undefined); } +/** + * Whether a workspace or derived group is the synthetic per-host fallback bucket + * for remote sessions outside any registered remote project (or a host placeholder + * when a remote host has zero projects). + */ +export function isRemoteFallbackWorkspace(workspace: { + readonly remote?: unknown; + readonly path?: string | undefined; + readonly cwd?: string | undefined; +}): boolean { + if (workspace.remote === undefined) return false; + const dir = workspace.path ?? workspace.cwd; + return dir === undefined || dir.trim() === ""; +} + /** Whether any workspace belongs to a peer-hub remote host (`remote-peer:*`). */ export function hasRemotePeerWorkspaces(workspaces: readonly WorkspaceView[]): boolean { return workspaces.some( diff --git a/apps/web-ui/packages/client/ui-workspace/test/hero-picker-model.test.ts b/apps/web-ui/packages/client/ui-workspace/test/hero-picker-model.test.ts index e351b3bbb8..eabc74c522 100644 --- a/apps/web-ui/packages/client/ui-workspace/test/hero-picker-model.test.ts +++ b/apps/web-ui/packages/client/ui-workspace/test/hero-picker-model.test.ts @@ -10,6 +10,7 @@ import { parseConfiguredRemotePeers, workspaceParentHint, } from "../src/client/hero-picker-model.ts"; +import { isRemoteFallbackWorkspace } from "../src/client/rows/host-scope-filter.ts"; function makeWorkspace(overrides: Partial & { workspaceId: string }): WorkspaceView { return { @@ -114,6 +115,74 @@ describe("hero-picker-model", () => { ); }); + it("identifies remote fallback workspaces and excludes them from selectable hero projects while keeping 0-project hosts", () => { + const localWs = makeWorkspace({ + workspaceId: "ws-local", + title: "codex-host", + path: "/Users/me/Code/codex-host", + }); + const localEmptyPath = makeWorkspace({ + workspaceId: "ws-local-empty", + title: "local-empty", + path: "", + }); + const remoteReal = makeWorkspace({ + workspaceId: "ws-c-proj", + title: "web-app", + path: "/srv/web-app", + remote: { hostId: "remote-peer:c", displayName: "C", state: "connected" }, + }); + const remoteFallbackWithReal = makeWorkspace({ + workspaceId: "ws-c-fallback", + title: "C", + path: "", + remote: { hostId: "remote-peer:c", displayName: "C", state: "connected" }, + }); + const remoteZeroProjectPlaceholder = makeWorkspace({ + workspaceId: "ws-d-fallback", + title: "D", + path: "", + remote: { hostId: "remote-peer:d", displayName: "D", state: "disconnected" }, + }); + + assert.equal(isRemoteFallbackWorkspace(localWs), false); + assert.equal(isRemoteFallbackWorkspace(localEmptyPath), false); + assert.equal(isRemoteFallbackWorkspace(remoteReal), false); + assert.equal(isRemoteFallbackWorkspace(remoteFallbackWithReal), true); + assert.equal(isRemoteFallbackWorkspace(remoteZeroProjectPlaceholder), true); + assert.equal(isRemoteFallbackWorkspace({ remote: remoteReal.remote, cwd: " " }), true); + + const locations = buildHeroLocationOptions( + [localWs, remoteReal, remoteFallbackWithReal, remoteZeroProjectPlaceholder], + [], + ); + assert.deepEqual( + locations.map((item) => ({ + key: item.key, + name: item.displayName, + workspaceIds: item.workspaces.map((w) => w.workspaceId), + })), + [ + { key: "local", name: undefined, workspaceIds: ["ws-local"] }, + { key: "remote-peer:c", name: "C", workspaceIds: ["ws-c-proj"] }, + { key: "remote-peer:d", name: "D", workspaceIds: [] }, + ], + ); + + assert.deepEqual( + filterHeroProjects([remoteReal, remoteFallbackWithReal], "", (w) => w.title).map( + (w) => w.workspaceId, + ), + ["ws-c-proj"], + ); + assert.deepEqual( + filterHeroProjects([remoteReal, remoteFallbackWithReal], "c", (w) => w.title).map( + (w) => w.workspaceId, + ), + [], + ); + }); + it("derives immediate parent folder hints without redundant or root segments", () => { assert.equal(workspaceParentHint("/Users/me/Code/codex-host", "codex-host"), "Code"); assert.equal(workspaceParentHint("/Users/me", "me"), undefined);