Skip to content

armgit / kanzo

Public Imported from GitHub
0

Self-hosted, sharable kanban for humans and agents. One 4.7 MB binary, 5 MB of RAM, 10 to 60 tokens per agent reply, starts in 3 ms, zero setup.

Filter the board: keep only the tasks that match

Tommaso Marsond818cdea5e3f
diff --git a/src/app.js b/src/app.js
index 376a3c5..966e110 100644
--- a/src/app.js
+++ b/src/app.js
@@ -481,6 +481,7 @@ function renderHeader() {
const header = $("#header");
$("#new-task").hidden = !projects.length;
$("#human-only").hidden = !projects.length;
+ $("#filter").hidden = !projects.length;
$("#human-only").setAttribute("aria-pressed", String(isHumanOnly()));
if (!projects.length) { header.replaceChildren(); return; }
// Plain words for what each piece is: how much is open, and the repos on GitHub.
@@ -547,23 +548,39 @@ function renderColumns() {
if (state.dragging) return;
const all = state.project === "all";
const humanOnly = isHumanOnly();
+ const words = filterWords();
+ $("#filter").classList.toggle("on", words.length > 0);
for (const status of statuses) {
const col = columns.querySelector(`[data-status="${CSS.escape(status)}"]`);
- const mine = tasks.filter((t) => t.status === status && (!humanOnly || t.human));
+ const mine = tasks.filter((t) => t.status === status && (!humanOnly || t.human) && matchesFilter(t, words));
// Older done tasks the server left out (see loadBoard).
const last = status === statuses[statuses.length - 1];
const hidden = last && !state.allDone ? state.board.done_hidden || 0 : 0;
// Filtered, the server's count of older done tasks says nothing about human ones.
- const count = mine.length + (humanOnly ? 0 : hidden);
+ const filtered = humanOnly || words.length > 0;
+ const count = mine.length + (filtered ? 0 : hidden);
col.querySelector("h2 .count").textContent = count ? String(count) : "";
const more = hidden
? el("button", { class: "ghost more", onclick: () => { state.allDone = true; loadBoard(); } },
- humanOnly ? "Show older" : `Show ${hidden} older`)
+ filtered ? "Show older" : `Show ${hidden} older`)
: null;
col.querySelector(".cards").replaceChildren(...[more].filter(Boolean), ...mine.map((t) => card(t, all)));
}
}
+// The filter box keeps on the board only the tasks that hold every word typed, in their key,
+// title, description or tags: the same match as search, but the board stays a board.
+function filterWords() {
+ return $("#filter").value.toLowerCase().split(/\s+/).filter(Boolean);
+}
+
+function matchesFilter(t, words) {
+ if (!words.length) return true;
+ const tags = Array.isArray(t.tags) ? t.tags.join(" ") : t.tags || "";
+ const text = `${t.project}#${t.id} ${t.title} ${t.description || ""} ${tags}`.toLowerCase();
+ return words.every((w) => text.includes(w));
+}
+
// The board can show only human tasks; off at first, and each browser remembers the choice.
function isHumanOnly() {
return localStorageGet("kanzo.humanOnly") === "1";
@@ -734,6 +751,10 @@ function hideNewProject() {
$("#new-task").addEventListener("click", newTask);
$("#human-only").addEventListener("click", () => setHumanOnly(!isHumanOnly()));
+$("#filter").addEventListener("input", render);
+$("#filter").addEventListener("keydown", (e) => {
+ if (e.key === "Escape") { e.stopPropagation(); $("#filter").value = ""; render(); $("#filter").blur(); }
+});
$("#new-project-toggle").addEventListener("click", showNewProject);
$("#new-project-cancel").addEventListener("click", hideNewProject);
$("#project-dialog").addEventListener("mousedown", (e) => { if (e.target.id === "project-dialog") hideNewProject(); });
@@ -1130,6 +1151,9 @@ document.addEventListener("keydown", (e) => {
if (e.key === "n" && !typing && !e.metaKey && !e.ctrlKey) {
if (!$("#new-task").hidden) { e.preventDefault(); newTask(); }
}
+ if (e.key === "f" && !typing && !e.metaKey && !e.ctrlKey) {
+ if (!$("#filter").hidden) { e.preventDefault(); $("#filter").focus(); }
+ }
if (e.key === "h" && !typing && !e.metaKey && !e.ctrlKey) {
if (!$("#human-only").hidden) { e.preventDefault(); setHumanOnly(!isHumanOnly()); }
}
diff --git a/src/index.html b/src/index.html
index 4cdbf8c..16fb669 100644
--- a/src/index.html
+++ b/src/index.html
@@ -154,6 +154,13 @@ header .repo-link .icon svg { width: 14px; height: 14px; }
}
#new-task { display: inline-flex; align-items: center; gap: 6px; padding-left: 12px; }
#new-task .icon svg { width: 16px; height: 16px; }
+/* Filter: the board keeps only the tasks whose key, title, description or tags hold every word typed. */
+#filter {
+ width: 180px; height: 35px; padding: 0 14px; border: 1px solid var(--border); border-radius: 99px;
+ background: transparent; color: var(--text); font: inherit; font-size: 13px; outline: none;
+}
+#filter:focus { border-color: var(--link); }
+#filter.on { border-color: var(--link); background: color-mix(in srgb, var(--link) 8%, transparent); }
/* Show only human tasks: a small icon, coloured while the filter is on. */
#human-only { color: var(--muted); }
#human-only:hover, #human-only:focus-visible { color: var(--text); }
@@ -442,6 +449,8 @@ label.setting { cursor: pointer; }
.settings-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
#settings-nav { flex-direction: row; border-right: 0; border-bottom: 1px solid var(--border); }
header { padding: 12px; }
+ /* On a phone the filter takes its own line, below the title and buttons. */
+ #filter { order: 1; flex: 1 0 100%; width: auto; }
}
</style>
</head>
@@ -461,6 +470,7 @@ label.setting { cursor: pointer; }
<main>
<header>
<div class="info" id="header"></div>
+ <input type="search" id="filter" placeholder="Filter board" title="Show only the tasks that match (f)" aria-label="Filter the board" autocomplete="off" spellcheck="false" hidden>
<button class="ghost" id="human-only" title="Show only human tasks (h)" aria-label="Show only human tasks" aria-pressed="false" hidden><span class="icon" data-icon="human"></span></button>
<button class="ghost" id="network" aria-haspopup="dialog" aria-controls="network-menu"></button>
<button class="btn primary" id="new-task" title="New task (n)" hidden><span class="icon" data-icon="plus"></span>New task</button>