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
12 changes: 9 additions & 3 deletions docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,12 @@ codex exec resume <세션 id> "이어서 문서도" # codex 도 같
- 다른 터미널의 세션은 `--tab`(다른 워크스페이스면 `--workspace` 도)으로 고릅니다.
- 앱을 업데이트하기 전부터 돌던 Claude · Codex 탭의 프로그램은 예전 환경 그대로라, 그 탭이 띄운 실행은 탭의 프로그램이 다시 시작된 뒤부터 보입니다.

## 워크스페이스 추가 · 제거 · 정리
## 워크스페이스 추가 · 제거 · 이름 · 색 · 정리

```bash
nexus workspace add ../lib --name 라이브러리 --show # 이 터미널 위치 기준 폴더를 사이드바 끝에 추가
nexus workspace remove 라이브러리 # 앱 목록에서 제거(폴더는 그대로)
nexus workspace edit lib --name 라이브러리 --color blue # 이름 바꾸기 · 색 지정 (--color auto 는 앱이 고름)
nexus workspace pin lib # 사이드바 위쪽에 고정 (workspace unpin 으로 해제)
nexus workspace move lib --before api # api 바로 위로 (--after · --top · --bottom)
```
Expand All @@ -251,17 +252,22 @@ nexus workspace move lib --before api # api 바로 위로 (--after
- 폴더 이름이 사이드바 이름이 됩니다. `--name` 으로 바꿀 수 있습니다.
- SSH · WSL 터미널에서 실행하면 그 터미널과 같은 호스트(같은 접속 방법)의 폴더를 추가합니다.
- 처음 보여줄 때 연결합니다. `--show` 면 바로 그 워크스페이스로 전환합니다.
- `--color` 로 색을 정해 추가할 수 있습니다.
- 이미 목록에 있는 폴더면 새로 만들지 않고 그 워크스페이스를 알려줍니다. 묻지 않습니다.
- `workspace remove` 는 사이드바 메뉴의 **목록에서 제거** 와 같습니다.
- 그 워크스페이스와 작업들의 터미널을 닫고(실행 중인 프로그램 포함) 사이드바에서 뺍니다. 폴더는 지우지 않습니다. 작업의 워크트리 폴더와 브랜치도 디스크에 남습니다.
- 저장하지 않은 파일이 있거나, 명령을 실행한 터미널이 그 워크스페이스(또는 그 작업) 안에 있으면 거절합니다.
- 작업 하나만 지우려면 `worktree remove` 를 씁니다.
- 항상 다른 워크스페이스라서 아래 "다른 워크스페이스 바꾸기" 설정을 따릅니다.
- `workspace edit` 는 사이드바 메뉴의 **이름 바꾸기** · **색** 과 같습니다. `--name` · `--color` 중 하나 이상을 줍니다.
- 색은 `red` · `amber` · `lime` · `green` · `cyan` · `blue` · `violet` · `pink` 이거나 `auto` 입니다. 사이드바 행의 폴더 아이콘과 에이전트 뷰에서 그 워크스페이스를 가르는 색이 되고, `auto` 는 앱이 워크스페이스마다 골라 줍니다. 새로 추가한 워크스페이스는 `auto` 입니다.
- 워크스페이스의 작업(워크트리)은 그 워크스페이스의 색을 따르므로 따로 바꾸지 않습니다.
- 지금 값과 같으면 아무것도 바꾸지 않고 묻지도 않습니다. `workspace list --json` 에 `color` 가 나옵니다.
- `workspace pin` 은 사이드바의 고정 버튼과 같습니다. 고정한 것들의 맨 아래로 갑니다.
- `workspace move` 는 사이드바에서 끌어 옮기는 것과 같습니다. `--before` · `--after` 로 다른 묶음(고정 · 고정 안 함)의 워크스페이스 옆에 두면 그 묶음으로 고정되거나 풀립니다. `--top` · `--bottom` 은 지금 묶음 안에서 맨 위 · 맨 아래로 옮깁니다.
- 작업(워크트리)은 사이드바에서 워크스페이스 아래에 보여서 이름 · 고정 · 순서를 바꾸지 않습니다.
- 작업(워크트리)은 사이드바에서 워크스페이스 아래에 보여서 이름 · 색 · 고정 · 순서를 바꾸지 않습니다.
- `workspace list` 는 사이드바 순서(고정한 것 먼저)이고, 고정한 것에 `pinned` 가 붙습니다.
- 다른 워크스페이스의 이름 · 고정 · 순서 바꾸기는 "다른 워크스페이스 바꾸기" 설정을 따릅니다.
- 다른 워크스페이스의 이름 · 색 · 고정 · 순서 바꾸기는 "다른 워크스페이스 바꾸기" 설정을 따릅니다.

