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
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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],
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -41,7 +45,10 @@ export function buildHeroLocationOptions(
const remoteByHostId = new Map<string, HeroLocationOption>();
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) {
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export const zh = {
"recent.clearAllHint": "关闭所有标签,不删除会话或停止任务",
"recent.cache.error": "无法读取或保存会话标签。仍可在本页切换会话,刷新后标签可能丢失。",
"group.ungrouped": "最近",
"group.remoteOtherSessions": "未归类",
"session.new": "新会话",
"session.untitled": "未命名",
"session.backToList": "返回会话列表",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
deriveAvailableHosts,
hasRemoteWorkspaces,
isHostScopeFiltered,
isRemoteFallbackWorkspace,
reconcileHostScopeFilter,
resetHostScopeFilter,
selectHostScope,
Expand Down Expand Up @@ -79,6 +80,7 @@ function HostScopeWorkspacesEditor({
[host.workspaces],
);
const selectedCount = countSelectedWorkspacesForHost(host, scope);
const hostName = hostDisplayLabel(host, t);

return (
<div className={css.scopeEditor}>
Expand Down Expand Up @@ -145,11 +147,13 @@ function HostScopeWorkspacesEditor({
<div className={css.workspaceList}>
{host.workspaces.map((workspace) => {
const checked = selectedIds.has(workspace.workspaceId);
const isFallback = isRemoteFallbackWorkspace(workspace);
const label = isFallback ? t("group.remoteOtherSessions") : workspace.title;
return (
<label
key={workspace.workspaceId}
className={css.workspaceOption}
title={workspace.path || workspace.title}
title={isFallback ? `${hostName} · ${label}` : workspace.path || label}
>
<input
type="checkbox"
Expand All @@ -166,7 +170,7 @@ function HostScopeWorkspacesEditor({
);
}}
/>
<span className={css.workspaceOptionName}>{workspace.title}</span>
<span className={css.workspaceOptionName}>{label}</span>
</label>
);
})}
Expand Down
25 changes: 20 additions & 5 deletions apps/web-ui/packages/client/ui-workspace/src/client/rows/Rows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
IconNewChatOutlineRegular,
IconPinFillRegular,
IconPinOutlineRegular,
IconQueueOutlineRegular,
IconTrashOutlineRegular,
IconUnarchiveOutlineRegular,
Menu,
Expand All @@ -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";
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -291,7 +300,13 @@ export function ProjectRowItem({
onDragEnd={drag?.end}
>
<span className={clsx(css.slot, row.expanded && css.folderExpanded)}>
{row.expanded ? <IconFolderOpenRegular /> : <IconFolderCloseRegular />}
{isRemoteFallback ? (
<IconQueueOutlineRegular size={16} />
) : row.expanded ? (
<IconFolderOpenRegular />
) : (
<IconFolderCloseRegular />
)}
{showRemoteIndicator && row.remote && remoteColor !== undefined && (
<RemoteFolderGlobe color={remoteColor} state={row.remote.state} />
)}
Expand Down Expand Up @@ -364,7 +379,7 @@ export function ProjectRowItem({
}
/>
)}
{(!row.remote || (row.remote.state === "connected" && !!group.cwd)) && (
{(!row.remote || (row.remote.state === "connected" && !isRemoteFallback)) && (
<Tooltip
label={t("actions.newSession")}
shortcutKeys={newShortcut?.keys}
Expand Down Expand Up @@ -414,7 +429,7 @@ export function ProjectRowItem({
anchor={ownRow}
content={
<WorkspaceHoverContent
label={row.label}
label={label}
cwd={cwd === undefined ? undefined : abbreviateHomePath(cwd, home)}
createdAt={row.createdAt}
t={t}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ import {
hasRemotePeerWorkspaces,
hasRemoteWorkspaces,
isHostScopeFiltered,
isRemoteFallbackWorkspace,
loadHostScopeFilter,
pruneUnavailableHostScopeFilter,
reconcileHostScopeFilter,
Expand Down Expand Up @@ -1764,16 +1765,19 @@ function WorkspaceBrowserContent({
const list = useSessions((state) => 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<WorkspaceView> & { workspaceId: string }): WorkspaceView {
return {
Expand Down Expand Up @@ -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);
Expand Down
Loading