Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(views): stop telling worktree-mode users their folder is edited in place (MUL-5707) (#6911)
Bohan Jiangea1ace776fa1
diff --git a/packages/views/locales/en/projects.json b/packages/views/locales/en/projects.jsonindex 715c34348f..423a3a9eca 100644--- a/packages/views/locales/en/projects.json+++ b/packages/views/locales/en/projects.json@@ -105,6 +105,8 @@"local_no_daemon_tooltip": "Local daemon isn't reporting an ID yet — the agent can't open this directory.","local_other_machine_tooltip": "Only available on the machine that registered this directory.","chat_hint_prefix": "Agent will work in-place at",+ "chat_hint_worktree_prefix": "Agent will work in an isolated worktree of",+ "chat_hint_worktree_note": "Your working copy stays untouched — each task hands its work back as an agent/… branch.","toast_local_attached": "Local directory attached","toast_local_renamed": "Renamed","toast_local_rename_failed": "Failed to rename",diff --git a/packages/views/locales/ja/projects.json b/packages/views/locales/ja/projects.jsonindex 2f7a8323ee..a5ea91570c 100644--- a/packages/views/locales/ja/projects.json+++ b/packages/views/locales/ja/projects.json@@ -104,6 +104,8 @@"local_no_daemon_tooltip": "ローカルデーモンがまだ ID を報告していないため、エージェントはこのディレクトリを開けません。","local_other_machine_tooltip": "このディレクトリを登録したマシンでのみ利用できます。","chat_hint_prefix": "エージェントは次の場所で直接作業します:",+ "chat_hint_worktree_prefix": "エージェントは次のリポジトリの独立した worktree で作業します:",+ "chat_hint_worktree_note": "作業コピーは変更されません。各タスクの成果は agent/… ブランチとして返されます。","toast_local_attached": "ローカルディレクトリを添付しました","toast_local_renamed": "名前を変更しました","toast_local_rename_failed": "名前を変更できませんでした",diff --git a/packages/views/locales/ko/projects.json b/packages/views/locales/ko/projects.jsonindex fa2153f26c..bfd3dc6831 100644--- a/packages/views/locales/ko/projects.json+++ b/packages/views/locales/ko/projects.json@@ -104,6 +104,8 @@"local_no_daemon_tooltip": "로컬 데몬이 아직 ID를 보고하지 않아 에이전트가 이 디렉터리를 열 수 없습니다.","local_other_machine_tooltip": "이 디렉터리를 등록한 기기에서만 사용할 수 있습니다.","chat_hint_prefix": "에이전트가 다음 위치에서 직접 작업합니다:",+ "chat_hint_worktree_prefix": "에이전트가 다음 저장소의 격리된 worktree에서 작업합니다:",+ "chat_hint_worktree_note": "작업 중인 파일은 그대로 유지되며, 각 작업 결과는 agent/… 브랜치로 전달됩니다.","toast_local_attached": "로컬 디렉터리를 연결했습니다","toast_local_renamed": "이름을 변경했습니다","toast_local_rename_failed": "이름을 변경하지 못했습니다",diff --git a/packages/views/locales/zh-Hans/projects.json b/packages/views/locales/zh-Hans/projects.jsonindex 607ffcfac7..5caced7194 100644--- a/packages/views/locales/zh-Hans/projects.json+++ b/packages/views/locales/zh-Hans/projects.json@@ -103,7 +103,9 @@"local_rename_label": "本地目录显示名","local_no_daemon_tooltip": "尚未识别到本机 daemon,agent 暂时无法打开此目录。","local_other_machine_tooltip": "此目录仅在最初注册它的电脑上可用。",- "chat_hint_prefix": "Agent 将在",+ "chat_hint_prefix": "智能体将直接在以下目录中工作:",+ "chat_hint_worktree_prefix": "智能体将在以下仓库的独立 worktree 中工作:",+ "chat_hint_worktree_note": "不会改动你的工作副本,每条任务的结果以 agent/… 分支交回。","toast_local_attached": "已添加本地目录","toast_local_renamed": "已重命名","toast_local_rename_failed": "重命名失败",diff --git a/packages/views/projects/components/local-directory-hint.test.tsx b/packages/views/projects/components/local-directory-hint.test.tsxindex 679fecb907..4323e89f3e 100644--- a/packages/views/projects/components/local-directory-hint.test.tsx+++ b/packages/views/projects/components/local-directory-hint.test.tsx@@ -49,6 +49,7 @@ function makeLocalDirectoryResource(overrides: {daemon_id: string;local_path: string;label?: string;+ execution_mode?: string;}): ProjectResource {return {id: `res-${overrides.local_path}`,@@ -59,6 +60,9 @@ function makeLocalDirectoryResource(overrides: {daemon_id: overrides.daemon_id,local_path: overrides.local_path,...(overrides.label ? { label: overrides.label } : {}),+ ...(overrides.execution_mode+ ? { execution_mode: overrides.execution_mode }+ : {}),},label: null,position: 0,@@ -115,6 +119,86 @@ describe("LocalDirectoryHint", () => {expect(screen.getByText(/Users\/foo\/work/)).toBeInTheDocument();});+ // The banner used to say "in-place" for every local_directory resource.+ // Under worktree mode that is simply false — the agent runs in an isolated+ // worktree and the named directory does not change — and it points the user+ // at the wrong place to look for the work.+ it("describes worktree mode as isolated, never in-place", async () => {+ mockDaemonStatus.daemonId = "daemon-A";+ mockDaemonStatus.running = true;+ mockListResources.mockResolvedValue({+ resources: [+ makeLocalDirectoryResource({+ daemon_id: "daemon-A",+ local_path: "/Users/foo/work",+ label: "work",+ execution_mode: "worktree",+ }),+ ],+ total: 1,+ });+ renderHint("proj-1");+ await waitFor(() => {+ expect(screen.getByText(/isolated worktree of/i)).toBeInTheDocument();+ });+ expect(screen.queryByText(/in-place/i)).not.toBeInTheDocument();+ // The mode's whole point is that results arrive as a branch; a user who+ // only reads this banner still has to know where to find them.+ expect(screen.getByText(/agent\/….*branch/i)).toBeInTheDocument();+ // The path stays: it identifies the repository the branch lands in.+ expect(screen.getByText(/Users\/foo\/work/)).toBeInTheDocument();+ });++ it("describes an explicit in_place resource as in-place", async () => {+ mockDaemonStatus.daemonId = "daemon-A";+ mockDaemonStatus.running = true;+ mockListResources.mockResolvedValue({+ resources: [+ makeLocalDirectoryResource({+ daemon_id: "daemon-A",+ local_path: "/Users/foo/work",+ label: "work",+ execution_mode: "in_place",+ }),+ ],+ total: 1,+ });+ renderHint("proj-1");+ await waitFor(() => {+ expect(screen.getByText(/in-place/i)).toBeInTheDocument();+ });+ expect(screen.queryByText(/isolated worktree/i)).not.toBeInTheDocument();+ });++ // Absent (pre-mode resources) and anything a newer server might send both+ // mean "assume the working copy is at stake" — claiming isolation we cannot+ // verify is the one wrong answer here.+ it("treats an absent or unknown mode as in-place", async () => {+ mockDaemonStatus.daemonId = "daemon-A";+ mockDaemonStatus.running = true;+ mockListResources.mockResolvedValue({+ resources: [+ makeLocalDirectoryResource({+ daemon_id: "daemon-A",+ local_path: "/Users/foo/legacy",+ label: "legacy",+ }),+ makeLocalDirectoryResource({+ daemon_id: "daemon-A",+ local_path: "/Users/foo/future",+ label: "future",+ execution_mode: "snapshot",+ }),+ ],+ total: 2,+ });+ renderHint("proj-1");+ await waitFor(() => {+ expect(screen.getAllByText(/in-place/i)).toHaveLength(2);+ });+ expect(screen.queryByText(/isolated worktree/i)).not.toBeInTheDocument();+ });+it("ignores resources pinned to a different daemon", async () => {mockDaemonStatus.daemonId = "daemon-A";mockDaemonStatus.running = true;diff --git a/packages/views/projects/components/local-directory-hint.tsx b/packages/views/projects/components/local-directory-hint.tsxindex b582da355b..85c5503706 100644--- a/packages/views/projects/components/local-directory-hint.tsx+++ b/packages/views/projects/components/local-directory-hint.tsx@@ -1,7 +1,7 @@"use client";import { useQuery } from "@tanstack/react-query";-import { FolderOpen } from "lucide-react";+import { FolderOpen, GitBranch } from "lucide-react";import { projectResourcesOptions } from "@multica/core/projects";import type { LocalDirectoryResourceRef, ProjectResource } from "@multica/core/types";import { useWorkspaceId } from "@multica/core/hooks";@@ -11,8 +11,15 @@ import { useT } from "../../i18n";/*** Banner shown at the top of the issue's Activity section when the* project is pinned to a `local_directory` resource on **this** daemon.- * Tells the user "starting an agent here will use {label} ({path}) in-- * place" so they notice they are not getting an isolated git worktree.+ * Tells the user what starting an agent here will actually do to that+ * directory, which differs by the resource's execution mode:+ *+ * - `in_place`: the agent edits {label} ({path}) itself, so the user should+ * expect their working copy to change under them.+ * - `worktree`: the agent never touches that working copy — it runs in an+ * isolated worktree of the repo and hands back a branch. Saying "in-place"+ * here would be a plain factual error, and it would send the user looking+ * for results in a directory that will not have changed (MUL-5707).** Rendered only on desktop: web has no daemon to compare against, so the* "this machine" check would always fail. Web users will see local_directory@@ -53,17 +60,33 @@ export function LocalDirectoryHint({const ref = resource.resource_ref;const label = (ref.label || resource.label || ref.local_path).trim() ||ref.local_path;+ // Anything other than an explicit "worktree" is in_place: the mode is+ // absent on resources created before it existed, and an unknown value+ // from a newer server must not claim isolation we cannot verify.+ const isWorktree = ref.execution_mode === "worktree";return (- <div- key={resource.id}- className="flex items-center gap-2"- >- <FolderOpen className="size-3 shrink-0" />- <span className="truncate">- {t(($) => $.resources.chat_hint_prefix)}- <span className="font-medium text-foreground"> {label} </span>- <span className="font-mono opacity-70">({ref.local_path})</span>- </span>+ <div key={resource.id} className="space-y-0.5">+ <div className="flex items-center gap-2">+ {isWorktree ? (+ <GitBranch className="size-3 shrink-0" />+ ) : (+ <FolderOpen className="size-3 shrink-0" />+ )}+ <span className="truncate">+ {isWorktree+ ? t(($) => $.resources.chat_hint_worktree_prefix)+ : t(($) => $.resources.chat_hint_prefix)}+ <span className="font-medium text-foreground"> {label} </span>+ <span className="font-mono opacity-70">({ref.local_path})</span>+ </span>+ </div>+ {/* Where the work ends up. Only worktree mode needs saying: in+ place, the answer is the directory already named above. */}+ {isWorktree && (+ <div className="pl-5 opacity-80">+ {t(($) => $.resources.chat_hint_worktree_note)}+ </div>+ )}</div>);})}diff --git a/server/internal/service/builtin_skills/multica-projects-and-resources/SKILL.md b/server/internal/service/builtin_skills/multica-projects-and-resources/SKILL.mdindex 80811069eb..61caba0e93 100644--- a/server/internal/service/builtin_skills/multica-projects-and-resources/SKILL.md+++ b/server/internal/service/builtin_skills/multica-projects-and-resources/SKILL.md@@ -58,10 +58,12 @@ multica project resource remove <project-id> <resource-id> --output jsondirectory, one task at a time; a second task waits in `waiting_local_directory`. `worktree` gives each task its owngit worktree of that repo, so tasks run concurrently and each delivers its work as an `agent/<agent>/<task>` branchin the user's repo instead of editing the working copy. `worktree` requires the path to be a git repository with at-least one commit; tasks fail with an explicit error otherwise. The daemon version is gated twice — at save time and again-against the daemon that claims each task — so a downgraded machine gets its tasks cancelled rather than run in place. Saving `worktree` is also refused (HTTP 422, code-`daemon_version_unsupported`) while the daemon on that machine is older than the release that ships the mode — the-fix is upgrading that daemon, then retrying. Pass an empty value to clear it back to the default.+least one commit; tasks fail with an explicit error otherwise. The gate is the `local-worktree-v1` capability the+daemon advertises — not its version string — and it is checked twice: at save time, and again against the daemon that+claims each task, so a machine whose runtime cannot do worktrees gets its tasks cancelled rather than run in place.+Saving `worktree` is also refused (HTTP 422, code `daemon_version_unsupported`) while the daemon on that machine does+not advertise the capability — the fix is updating the Multica app there, then retrying. Pass an empty value to clear+it back to the default.For `github_repo`, non-JSON `--ref` sets `resource_ref.ref`, the default checkout branch/tag/SHA for future tasks in that project. JSON `--ref '<json>'` remains the escape hatch for full payloads or resource types not covered by shortcuts.