## 작업(워크트리) 만들기 · 지우기

Expand Down
2 changes: 1 addition & 1 deletion src/main/features/cli/commands/agent-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function agentContextNote(heading: string, inRoom: boolean): string {
"listens on, as nexus port list shows), then snapshot (the page with element refs), click e12,",
"fill e3 TEXT, press Enter, screenshot, console and eval. The workbench can be arranged",
"too: nexus layout show/split/resize, tab move/rename/pin, panel show/hide, reveal,",
"workspace move/pin (the sidebar's rows),",
"workspace move/pin/edit (the sidebar's rows: order, pin, name and color),",
"and nexus view agents|workspaces, view layout/open/split for the agent view's panels;",
"nexus problems lists the language servers' errors in open files.",
"The user's notes are the app's (its Notes panel): a note they speak of is one of these,",
Expand Down
74 changes: 72 additions & 2 deletions src/main/features/cli/commands/workspace.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
/** nexus status, nexus workspace ... and nexus worktree ... (the app's tasks). */
import type { CliTaskStart, CliView } from "../../../../shared/cli/ui";
import type { WorkspaceLocation, WorkspaceMeta } from "../../../../shared/types/workspace";
import {
WORKSPACE_COLOR_AUTO,
WORKSPACE_COLORS,
type WorkspaceColor,
WorkspaceColorSchema,
} from "../../../../shared/types/workspace-color";
import { compareWorkspaceOrder } from "../../../../shared/workspace-order";
import { CliUsageError, exactArgs } from "../args";
import {
Expand Down Expand Up @@ -31,6 +37,7 @@ export function workspaceJson(ctx: CliContext, workspace: WorkspaceMeta) {
name: workspace.name,
location: workspace.location,
pinned: workspace.pinned,
color: workspace.color,
current: workspace.id === ctx.caller.workspaceId,
shown: shown?.workspaceId === workspace.id,
...(workspace.task
Expand Down Expand Up @@ -526,6 +533,24 @@ function locationBeside(beside: WorkspaceLocation, folder: string): WorkspaceLoc
: { ...beside, remotePath: folder };
}

const COLOR_FLAG = {
type: "string",
value: "COLOR",
description: `One of ${WORKSPACE_COLORS.join(", ")}, or ${WORKSPACE_COLOR_AUTO} for the app's own pick`,
} as const;

/** The color a --color flag names; undefined when it is not given. */
export function colorFlag(value: unknown): WorkspaceColor | undefined {
if (value === undefined) return undefined;
const parsed = WorkspaceColorSchema.safeParse(String(value).trim().toLowerCase());
if (!parsed.success) {
throw new CliUsageError(
`--color is one of ${WORKSPACE_COLORS.join(", ")}, or ${WORKSPACE_COLOR_AUTO}`,
);
}
return parsed.data;
}

const workspaceAdd: CliCommand = {
path: ["workspace", "add"],
summary: "Add a folder to the app as a workspace, on this terminal's host",
Expand All @@ -534,17 +559,20 @@ const workspaceAdd: CliCommand = {
"As Add Workspace in the app: the folder, from this terminal's directory, goes at the end\n" +
"of the sidebar, named after it unless --name. An SSH or WSL terminal adds a folder on its\n" +
"own host, reached as its workspace is. It connects once it is first shown, so --show it\n" +
"or click it. A folder already in the list gives that workspace.",
"or click it. --color gives it a color, as the sidebar's menu does. A folder already in\n" +
"the list gives that workspace as it is.",
flags: {
name: { type: "string", value: "NAME", description: "The name the sidebar shows" },
color: COLOR_FLAG,
show: { type: "boolean", description: "Show it to the user" },
},
async run(ctx, { positionals, flags }) {
const [input] = exactArgs(positionals, "folder") as [string];
const caller = resolveWorkspace(ctx, undefined);
const location = locationBeside(caller.location, absolutePath(ctx, caller, input));
const name = (flags.name as string | undefined)?.trim() || undefined;
const { workspace, added } = await ctx.services.addWorkspace(location, name);
const color = colorFlag(flags.color);
const { workspace, added } = await ctx.services.addWorkspace(location, name, color);
if (flags.show === true) await ctx.services.ui("workspace.show", { workspaceId: workspace.id });
const what = added ? "Added" : "Already listed";
return output(
Expand Down Expand Up @@ -632,6 +660,47 @@ function workspacePinCommand(pinned: boolean): CliCommand {
};
}

const workspaceEdit: CliCommand = {
path: ["workspace", "edit"],
summary: "Rename a workspace or change its color, as the sidebar's menu does",
args: "<workspace>",
details:
"Give --name, --color or both. The color marks the workspace in the sidebar and the agent\n" +
`view; ${WORKSPACE_COLOR_AUTO} leaves it to the app. A worktree is shown under its workspace and\n` +
"takes its color, so it is not edited here. Another workspace's is changed with the user's leave.",
flags: {
name: { type: "string", value: "NAME", description: "The name the sidebar shows" },
color: COLOR_FLAG,
},
async run(ctx, { positionals, flags }) {
const [selector] = exactArgs(positionals, "workspace") as [string];
const name = (flags.name as string | undefined)?.trim();
const color = colorFlag(flags.color);
if (flags.name !== undefined && !name) throw new CliUsageError("--name is empty");
if (name === undefined && color === undefined) {
throw new CliUsageError("give --name, --color or both");
}
const target = sidebarWorkspace(ctx, selector);
const edit = {
...(name !== undefined && name !== target.name ? { name } : {}),
...(color !== undefined && color !== target.color ? { color } : {}),
};
if (Object.keys(edit).length === 0) {
return output(`${target.name} is as asked.`, workspaceJson(ctx, target));
}
await mayChange(ctx, target, { kind: "workspaceEdit" });
const changed = ctx.services.editWorkspace(target.id, edit);
const parts = [
...(edit.name !== undefined ? [`renamed from ${target.name}`] : []),
...(edit.color !== undefined ? [`color ${changed.color}`] : []),
];
return output(
`${changed.name} (${shortId(changed.id)}): ${parts.join(", ")}.`,
workspaceJson(ctx, changed),
);
},
};

/** What a group of the sidebar is called. */
const GROUP_NAMES = { pinned: "pinned workspaces", unpinned: "workspaces not pinned" } as const;

Expand Down Expand Up @@ -696,6 +765,7 @@ export const workspaceCommands: CliCommand[] = [
workspaceSwitch,
workspaceAdd,
workspaceRemove,
workspaceEdit,
workspacePinCommand(true),
workspacePinCommand(false),
workspaceMove,
Expand Down
4 changes: 4 additions & 0 deletions src/main/features/cli/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import type { TranscriptFile } from "../../../shared/notes/transcript";
import type { NoteAsset, NoteContent, NoteSummary } from "../../../shared/notes/types";
import type { ListeningPort, PortForward } from "../../../shared/pty/ports";
import type { WorkspaceLocation, WorkspaceMeta } from "../../../shared/types/workspace";
import type { WorkspaceColor } from "../../../shared/types/workspace-color";
import type { TabActivity } from "./activity";
import type { BrowserDriver } from "./browser/driver";
import type { ChangeRequest } from "./consent";
Expand Down Expand Up @@ -115,7 +116,10 @@ export interface CliServices {
addWorkspace(
location: WorkspaceLocation,
name: string | undefined,
color?: WorkspaceColor,
): Promise<{ workspace: WorkspaceMeta; added: boolean }>;
/** Renames a workspace and sets its color, as the sidebar's menu does; the workspace as it is now. */
editWorkspace(id: string, edit: { name?: string; color?: WorkspaceColor }): WorkspaceMeta;
/**
* Pins or unpins a workspace as the sidebar's pin does (to the end of its
* new group); the workspace as it is now.
Expand Down
21 changes: 17 additions & 4 deletions src/main/features/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { createLogger } from "../../../shared/log/main";
import { redactLogSecrets } from "../../../shared/log/redact-secrets";
import type { ListeningPort } from "../../../shared/pty/ports";
import type { WorkspaceLocation, WorkspaceMeta } from "../../../shared/types/workspace";
import type { WorkspaceColor } from "../../../shared/types/workspace-color";
import type { AgentChannel } from "../../infra/agent/channel";
import { register, validateArgs } from "../../infra/ipc-router";
import { getBrowserRegistry, onBrowserTabCreated } from "../browser";
Expand Down Expand Up @@ -71,8 +72,15 @@ export interface SetupCliFeatureOptions {
agentHost: ActivitySource & { call(method: string, args: unknown): Promise<unknown> };
workspaceManager: {
list(): WorkspaceMeta[];
create(opts: { location: WorkspaceLocation; name?: string }): WorkspaceMeta;
update(id: string, partial: { pinned?: boolean }): WorkspaceMeta;
create(opts: {
location: WorkspaceLocation;
name?: string;
color?: WorkspaceColor;
}): WorkspaceMeta;
update(
id: string,
partial: { pinned?: boolean; name?: string; color?: WorkspaceColor },
): WorkspaceMeta;
reorder(
id: string,
opts: { beforeId?: string; afterId?: string; targetGroup: "pinned" | "unpinned" },
Expand Down Expand Up @@ -244,18 +252,23 @@ export function setupCliFeature(options: SetupCliFeatureOptions): CliFeature {
const services: CliServices = {
appVersion: options.appVersion,
listWorkspaces: () => workspaceManager.list(),
addWorkspace: async (location, name) => {
addWorkspace: async (location, name, color) => {
const listed = await listedAt(workspaceManager.list(), location);
if (listed) return { workspace: listed, added: false };
if (location.kind === "local") {
const found = await stat(location.rootPath).catch(() => null);
if (!found?.isDirectory()) throw new CliError(`no folder at ${location.rootPath}`);
}
return {
workspace: workspaceManager.create({ location, ...(name ? { name } : {}) }),
workspace: workspaceManager.create({
location,
...(name ? { name } : {}),
...(color ? { color } : {}),
}),
added: true,
};
},
editWorkspace: (id, edit) => workspaceManager.update(id, edit),
pinWorkspace: (id, pinned) => workspaceManager.update(id, { pinned }),
moveWorkspace: (id, { group, ...anchor }) =>
workspaceManager.reorder(id, { ...anchor, targetGroup: group }),
Expand Down
7 changes: 4 additions & 3 deletions src/main/features/workspace/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
type WorkspaceTask,
workspaceLocationKey,
} from "../../../shared/types/workspace";
import type { WorkspaceColor } from "../../../shared/types/workspace-color";
import type { AgentChannel } from "../../infra/agent/channel";
import {
type CreateLocalChannelOptions,
Expand Down Expand Up @@ -82,8 +83,8 @@ const log = createLogger("workspace");

export type BroadcastFn = (channelName: string, event: string, args: unknown) => void;
export type WorkspaceCreateOptions =
| { location: WorkspaceLocation; name?: string; task?: WorkspaceTask }
| { rootPath: string; name?: string; task?: WorkspaceTask };
| { location: WorkspaceLocation; name?: string; color?: WorkspaceColor; task?: WorkspaceTask }
| { rootPath: string; name?: string; color?: WorkspaceColor; task?: WorkspaceTask };
export type WorkspaceSshChannelFactory = (options: CreateSshChannelOptions) => SshChannel;
export type WorkspaceSshBootstrap = (
options: EnsureRemoteAgentOptions,
Expand Down Expand Up @@ -729,7 +730,7 @@ export class WorkspaceManager {
name,
location,
rootPath,
colorTone: "default",
color: opts.color ?? "auto",
pinned: false,
lastOpenedAt: new Date().toISOString(),
tabs: [],
Expand Down
13 changes: 7 additions & 6 deletions src/main/infra/storage/global-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
type WorkspaceTask,
WorkspaceTaskSchema,
} from "../../../shared/types/workspace";
import { toWorkspaceColor } from "../../../shared/types/workspace-color";
import { applyMigrations, type SqliteDb } from "./migrations";

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -132,7 +133,7 @@ interface WorkspaceRow {
name: string;
root_path: string;
location: string | null;
color_tone: string;
color: string;
pinned: number;
last_opened_at: number;
sort_order: number;
Expand Down Expand Up @@ -231,7 +232,7 @@ function rowToMeta(row: WorkspaceRow): WorkspaceMeta {
name: row.name,
location,
rootPath: rootPathFromLocation(location),
colorTone: row.color_tone as WorkspaceMeta["colorTone"],
color: toWorkspaceColor(row.color),
pinned: row.pinned === 1,
lastOpenedAt: new Date(row.last_opened_at).toISOString(),
tabs: [],
Expand Down Expand Up @@ -293,7 +294,7 @@ export class GlobalStorage {
this.db
.prepare(
`INSERT INTO workspaces
(id, name, root_path, location, color_tone, pinned, last_opened_at,
(id, name, root_path, location, color, pinned, last_opened_at,
sort_order, pinned_sort_order, task)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
)
Expand All @@ -302,7 +303,7 @@ export class GlobalStorage {
normalized.name,
rootPath,
JSON.stringify(location),
normalized.colorTone ?? "default",
normalized.color,
normalized.pinned ? 1 : 0,
normalized.lastOpenedAt ? new Date(normalized.lastOpenedAt).getTime() : Date.now(),
normalized.sortOrder,
Expand Down Expand Up @@ -334,14 +335,14 @@ export class GlobalStorage {
this.db
.prepare(
`UPDATE workspaces
SET name = ?, root_path = ?, location = ?, color_tone = ?, pinned = ?, last_opened_at = ?
SET name = ?, root_path = ?, location = ?, color = ?, pinned = ?, last_opened_at = ?
WHERE id = ?`,
)
.run(
partial.name ?? row.name,
rootPath,
locationJson,
(partial.colorTone ?? row.color_tone) as string,
partial.color ?? toWorkspaceColor(row.color),
partial.pinned !== undefined ? (partial.pinned ? 1 : 0) : row.pinned,
partial.lastOpenedAt ? new Date(partial.lastOpenedAt).getTime() : row.last_opened_at,
id,
Expand Down
13 changes: 13 additions & 0 deletions src/main/infra/storage/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,19 @@ export const MIGRATIONS: Migration[] = [
db.exec(`ALTER TABLE session_spans ADD COLUMN agent TEXT`);
},
},
// A workspace's color replaces its tone (subdued, default, prominent, pinned),
// which no screen used: every workspace starts as "auto", whatever its tone
// was. The `color_tone` column stays, unused, so an older build opening the
// same database still inserts into it (it has a DEFAULT) and a downgrade is
// safe; nothing reads or writes it now. Idempotent.
{
version: 10,
up: (db) => {
if (!hasColumn(db, "workspaces", "color")) {
db.exec("ALTER TABLE workspaces ADD COLUMN color TEXT NOT NULL DEFAULT 'auto';");
}
},
},
];

export function applyMigrations(db: SqliteDb): void {
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/components/agent-view/agent-pane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ export const AgentPane = memo(function AgentPane({
function WorkspaceChip({ workspaceId, className }: { workspaceId: string; className?: string }) {
const name = useWorkspacesStore((s) => s.workspaces.find((w) => w.id === workspaceId)?.name);
const rootId = useWorkspacesStore((s) => rootWorkspaceId(s.workspaces, workspaceId));
const color = useWorkspacesStore((s) => s.workspaces.find((w) => w.id === rootId)?.color);
return (
<span
className={cn(
Expand All @@ -386,7 +387,7 @@ function WorkspaceChip({ workspaceId, className }: { workspaceId: string; classN
<span
aria-hidden
className="size-1.5 shrink-0 rounded-full"
style={{ background: workspaceColor(rootId) }}
style={{ background: workspaceColor(rootId, color) }}
/>
<span className="truncate">{name}</span>
</span>
Expand Down
Loading