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.
Rust ai-agentsclaude-codeclicodexcoding-agentskanbanlocal-firstmcpmcp-servermodel-context-protocolproductivityproject-managementraspberry-pirustself-hostedsqlitetask-manager
Highlight filter qualifiers while typing them
emanuele-embceebb0108c1
diff --git a/src/app.js b/src/app.jsindex 164a137..ea9e3a3 100644--- a/src/app.js+++ b/src/app.js@@ -479,9 +479,9 @@ function renderHeader() {const header = $("#header");$("#new-task").hidden = !projects.length;$("#human-only").hidden = !projects.length || isPropertyHidden("human");- $("#filter").hidden = !projects.length;+ $("#filter-box").hidden = !projects.length;$("#filters").replaceChildren(...(projects.length ? savedFilters() : []).map((f, i) =>- el("span", { class: "chip" }, f,+ el("span", { class: "chip" }, el("span", {}, queryNodes(f)),el("button", { type: "button", title: `Remove "${f}"`, "aria-label": `Remove the filter ${f}`,onclick: () => setFilters(savedFilters().filter((_, j) => j !== i)) }, icon("close")))));$("#human-only").setAttribute("aria-pressed", String(isHumanOnly()));@@ -582,21 +582,65 @@ function filterQuery() {return [...savedFilters(), $("#filter").value].join(" ").trim();}-const QUALIFIERS = ["tag", "status", "project", "title", "description", "url", "comment", "id", "comments", "images",- "created", "updated", "is", "has", "no"];--// The text to highlight: words, phrases, and what tag:, title: and description: look for.+const anyText = () => true;+const isNumber = (v) => /^[+-]?\d+$/.test(v);+const isDate = (v) => /^\d{4}-\d{2}-\d{2}$/.test(v);+const inRange = (side) => (v) => {+ const ends = v.split("..");+ return ends.length > 1 ? ends.length === 2 && ends.every(side) : side(v.replace(/^(>=|<=|>|<)/, ""));+};+const isField = (v) => ["description", "tags", "url", "comments", "images"].includes(v);+// What the server takes as each qualifier's value: anything else makes it a plain word.+const QUALIFIERS = new Map([+ ["tag", anyText], ["status", anyText], ["project", anyText], ["title", anyText], ["description", anyText],+ ["url", anyText], ["comment", anyText], ["id", inRange(isNumber)], ["comments", inRange(isNumber)],+ ["images", inRange(isNumber)], ["created", inRange(isDate)], ["updated", inRange(isDate)],+ ["is", (v) => v === "human"], ["has", isField], ["no", isField],+]);++// A part of a query, read as the server reads it. Null for a word.+function qualifierIn(part) {+ const match = !part.startsWith('"') && part.replace(/"/g, "").toLowerCase().match(/^(-?)([^:]+):(.*)$/);+ const valid = match && QUALIFIERS.get(match[2]);+ if (!valid) return null;+ const [, negated, name, value] = match;+ // With no value yet it's still being typed; with a wrong one, it's a word.+ return !value || valid(value) ? { negated: negated === "-", name, value } : null;+}++// The text to highlight on cards: words, phrases, and what tag:, title: and description: look for.function wordsOf(query) {const words = [];- for (const part of query.toLowerCase().match(/(?:[^\s"]+|"[^"]*"?)+/g) || []) {- const text = part.replace(/"/g, "");- const qualifier = part.startsWith('"') ? null : text.match(/^(-?)([^:]+):(.*)$/);- if (!qualifier || !QUALIFIERS.includes(qualifier[2])) words.push(text);- else if (!qualifier[1] && ["tag", "title", "description"].includes(qualifier[2])) words.push(qualifier[3]);+ for (const part of query.match(/(?:[^\s"]+|"[^"]*"?)+/g) || []) {+ const qualifier = qualifierIn(part);+ if (!qualifier) words.push(part.replace(/"/g, "").toLowerCase());+ else if (!qualifier.negated && ["tag", "title", "description"].includes(qualifier.name)) words.push(qualifier.value);}return words.filter(Boolean);}+// A query as text, with its qualifiers marked. Keeps every character, for .query-mirror to line up.+function queryNodes(query) {+ return (query.match(/\s+|(?:[^\s"]+|"[^"]*"?)+/g) || []).map((part) => {+ const qualifier = qualifierIn(part);+ if (!qualifier) return part;+ const key = part.indexOf(":") + 1;+ return el("span", { class: qualifier.value ? "qualifier complete" : "qualifier" },+ el("span", { class: "qualifier-key" }, part.slice(0, key)), part.slice(key));+ });+}++// An input can't color part of its text, so a copy behind it shows it, and the input keeps the caret.+function paintQuery(input) {+ const mirror = input.previousElementSibling;+ mirror.firstElementChild.replaceChildren(...queryNodes(input.value));+ mirror.scrollLeft = input.scrollLeft;+}++for (const input of document.querySelectorAll(".query input")) {+ for (const type of ["input", "scroll", "keyup", "click"]) input.addEventListener(type, () => paintQuery(input));+}+function highlight(name, root, words) {if (!window.Highlight) return;const re = new RegExp(words.map((w) => w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|"), "gi");@@ -789,8 +833,8 @@ let filterTimer;$("#filter").addEventListener("input", () => { clearTimeout(filterTimer); filterTimer = setTimeout(loadBoard, 120); });$("#filter").addEventListener("keydown", (e) => {const box = e.target, text = box.value.trim();- if (e.key === "Escape") { e.stopPropagation(); box.value = ""; loadBoard(); box.blur(); }- else if (e.key === "Enter" && text) { box.value = ""; setFilters([...savedFilters(), text]); }+ if (e.key === "Escape") { e.stopPropagation(); box.value = ""; paintQuery(box); loadBoard(); box.blur(); }+ else if (e.key === "Enter" && text) { box.value = ""; paintQuery(box); setFilters([...savedFilters(), text]); }else if (e.key === "Backspace" && !box.value && savedFilters().length) setFilters(savedFilters().slice(0, -1));});$("#new-project-toggle").addEventListener("click", showNewProject);@@ -1111,6 +1155,7 @@ function openSearch() {closeMenu();$("#search-dialog").hidden = false;$("#search").value = "";+ paintQuery($("#search"));$("#search").focus();runSearch();}@@ -1173,7 +1218,7 @@ document.addEventListener("keydown", (e) => {openSearch();}if (e.key === "n" && plain && !$("#new-task").hidden) { e.preventDefault(); newTask(); }- if (e.key === "f" && plain && !$("#filter").hidden) { e.preventDefault(); $("#filter").focus(); }+ if (e.key === "f" && plain && !$("#filter-box").hidden) { e.preventDefault(); $("#filter").focus(); }if (e.key === "h" && plain && !$("#human-only").hidden) { e.preventDefault(); setHumanOnly(!isHumanOnly()); }});diff --git a/src/index.html b/src/index.htmlindex bd34a49..8c64a9e 100644--- a/src/index.html+++ b/src/index.html@@ -147,9 +147,28 @@ 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; }+.query { position: relative; display: block; }+.query[hidden] { display: none; }+.query input { position: relative; display: block; color: transparent; caret-color: var(--text); }+.query input::placeholder { color: var(--faint); }+.query input::selection { color: transparent; background: color-mix(in srgb, var(--link) 30%, transparent); }+.query-mirror {+ position: absolute; top: 0; right: 0; bottom: 0; left: 0; display: flex; align-items: center; overflow: hidden;+ color: var(--text); line-height: normal; pointer-events: none;+}+.query-mirror > span, .chip > span:first-child { white-space: pre; }+/* Room to scroll as far as the input does, with its clear button. */+.query-mirror > span { padding-right: 40px; }+/* Color only, no weight or padding: the text has to stay exactly under the input's caret. */+.qualifier-key { color: var(--link); }+.qualifier.complete { border-radius: 3px; background: color-mix(in srgb, var(--link) 18%, transparent); }+.chip .qualifier.complete { background: none; }+.chip .qualifier-key { font-weight: 600; }+/* Stops where the input's text does, before its clear button. */+#filter-box .query-mirror { padding: 0 15px; font-size: 13px; clip-path: inset(0 28px 0 0); }#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;+ background: transparent; 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); }@@ -351,7 +370,9 @@ header .repo-link .icon svg { width: 14px; height: 14px; }}.search-field { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }.search-field .icon { color: var(--faint); }-.search-field input { flex: 1; min-width: 0; border: 0; background: none; font-size: 16px; }+.search-field .query { flex: 1; min-width: 0; }+.search-field input { width: 100%; padding: 0; border: 0; background: none; font-size: 16px; }+.search-field .query-mirror { font-size: 16px; }.search-field input::-webkit-search-cancel-button { display: none; }.results { overflow-y: auto; padding: 6px; }.dialog-window {@@ -451,7 +472,8 @@ label.setting { cursor: pointer; }#settings-nav { flex-direction: row; border-right: 0; border-bottom: 1px solid var(--border); }header { padding: 12px; }#filters { order: 1; }- #filter { order: 1; flex: 1 0 100%; width: auto; }+ #filter-box { order: 1; flex: 1 0 100%; }+ #filter { width: 100%; }}</style></head>@@ -472,7 +494,7 @@ label.setting { cursor: pointer; }<header><div class="info" id="header"></div><div id="filters"></div>- <input type="search" id="filter" placeholder="Filter board" title="Show only the tasks that match, like tag:bug or -status:done (f)" aria-label="Filter the board" autocomplete="off" spellcheck="false" hidden>+ <span class="query" id="filter-box" hidden><span class="query-mirror" aria-hidden="true"><span></span></span><input type="search" id="filter" placeholder="Filter board" title="Show only the tasks that match, like tag:bug or -status:done (f)" aria-label="Filter the board" autocomplete="off" spellcheck="false"></span><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>@@ -592,7 +614,7 @@ label.setting { cursor: pointer; }</div><div class="search-dialog" id="search-dialog" hidden><div class="search-window" role="dialog" aria-label="Search tasks">- <label class="search-field"><span class="icon" data-icon="search"></span><input id="search" type="search" placeholder="Search tasks" autocomplete="off" spellcheck="false" aria-label="Search tasks"></label>+ <label class="search-field"><span class="icon" data-icon="search"></span><span class="query"><span class="query-mirror" aria-hidden="true"><span></span></span><input id="search" type="search" placeholder="Search tasks" autocomplete="off" spellcheck="false" aria-label="Search tasks"></span></label><div class="results" id="search-results"></div></div></div>