Skip to content

The agent that grows with you

fix(kanban): board switcher shows the bound project with an unbind action

teknium10985aeb732eb
diff --git a/plugins/kanban/dashboard/dist/index.js b/plugins/kanban/dashboard/dist/index.js
index 7f88456df5f..11fd0ad9264 100644
--- a/plugins/kanban/dashboard/dist/index.js
+++ b/plugins/kanban/dashboard/dist/index.js
@@ -1263,6 +1263,10 @@
onSwitch: switchBoard,
onNewClick: function () { setShowNewBoard(true); },
onSettingsClick: function () { setShowBoardSettings(true); },
+ onUnbindProject: function () {
+ updateBoard(board, { project_id: "" })
+ .catch(function (e) { setError(String(e.message || e)); });
+ },
onDeleteBoard: deleteBoard,
requestDialog: function (req) { return kanbanDialogs.request(req); },
}),
@@ -2065,6 +2069,30 @@
);
}
+ // Readout of the board's project binding (GET /boards annotates every
+ // board with project_id + project_name). The × sends PATCH
+ // {project_id: ""} — the same clear the settings dialog uses — so the
+ // binding is visible and removable without opening Settings.
+ function BoardProjectBadge(props) {
+ const { t } = useI18n();
+ const b = props.board;
+ if (!b || !b.project_id) return null;
+ return h(Badge, {
+ variant: "outline",
+ className: "hermes-kanban-board-project text-xs font-normal gap-1",
+ title: tx(t, "boardProjectBadgeTitle", "New tasks on this board inherit this project"),
+ },
+ tx(t, "boardProjectBadge", "Project: {name}", { name: b.project_name || b.project_id }),
+ h("button", {
+ type: "button",
+ className: "hermes-kanban-board-project-unbind",
+ "aria-label": tx(t, "unbindProject", "Unbind project"),
+ title: tx(t, "unbindProject", "Unbind project"),
+ onClick: props.onUnbind,
+ }, "×"),
+ );
+ }
+
function BoardSwitcher(props) {
const { t } = useI18n();
const list = props.boardList || [];
@@ -2097,6 +2125,7 @@
title: tx(t, "boardSettingsTitle",
"Board settings — name, description, and the default project directory new tasks inherit"),
}, tx(t, "boardSettings", "Settings")),
+ h(BoardProjectBadge, { board: current, onUnbind: props.onUnbindProject }),
h(DocsLink, null),
);
}
@@ -2122,6 +2151,7 @@
),
h("span", { className: "text-xs text-muted-foreground" },
`${currentTotal || 0} task${currentTotal === 1 ? "" : "s"}`),
+ h(BoardProjectBadge, { board: current, onUnbind: props.onUnbindProject }),
),
),
h("div", { className: "flex-1" }),
@@ -2378,15 +2408,19 @@
setErr(null);
// Send default_workdir unconditionally: "" clears it on the server,
// a path sets it (validated server-side: absolute + existing dir).
+ // Exception: a blank directory next to a chosen project is omitted
+ // so the server mirrors the project's primary folder into
+ // default_workdir — the same seeding the create dialog gets.
// project_id mirrors that only when the selector was rendered
// (projects loaded): "" clears the binding, an id scopes the board.
// When the projects store is unreachable the field is omitted so
// saving unrelated settings never wipes an existing binding.
+ const boundProject = projects.length ? projectId : undefined;
props.onSave({
name: name.trim() || undefined,
description: description.trim() || undefined,
- default_workdir: projectDirectory.trim(),
- project_id: projects.length ? projectId : undefined,
+ default_workdir: projectDirectory.trim() || (boundProject ? undefined : ""),
+ project_id: boundProject,
}).catch(function (e) {
setErr(parseApiErrorMessage(e));
setSubmitting(false);
diff --git a/plugins/kanban/dashboard/dist/style.css b/plugins/kanban/dashboard/dist/style.css
index fe0fd72a268..b82f164d019 100644
--- a/plugins/kanban/dashboard/dist/style.css
+++ b/plugins/kanban/dashboard/dist/style.css
@@ -293,6 +293,20 @@
padding: 0.05rem 0.3rem !important;
}
+/* Board-level project binding readout in the board switcher; the × unbinds. */
+.hermes-kanban-board-project-unbind {
+ margin-left: 0.25rem;
+ line-height: 1;
+ padding: 0 0.15rem;
+ border-radius: 0.2rem;
+ color: var(--color-muted-foreground, #888);
+ cursor: pointer;
+}
+.hermes-kanban-board-project-unbind:hover {
+ color: var(--color-destructive, #d44);
+ background: color-mix(in srgb, var(--color-destructive, #d44) 15%, transparent);
+}
+
.hermes-kanban-needs-assignee {
font-size: 0.6rem !important;
padding: 0.05rem 0.3rem !important;
diff --git a/tests/plugins/test_kanban_dashboard_plugin.py b/tests/plugins/test_kanban_dashboard_plugin.py
index c59b419275c..6edb829ea76 100644
--- a/tests/plugins/test_kanban_dashboard_plugin.py
+++ b/tests/plugins/test_kanban_dashboard_plugin.py
@@ -908,37 +908,31 @@ def test_dashboard_dependency_selects_use_value_change_handler():
def test_dashboard_board_project_binding_is_exposed_in_ui():
- """Regression for #114652: the board create/settings dialogs must
- expose the board↔project binding the REST API already supports
- (POST/PATCH ``project_id``, validated against the projects store).
-
- The bundle has no build step, so the wiring is pinned textually, in
- the same style as the dependency-select regression above:
- 1. both dialogs fetch the live project list via GET /projects;
- 2. the selectors land on React state through the shared
- ``selectChangeHandler`` helper (the exact bug class salvaged from
- #20019: value-only selects that never update state);
- 3. create sends ``project_id`` only when the selector rendered and a
- project was picked, while settings PATCHes mirror
- ``default_workdir`` — send unconditionally when the selector
- rendered, where ``""`` clears the binding — and omit the field
- when the projects store is unreachable so saving unrelated
- settings can never wipe an existing binding.
+ """The board create/settings dialogs and the board switcher expose the
+ board<->project binding the REST API already supports (POST/PATCH
+ ``project_id``; ``""`` clears it).
+
+ The bundle has no build step, so the wiring is pinned textually like
+ the dependency-select regression above: both dialogs load the live
+ list from GET /projects and drive React state through the shared
+ ``selectChangeHandler``; create sends ``project_id`` only when a
+ project was picked; settings sends it whenever the selector rendered
+ (``""`` clears) and omits it when the projects store is unreachable so
+ saving unrelated settings never wipes a binding; the switcher shows the
+ bound project as a badge whose unbind action PATCHes ``project_id: ""``.
"""
repo_root = Path(__file__).resolve().parents[2]
bundle = (
repo_root / "plugins" / "kanban" / "dashboard" / "dist" / "index.js"
- ).read_text()
+ ).read_text(encoding="utf-8")
- assert "function useBoardProjects()" in bundle
assert "`${API}/projects`" in bundle
- assert "selectChangeHandler(setProjectId)" in bundle
- assert "useState(b.project_id || \"\")" in bundle
-
- create_payload = "project_id: (projects.length && projectId) || undefined,"
- patch_payload = "project_id: projects.length ? projectId : undefined,"
- assert create_payload in bundle
- assert patch_payload in bundle
+ assert bundle.count("selectChangeHandler(setProjectId)") == 2
+ assert "project_id: (projects.length && projectId) || undefined," in bundle
+ assert "const boundProject = projects.length ? projectId : undefined;" in bundle
+ assert "project_id: boundProject," in bundle
+ assert "hermes-kanban-board-project-unbind" in bundle
+ assert 'updateBoard(board, { project_id: "" })' in bundle
def test_bulk_archive(client):
diff --git a/website/docs/user-guide/features/kanban.md b/website/docs/user-guide/features/kanban.md
index 9466f0a2e1b..9e64ee4c6ef 100644
--- a/website/docs/user-guide/features/kanban.md
+++ b/website/docs/user-guide/features/kanban.md
@@ -203,13 +203,23 @@ matters.
shifting the CLI's `current` pointer out from under a terminal you left
open.
- **+ New board** — opens a modal asking for slug, display name,
- description, and icon. Option to auto-switch to the new board.
+ description, icon, project directory, and (when any Project exists) a
+ **Project** selector. Option to auto-switch to the new board.
- **Settings** — opens a modal for editing the current board's display
name, description, and **project directory** (`default_workdir`). The
project directory is the board-level workspace default every new task
inherits (git repo → preserved worktree, plain dir → preserved
directory); each task can still override it at creation time. Clearing
the field reverts new tasks to disposable scratch workspaces.
+- **Project** (in both modals) — binds the board to a Hermes Project
+ (the board's `project_id`).
+ Tasks created on a bound board inherit the Project; picking a project
+ while the directory field is blank also seeds the project directory
+ with the Project's primary folder. The bound project shows as a
+ `Project: <name>` badge next to the board dropdown; its `×` unbinds the
+ board (sends `project_id: ""`) without touching the project directory,
+ and `No binding` in Settings does the same on save. The selector only
+ appears when at least one Project exists.
- **Archive** — only shown on non-`default` boards. Confirms, then moves
the board dir to `boards/_archived/`.