Skip to content

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

Go

feat(chat): warn when agent daemon is too old for project context (#5867)

Naiyuan Qing7d2f20f2ee33
diff --git a/packages/core/runtimes/cli-version.test.ts b/packages/core/runtimes/cli-version.test.ts
index c00df052d3..bb7a0139a4 100644
--- a/packages/core/runtimes/cli-version.test.ts
+++ b/packages/core/runtimes/cli-version.test.ts
@@ -1,8 +1,10 @@
import { describe, it, expect } from "vitest";
import {
+ chatProjectContextSupported,
checkQuickCreateCliVersion,
checkQuickCreateFieldsCliVersion,
handoffSupported,
+ MIN_CHAT_PROJECT_CONTEXT_CLI_VERSION,
MIN_HANDOFF_CLI_VERSION,
} from "./cli-version";
@@ -64,3 +66,28 @@ describe("handoffSupported", () => {
expect(handoffSupported("v0.1.0-235-gdaf0e935-dirty")).toBe(true);
});
});
+
+describe("chatProjectContextSupported", () => {
+ it("supports a tagged release at or above the minimum", () => {
+ expect(chatProjectContextSupported(MIN_CHAT_PROJECT_CONTEXT_CLI_VERSION)).toBe(true);
+ expect(chatProjectContextSupported("v0.4.10")).toBe(true);
+ expect(chatProjectContextSupported("0.5.0")).toBe(true);
+ });
+
+ it("does not support a tagged release below the minimum", () => {
+ expect(chatProjectContextSupported("0.4.9")).toBe(false);
+ expect(chatProjectContextSupported("0.3.28")).toBe(false);
+ });
+
+ it("fails closed on empty or unparsable input", () => {
+ expect(chatProjectContextSupported("")).toBe(false);
+ expect(chatProjectContextSupported(undefined)).toBe(false);
+ expect(chatProjectContextSupported(null)).toBe(false);
+ expect(chatProjectContextSupported("garbage")).toBe(false);
+ });
+
+ it("treats git-describe dev builds as supported regardless of base tag", () => {
+ expect(chatProjectContextSupported("v0.4.8-37-g5d0275d68")).toBe(true);
+ expect(chatProjectContextSupported("v0.1.0-235-gdaf0e935-dirty")).toBe(true);
+ });
+});
diff --git a/packages/core/runtimes/cli-version.ts b/packages/core/runtimes/cli-version.ts
index 41b51e4ca3..4775b8b254 100644
--- a/packages/core/runtimes/cli-version.ts
+++ b/packages/core/runtimes/cli-version.ts
@@ -110,10 +110,37 @@ export const MIN_HANDOFF_CLI_VERSION = "0.3.28";
* round-trip, exactly like the quick-create version gate.
*/
export function handoffSupported(detected: string | undefined | null): boolean {
+ return meetsMinCliVersion(detected, MIN_HANDOFF_CLI_VERSION);
+}
+
+/**
+ * First release whose daemon renders the chat session's project context
+ * (description + resources) into the run brief (PR #5765, ships in v0.4.10).
+ * Older daemons still receive and honor the project's repos — the server
+ * pre-extracts those into the generic `repos` claim field — but silently skip
+ * the Project Context section, so the durable description never reaches the
+ * agent. SOFT gate: selecting a project always works; the UI only warns.
+ *
+ * Frontend-only constant: unlike handoff there is no server preview endpoint
+ * computing this, so there is no server twin to keep in lockstep with.
+ */
+export const MIN_CHAT_PROJECT_CONTEXT_CLI_VERSION = "0.4.10";
+
+/**
+ * Whether a daemon-reported CLI version is new enough to inject a chat
+ * session's project description into the run brief. Same degrade rules as
+ * `handoffSupported`: missing / unparsable / below-minimum are `false`,
+ * dev-built daemons (git-describe shape) always pass.
+ */
+export function chatProjectContextSupported(detected: string | undefined | null): boolean {
+ return meetsMinCliVersion(detected, MIN_CHAT_PROJECT_CONTEXT_CLI_VERSION);
+}
+
+function meetsMinCliVersion(detected: string | undefined | null, minimum: string): boolean {
const current = (detected ?? "").trim();
if (!current) return false;
if (DEV_DESCRIBE_RE.test(current)) return true;
const parsed = parseSemver(current);
if (!parsed) return false;
- return !lessThan(parsed, parseSemver(MIN_HANDOFF_CLI_VERSION)!);
+ return !lessThan(parsed, parseSemver(minimum)!);
}
diff --git a/packages/views/chat/chat-page.tsx b/packages/views/chat/chat-page.tsx
index 3ebe7567e1..29dcc950a5 100644
--- a/packages/views/chat/chat-page.tsx
+++ b/packages/views/chat/chat-page.tsx
@@ -270,6 +270,7 @@ export function ChatPage() {
agentName={c.activeAgent?.name}
projects={c.projects}
projectId={c.activeProjectId}
+ projectContextUnsupported={c.projectContextUnsupported}
onProjectChange={changeProjectContext}
isProjectUpdating={c.isProjectUpdating}
focusRequest={c.focusInputRequest}
diff --git a/packages/views/chat/components/chat-add-menu.tsx b/packages/views/chat/components/chat-add-menu.tsx
index a7e8371e4d..dce529a3aa 100644
--- a/packages/views/chat/components/chat-add-menu.tsx
+++ b/packages/views/chat/components/chat-add-menu.tsx
@@ -24,6 +24,10 @@ interface ChatAddMenuProps {
projects?: Project[];
projectId?: string | null;
onSelectProject?: (projectId: string | null) => void;
+ /** Soft warning: the active agent's daemon is too old to receive the
+ * project description. Selection stays enabled; the submenu only appends
+ * an explanatory hint so the user knows before choosing. */
+ projectContextUnsupported?: boolean;
disabled?: boolean;
}
@@ -38,6 +42,7 @@ export function ChatAddMenu({
projects = [],
projectId,
onSelectProject,
+ projectContextUnsupported,
disabled,
}: ChatAddMenuProps) {
const { t } = useT("chat");
@@ -104,6 +109,14 @@ export function ChatAddMenu({
{t(($) => $.input.remove_project_context)}
</DropdownMenuItem>
)}
+ {projectContextUnsupported && (
+ <>
+ <DropdownMenuSeparator />
+ <div className="max-w-56 px-2 py-1.5 text-xs text-muted-foreground">
+ {t(($) => $.input.project_context_unsupported)}
+ </div>
+ </>
+ )}
</DropdownMenuSubContent>
</DropdownMenuSub>
)}
diff --git a/packages/views/chat/components/chat-input.test.tsx b/packages/views/chat/components/chat-input.test.tsx
index 2f51abdf6a..16a6aff8de 100644
--- a/packages/views/chat/components/chat-input.test.tsx
+++ b/packages/views/chat/components/chat-input.test.tsx
@@ -422,6 +422,39 @@ describe("ChatInput project context", () => {
resource_count: 0,
};
+ it("warns next to the chip when the agent's daemon cannot apply the project description", () => {
+ renderInput({
+ projects: [sampleProject],
+ projectId: "project-alpha",
+ onProjectChange: vi.fn(),
+ projectContextUnsupported: true,
+ });
+
+ expect(
+ screen.getByText(
+ "Project description won't apply — this agent's daemon needs an upgrade",
+ ),
+ ).toBeInTheDocument();
+ // Soft gate: the warning must not lock the control.
+ expect(
+ screen.getByRole("button", { name: "Change project context" }),
+ ).not.toBeDisabled();
+ });
+
+ it("shows no daemon warning when support is current or unknown", () => {
+ renderInput({
+ projects: [sampleProject],
+ projectId: "project-alpha",
+ onProjectChange: vi.fn(),
+ });
+
+ expect(
+ screen.queryByText(
+ "Project description won't apply — this agent's daemon needs an upgrade",
+ ),
+ ).not.toBeInTheDocument();
+ });
+
it("renders the selected project chip and forwards context changes", () => {
const onProjectChange = vi.fn();
renderInput({
diff --git a/packages/views/chat/components/chat-input.tsx b/packages/views/chat/components/chat-input.tsx
index fdb8a50bc3..68385694a0 100644
--- a/packages/views/chat/components/chat-input.tsx
+++ b/packages/views/chat/components/chat-input.tsx
@@ -2,6 +2,7 @@
import type { ReactNode } from "react";
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
+import { TriangleAlert } from "lucide-react";
import { cn } from "@multica/ui/lib/utils";
import {
ContentEditor,
@@ -101,6 +102,11 @@ interface ChatInputProps {
projectId?: string | null;
onProjectChange?: (projectId: string | null) => void;
isProjectUpdating?: boolean;
+ /** True when the active agent's daemon is too old to inject the project
+ * description into the run brief. Soft signal: selection stays enabled,
+ * the composer only surfaces a warning next to the chip and in the
+ * project submenu. */
+ projectContextUnsupported?: boolean;
/** Monotonic nonce bumped by the owner whenever the compose box should grab
* keyboard focus — currently on "new chat" so the user can type right away.
* 0 (the initial value) is inert, so a plain deep-link open never steals
@@ -132,6 +138,7 @@ export function ChatInput({
projectId,
onProjectChange,
isProjectUpdating,
+ projectContextUnsupported,
focusRequest,
draftKeyOverride,
editorKeyOverride,
@@ -548,7 +555,7 @@ export function ChatInput({
aria-disabled={noAgent || undefined}
>
{selectedProject && (
- <div className="px-3 pt-2">
+ <div className="flex flex-wrap items-center gap-x-2 gap-y-1 px-3 pt-2">
<div
className={cn(
"inline-flex max-w-full",
@@ -570,6 +577,12 @@ export function ChatInput({
}
/>
</div>
+ {projectContextUnsupported && (
+ <span className="inline-flex min-w-0 items-center gap-1 text-xs text-warning">
+ <TriangleAlert className="size-3 shrink-0" />
+ {t(($) => $.input.project_context_unsupported)}
+ </span>
+ )}
</div>
)}
<div className="flex-1 min-h-0 overflow-y-auto px-3 py-2">
@@ -614,6 +627,7 @@ export function ChatInput({
projects={projects}
projectId={projectId}
onSelectProject={projectSelectionEnabled ? onProjectChange : undefined}
+ projectContextUnsupported={projectContextUnsupported}
/>
)}
{leftAdornment}
diff --git a/packages/views/chat/components/chat-window.tsx b/packages/views/chat/components/chat-window.tsx
index 18a25b3132..e32455d1af 100644
--- a/packages/views/chat/components/chat-window.tsx
+++ b/packages/views/chat/components/chat-window.tsx
@@ -61,6 +61,7 @@ import {
isStillOnComposeTarget,
planProjectContextChange,
} from "./use-chat-controller";
+import { useChatProjectContextSupport } from "./use-chat-project-context-support";
import { createLogger } from "@multica/core/logger";
import type { Agent, Attachment, ChatMessage, ChatMessagesPage, ChatPendingTask, ChatSession, PendingChatTasksResponse } from "@multica/core/types";
import { useT } from "../../i18n";
@@ -268,6 +269,8 @@ export function ChatWindow() {
availableAgents[0] ??
null;
+ const projectContextSupport = useChatProjectContextSupport(wsId, activeAgent);
+
// Three-state availability — "loading" stays neutral (no banner, no
// disable) so the input doesn't flash a fake "no agent" state in the
// few hundred ms before the agent list query resolves. Only `"none"`
@@ -938,6 +941,7 @@ export function ChatWindow() {
projects={projects}
projectId={activeProjectId}
onProjectChange={handleProjectChange}
+ projectContextUnsupported={projectContextSupport === false}
isProjectUpdating={
setSessionProject.isPending || (!!activeSessionId && !currentSession)
}
diff --git a/packages/views/chat/components/use-chat-controller.ts b/packages/views/chat/components/use-chat-controller.ts
index 5cee60514a..debe532fe6 100644
--- a/packages/views/chat/components/use-chat-controller.ts
+++ b/packages/views/chat/components/use-chat-controller.ts
@@ -35,6 +35,7 @@ import {
import { useChatStore } from "@multica/core/chat";
import { removeChatMessageFromCaches } from "@multica/core/realtime";
import { useChatDraftRestore } from "./use-chat-draft-restore";
+import { useChatProjectContextSupport } from "./use-chat-project-context-support";
import { createLogger } from "@multica/core/logger";
import type {
Agent,
@@ -369,6 +370,8 @@ export function useChatController(opts?: { isActive?: boolean }) {
const agentAvailability = useWorkspaceAgentAvailability();
const noAgent = agentAvailability === "none";
+ const projectContextSupport = useChatProjectContextSupport(wsId, activeAgent);
+
const presenceDetail = useAgentPresenceDetail(wsId, activeAgent?.id);
const availability =
presenceDetail === "loading" ? undefined : presenceDetail.availability;
@@ -842,6 +845,7 @@ export function useChatController(opts?: { isActive?: boolean }) {
activeSessionId,
selectedAgentId,
activeProjectId,
+ projectContextUnsupported: projectContextSupport === false,
isProjectUpdating:
setSessionProject.isPending || (!!activeSessionId && !currentSession),
currentSession,
diff --git a/packages/views/chat/components/use-chat-project-context-support.test.tsx b/packages/views/chat/components/use-chat-project-context-support.test.tsx
new file mode 100644
index 0000000000..edb013066e
--- /dev/null
+++ b/packages/views/chat/components/use-chat-project-context-support.test.tsx
@@ -0,0 +1,77 @@
+import type { ReactNode } from "react";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import { renderHook, waitFor } from "@testing-library/react";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { api } from "@multica/core/api";
+import { useChatProjectContextSupport } from "./use-chat-project-context-support";
+
+vi.mock("@multica/core/api", () => ({
+ api: {
+ listRuntimes: vi.fn().mockResolvedValue([]),
+ },
+}));
+
+const WS_ID = "ws-1";
+
+function runtimeRow(cliVersion: string | undefined) {
+ return {
+ id: "runtime-1",
+ workspace_id: WS_ID,
+ provider: "claude",
+ metadata: cliVersion === undefined ? {} : { cli_version: cliVersion },
+ };
+}
+
+function renderSupport(agent: { runtime_id?: string | null } | null) {
+ const qc = new QueryClient({
+ defaultOptions: { queries: { retry: false } },
+ });
+ const wrapper = ({ children }: { children: ReactNode }) => (
+ <QueryClientProvider client={qc}>{children}</QueryClientProvider>
+ );
+ return renderHook(() => useChatProjectContextSupport(WS_ID, agent), { wrapper });
+}
+
+describe("useChatProjectContextSupport", () => {
+ beforeEach(() => {
+ vi.mocked(api.listRuntimes).mockReset().mockResolvedValue([]);
+ });
+
+ it("returns false when the bound runtime reports a stale release version", async () => {
+ vi.mocked(api.listRuntimes).mockResolvedValue([runtimeRow("v0.4.9")] as never);
+
+ const { result } = renderSupport({ runtime_id: "runtime-1" });
+
+ await waitFor(() => expect(result.current).toBe(false));
+ });
+
+ it("returns true for a new-enough release and for dev-describe builds", async () => {
+ vi.mocked(api.listRuntimes).mockResolvedValue([
+ runtimeRow("v0.4.10-3-gabc1234"),
+ ] as never);
+
+ const { result } = renderSupport({ runtime_id: "runtime-1" });
+
+ await waitFor(() => expect(result.current).toBe(true));
+ });
+
+ it("returns null (no warning) when the agent, runtime binding, or runtime row is unknown", async () => {
+ vi.mocked(api.listRuntimes).mockResolvedValue([runtimeRow("v0.4.9")] as never);
+
+ expect(renderSupport(null).result.current).toBeNull();
+ expect(renderSupport({ runtime_id: null }).result.current).toBeNull();
+
+ const { result } = renderSupport({ runtime_id: "runtime-other" });
+ // The list resolves but never contains this runtime — stays "cannot tell".
+ await waitFor(() => expect(vi.mocked(api.listRuntimes)).toHaveBeenCalled());
+ expect(result.current).toBeNull();
+ });
+
+ it("fails closed to false when the runtime row reports no cli_version", async () => {
+ vi.mocked(api.listRuntimes).mockResolvedValue([runtimeRow(undefined)] as never);
+
+ const { result } = renderSupport({ runtime_id: "runtime-1" });
+
+ await waitFor(() => expect(result.current).toBe(false));
+ });
+});
diff --git a/packages/views/chat/components/use-chat-project-context-support.ts b/packages/views/chat/components/use-chat-project-context-support.ts
new file mode 100644
index 0000000000..b53330d2af
--- /dev/null
+++ b/packages/views/chat/components/use-chat-project-context-support.ts
@@ -0,0 +1,30 @@
+"use client";
+
+import { useQuery } from "@tanstack/react-query";
+import {
+ runtimeListOptions,
+ readRuntimeCliVersion,
+ chatProjectContextSupported,
+} from "@multica/core/runtimes";
+
+/**
+ * Whether the active agent's daemon is new enough to inject a chat session's
+ * project description into the run brief. `null` means "cannot tell" (no
+ * agent, no bound runtime, or the runtime row not in cache yet) and must NOT
+ * warn: this is a soft gate, and a spurious warning is worse than a
+ * description an old daemon drops — same policy as the handoff note gate in
+ * run-confirm.
+ *
+ * Shared by both send chains (chat tab controller and floating ChatWindow) so
+ * the resolution rule cannot drift between the two surfaces.
+ */
+export function useChatProjectContextSupport(
+ wsId: string,
+ agent: { runtime_id?: string | null } | null | undefined,
+): boolean | null {
+ const { data: runtimes = [] } = useQuery({ ...runtimeListOptions(wsId), enabled: !!wsId });
+ if (!agent?.runtime_id) return null;
+ const runtime = runtimes.find((r) => r.id === agent.runtime_id);
+ if (!runtime) return null;
+ return chatProjectContextSupported(readRuntimeCliVersion(runtime.metadata));
+}
diff --git a/packages/views/locales/en/chat.json b/packages/views/locales/en/chat.json
index b326f94ed9..fc7c53fb31 100644
--- a/packages/views/locales/en/chat.json
+++ b/packages/views/locales/en/chat.json
@@ -26,7 +26,8 @@
"project_context": "Project context",
"change_project_context": "Change project context",
"remove_project_context": "Remove project context",
- "no_projects": "No projects yet"
+ "no_projects": "No projects yet",
+ "project_context_unsupported": "Project description won't apply — this agent's daemon needs an upgrade"
},
"message_list": {
"show_details": "Show details",
diff --git a/packages/views/locales/ja/chat.json b/packages/views/locales/ja/chat.json
index 4569c60e46..c86e66fab0 100644
--- a/packages/views/locales/ja/chat.json
+++ b/packages/views/locales/ja/chat.json
@@ -25,7 +25,8 @@
"project_context": "プロジェクトコンテキスト",
"change_project_context": "プロジェクトコンテキストを変更",
"remove_project_context": "プロジェクトコンテキストを削除",
- "no_projects": "プロジェクトがまだありません"
+ "no_projects": "プロジェクトがまだありません",
+ "project_context_unsupported": "プロジェクトの説明は適用されません——このエージェントのデーモンのアップグレードが必要です"
},
"message_list": {
"show_details": "詳細を表示",
diff --git a/packages/views/locales/ko/chat.json b/packages/views/locales/ko/chat.json
index c63f0e3fb8..8cd1bb58d9 100644
--- a/packages/views/locales/ko/chat.json
+++ b/packages/views/locales/ko/chat.json
@@ -25,7 +25,8 @@
"project_context": "프로젝트 컨텍스트",
"change_project_context": "프로젝트 컨텍스트 변경",
"remove_project_context": "프로젝트 컨텍스트 제거",
- "no_projects": "아직 프로젝트가 없습니다"
+ "no_projects": "아직 프로젝트가 없습니다",
+ "project_context_unsupported": "프로젝트 설명이 적용되지 않습니다 — 이 에이전트의 데몬 업그레이드가 필요합니다"
},
"message_list": {
"show_details": "세부 정보 보기",
diff --git a/packages/views/locales/zh-Hans/chat.json b/packages/views/locales/zh-Hans/chat.json
index e59a675223..befe45b027 100644
--- a/packages/views/locales/zh-Hans/chat.json
+++ b/packages/views/locales/zh-Hans/chat.json
@@ -25,7 +25,8 @@
"project_context": "项目上下文",
"change_project_context": "更改项目上下文",
"remove_project_context": "移除项目上下文",
- "no_projects": "还没有项目"
+ "no_projects": "还没有项目",
+ "project_context_unsupported": "项目描述不会生效——该智能体的守护进程版本过旧,需要升级"
},
"message_list": {
"show_details": "查看详情",