Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(issues): resolve local directory hint from assigned agent daemon (#8948)

Zn8aead14ab841
diff --git a/packages/views/issues/components/issue-detail.test.tsx b/packages/views/issues/components/issue-detail.test.tsx
index 14414e6393..3bc662f9b5 100644
--- a/packages/views/issues/components/issue-detail.test.tsx
+++ b/packages/views/issues/components/issue-detail.test.tsx
@@ -20,6 +20,13 @@ import enIssues from "../../locales/en/issues.json";
const TEST_RESOURCES = { en: { agents: enAgents, common: enCommon, issues: enIssues } };
const mockViewport = vi.hoisted(() => ({ isMobile: false }));
+const mockLocalDirectoryHint = vi.hoisted(() => vi.fn());
+vi.mock("../../projects/components/local-directory-hint", () => ({
+ LocalDirectoryHint: (props: unknown) => {
+ mockLocalDirectoryHint(props);
+ return null;
+ },
+}));
// Counts MockContentEditor mounts. This pins the description to exactly one
// eager editor per issue and catches stale editor reuse across issue switches.
@@ -86,7 +93,7 @@ vi.mock("@multica/core/workspace/queries", () => ({
}),
agentListOptions: () => ({
queryKey: ["workspaces", "ws-1", "agents"],
- queryFn: () => Promise.resolve([]),
+ queryFn: () => mockApiObj.listAgents(),
}),
squadListOptions: () => ({
queryKey: ["workspaces", "ws-1", "squads"],
@@ -742,6 +749,25 @@ describe("IssueDetail (shared)", () => {
mockApiObj.getProject.mockReset();
});
+ it("passes the issue's agent assignment to the local-directory hint", async () => {
+ const agent = { id: "agent-vue", name: "Vue developer", runtime_id: "runtime-vue" };
+ mockApiObj.getIssue.mockResolvedValue({
+ ...mockIssue,
+ project_id: "proj-1",
+ assignee_type: "agent",
+ assignee_id: agent.id,
+ });
+ mockApiObj.getProject.mockResolvedValue({ id: "proj-1", name: "Demo" });
+ mockApiObj.listAgents.mockResolvedValue([agent]);
+
+ renderIssueDetail();
+
+ await waitFor(() => expect(mockLocalDirectoryHint).toHaveBeenCalledWith({
+ projectId: "proj-1",
+ assignedAgent: agent,
+ }));
+ });
+
it("counts comment files as deliverables, a re-upload once as v2, never the description's (MUL-7649)", async () => {
const file = (id: string, over: Partial<Attachment>): Attachment => ({
id,
diff --git a/packages/views/issues/components/issue-detail.tsx b/packages/views/issues/components/issue-detail.tsx
index c0348f46ac..82925bbc19 100644
--- a/packages/views/issues/components/issue-detail.tsx
+++ b/packages/views/issues/components/issue-detail.tsx
@@ -3843,7 +3843,12 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr
</div>
</div>
- <LocalDirectoryHint projectId={issue?.project_id} />
+ <LocalDirectoryHint
+ projectId={issue.project_id}
+ assignedAgent={issue.assignee_type === "agent"
+ ? agents.find((agent) => agent.id === issue.assignee_id) ?? null
+ : undefined}
+ />
{/* The "agent is working" live signal now lives in the header
(IssueAgentHeaderChip) so it stays in one fixed place and
diff --git a/packages/views/projects/components/local-directory-hint.test.tsx b/packages/views/projects/components/local-directory-hint.test.tsx
index 4323e89f3e..e73fdb6710 100644
--- a/packages/views/projects/components/local-directory-hint.test.tsx
+++ b/packages/views/projects/components/local-directory-hint.test.tsx
@@ -2,7 +2,7 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
import { render, screen, waitFor } from "@testing-library/react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { I18nProvider } from "@multica/core/i18n/react";
-import type { ProjectResource } from "@multica/core/types";
+import type { Agent, ProjectResource } from "@multica/core/types";
import enCommon from "../../locales/en/common.json";
import enProjects from "../../locales/en/projects.json";
@@ -23,26 +23,32 @@ vi.mock("@multica/core/hooks", () => ({
}));
const mockListResources = vi.hoisted(() => vi.fn());
+const mockListRuntimes = vi.hoisted(() => vi.fn());
vi.mock("@multica/core/api", () => ({
api: {
listProjectResources: (...args: unknown[]) => mockListResources(...args),
+ listRuntimes: (...args: unknown[]) => mockListRuntimes(...args),
},
}));
import { LocalDirectoryHint } from "./local-directory-hint";
-function renderHint(projectId: string | null | undefined) {
+function renderHint(
+ projectId: string | null | undefined,
+ assignedAgent?: Pick<Agent, "runtime_id" | "runtime_bound"> | null,
+) {
const qc = new QueryClient({
defaultOptions: { queries: { retry: false } },
});
- return render(
+ const result = render(
<QueryClientProvider client={qc}>
<I18nProvider locale="en" resources={TEST_RESOURCES}>
- <LocalDirectoryHint projectId={projectId} />
+ <LocalDirectoryHint projectId={projectId} assignedAgent={assignedAgent} />
</I18nProvider>
</QueryClientProvider>,
);
+ return { ...result, queryClient: qc };
}
function makeLocalDirectoryResource(overrides: {
@@ -77,6 +83,41 @@ describe("LocalDirectoryHint", () => {
mockDaemonStatus.deviceName = null;
mockDaemonStatus.running = false;
mockListResources.mockReset();
+ mockListRuntimes.mockReset().mockResolvedValue([]);
+ });
+
+ it("shows the assigned agent's directory instead of the viewer's directory (#8861)", async () => {
+ mockDaemonStatus.daemonId = "daemon-A";
+ mockListRuntimes.mockResolvedValue([{ id: "runtime-vue", daemon_id: "daemon-B" }]);
+ mockListResources.mockResolvedValue({
+ resources: [
+ makeLocalDirectoryResource({ daemon_id: "daemon-A", local_path: "/repos/laravel", label: "Laravel" }),
+ makeLocalDirectoryResource({ daemon_id: "daemon-B", local_path: "/repos/vue", label: "VueJS", execution_mode: "worktree" }),
+ ],
+ total: 2,
+ });
+
+ renderHint("proj-1", { runtime_id: "runtime-vue" });
+
+ expect(await screen.findByText("VueJS")).toBeInTheDocument();
+ expect(screen.getByText(/\/repos\/vue/)).toBeInTheDocument();
+ expect(screen.getByText(/isolated worktree of/i)).toBeInTheDocument();
+ expect(screen.queryByText("Laravel")).not.toBeInTheDocument();
+ });
+
+ it.each([
+ { name: "agent is missing", agent: null, runtimes: [] },
+ { name: "runtime is hidden or missing", agent: { runtime_id: "runtime-vue" }, runtimes: [] },
+ ])("does not substitute the viewer's directory when $name", async ({ agent, runtimes }) => {
+ mockDaemonStatus.daemonId = "daemon-A";
+ mockListRuntimes.mockResolvedValue(runtimes);
+ mockListResources.mockResolvedValue({
+ resources: [makeLocalDirectoryResource({ daemon_id: "daemon-A", local_path: "/repos/laravel", label: "Laravel" })],
+ total: 1,
+ });
+ const { container, queryClient } = renderHint("proj-1", agent);
+ await waitFor(() => expect(queryClient.isFetching()).toBe(0));
+ expect(container).toBeEmptyDOMElement();
});
it("renders nothing when project_id is null", () => {
@@ -199,7 +240,7 @@ describe("LocalDirectoryHint", () => {
expect(screen.queryByText(/isolated worktree/i)).not.toBeInTheDocument();
});
- it("ignores resources pinned to a different daemon", async () => {
+ it("ignores other daemons when there is no agent assignee", async () => {
mockDaemonStatus.daemonId = "daemon-A";
mockDaemonStatus.running = true;
mockListResources.mockResolvedValue({
@@ -212,10 +253,8 @@ describe("LocalDirectoryHint", () => {
],
total: 1,
});
- const { container } = renderHint("proj-1");
- // Allow the query to settle; the hint should still render nothing.
- await Promise.resolve();
- await Promise.resolve();
+ const { container, queryClient } = renderHint("proj-1");
+ await waitFor(() => expect(queryClient.isFetching()).toBe(0));
expect(container.querySelector("div[class*='rounded-md']")).toBeNull();
});
});
diff --git a/packages/views/projects/components/local-directory-hint.tsx b/packages/views/projects/components/local-directory-hint.tsx
index 979adac3f8..e518a2959e 100644
--- a/packages/views/projects/components/local-directory-hint.tsx
+++ b/packages/views/projects/components/local-directory-hint.tsx
@@ -3,15 +3,18 @@
import { useQuery } from "@tanstack/react-query";
import { FolderOpen, GitBranch } from "lucide-react";
import { projectResourcesOptions } from "@multica/core/projects";
-import type { LocalDirectoryResourceRef, ProjectResource } from "@multica/core/types";
+import type { Agent, LocalDirectoryResourceRef, ProjectResource } from "@multica/core/types";
import { useWorkspaceId } from "@multica/core/hooks";
+import { isAgentRuntimeBound } from "@multica/core/agents";
+import { runtimeListOptions } from "@multica/core/runtimes";
import { useLocalDaemonStatus } from "../../platform";
import { useT } from "../../i18n";
import { localDirectoryLabel } from "./local-directory-label";
/**
* Banner shown at the top of the issue's Activity section when the
- * project is pinned to a `local_directory` resource on **this** daemon.
+ * project is pinned to a `local_directory` resource on the assigned agent's
+ * daemon (or this daemon when no agent is assigned).
* Tells the user what starting an agent here will actually do to that
* directory, which differs by the resource's execution mode:
*
@@ -27,16 +30,28 @@ import { localDirectoryLabel } from "./local-directory-label";
* resources read-only in the sidebar but no Activity-section hint.
*
* SSR-safe: the underlying hook reads `window.daemonAPI` defensively, so
- * server renders return null.
+ * server renders return null. An unresolved agent runtime does not fall back
+ * to the viewer's directory.
*/
export function LocalDirectoryHint({
projectId,
+ assignedAgent,
}: {
projectId: string | null | undefined;
+ // undefined means no agent assignee; null means the assigned agent is unresolved.
+ assignedAgent?: Pick<Agent, "runtime_id" | "runtime_bound"> | null;
}) {
const { t } = useT("projects");
const wsId = useWorkspaceId();
const daemon = useLocalDaemonStatus();
+ const runtimeId = assignedAgent && isAgentRuntimeBound(assignedAgent) ? assignedAgent.runtime_id : null;
+ const { data: runtimes = [] } = useQuery({
+ ...runtimeListOptions(wsId),
+ enabled: Boolean(projectId && daemon.daemonId && runtimeId),
+ });
+ const targetDaemonId = assignedAgent !== undefined
+ ? runtimes.find((runtime) => runtime.id === runtimeId)?.daemon_id
+ : daemon.daemonId;
const { data: resources = [] } = useQuery({
...projectResourcesOptions(wsId, projectId ?? ""),
enabled: Boolean(projectId),
@@ -44,6 +59,7 @@ export function LocalDirectoryHint({
if (!projectId) return null;
if (!daemon.daemonId) return null;
+ if (!targetDaemonId) return null;
const matches: Array<ProjectResource & { resource_ref: LocalDirectoryResourceRef }> =
resources
@@ -51,7 +67,7 @@ export function LocalDirectoryHint({
(r): r is ProjectResource & { resource_ref: LocalDirectoryResourceRef } =>
r.resource_type === "local_directory",
)
- .filter((r) => r.resource_ref.daemon_id === daemon.daemonId);
+ .filter((r) => r.resource_ref.daemon_id === targetDaemonId);
if (matches.length === 0) return null;