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.

Find tasks to wait on while typing

emanuele-embdf736fb64b1
diff --git a/README.md b/README.md
index 4e5df87..327e1a4 100644
--- a/README.md
+++ b/README.md
@@ -99,7 +99,7 @@ Turn on Backlog in Settings for a column agents leave alone, until you move its
> [!TIP]
> **Just ask your agent:** *"make kanzo#12 wait on #10 and #11."*
-List what a task waits on in its panel, or have agents pass `waits_on`. Until those tasks are done, `next_task` skips it, and its card is dimmed and says what it waits on. Only `done` counts: a task in `review` still blocks. Nothing stops you from moving a waiting task yourself.
+In a task's panel, type in Waits on to find other tasks in its project and pick them, or have agents pass `waits_on`. Until those tasks are done, `next_task` skips it, and its card is dimmed and says what it waits on. Only `done` counts: a task in `review` still blocks. Nothing stops you from moving a waiting task yourself.
## Filter and search
diff --git a/src/app.js b/src/app.js
index cdac602..8519dc6 100644
--- a/src/app.js
+++ b/src/app.js
@@ -1465,12 +1465,69 @@ $("#p-url").addEventListener("blur", (e) => {
else e.target.value = url;
});
+let waitResults = [], waitSelected = 0, waitRequest = 0, waitTimer;
+
+function closeWaits() {
+ clearTimeout(waitTimer);
+ waitRequest++;
+ waitResults = [];
+ $("#p-waits-list").hidden = true;
+ $("#p-waits").setAttribute("aria-expanded", "false");
+}
+
+// The search behind the filter, for what's typed after the last comma.
+async function findWaits() {
+ const parts = $("#p-waits").value.split(",").map((part) => part.trim());
+ const words = parts[parts.length - 1];
+ if (!words || !panelTask) { closeWaits(); return; }
+ const { id, project } = panelTask;
+ const request = ++waitRequest;
+ try {
+ const found = await api("GET", "/search?q=" + encodeURIComponent(`project:${project} -status:done ${words}`));
+ if (request !== waitRequest) return;
+ waitResults = found.filter((t) => t.id !== id && !parts.includes(key(t))).slice(0, 8);
+ waitSelected = 0;
+ const list = $("#p-waits-list");
+ list.replaceChildren(...waitResults.map((t, i) => el("button", { type: "button", tabindex: "-1", role: "option", class: "result" + (i === 0 ? " selected" : ""),
+ onmousemove: () => selectWait(i),
+ // Before the field loses focus, which would save half a word.
+ onmousedown: (e) => { e.preventDefault(); pickWait(t); } },
+ el("span", { class: "mono" }, `#${t.id}`),
+ el("span", { class: "title" }, t.title),
+ el("span", { class: "meta" }, t.status))));
+ if (!waitResults.length) list.append(el("span", { class: "note" }, "No tasks match."));
+ list.hidden = false;
+ $("#p-waits").setAttribute("aria-expanded", "true");
+ highlight("search", list, wordsOf(words));
+ } catch (err) { toast(err.message); }
+}
+
+function selectWait(i) {
+ const rows = $("#p-waits-list").querySelectorAll(".result");
+ waitSelected = (i + rows.length) % rows.length;
+ rows.forEach((r, j) => r.classList.toggle("selected", j === waitSelected));
+ rows[waitSelected].scrollIntoView({ block: "nearest" });
+}
+
+function pickWait(t) {
+ const input = $("#p-waits");
+ const kept = input.value.split(",").slice(0, -1).map((part) => part.trim()).filter(Boolean);
+ input.value = [...kept, key(t)].join(", ") + ", ";
+ closeWaits();
+}
+
+$("#p-waits").addEventListener("input", () => { clearTimeout(waitTimer); waitTimer = setTimeout(findWaits, 120); });
$("#p-waits").addEventListener("keydown", (e) => {
- if (e.key === "Enter") { e.preventDefault(); e.target.blur(); }
+ const listed = waitResults.length > 0;
+ if ((e.key === "ArrowDown" || e.key === "ArrowUp") && listed) { e.preventDefault(); selectWait(waitSelected + (e.key === "ArrowDown" ? 1 : -1)); }
+ else if (e.key === "Enter") { e.preventDefault(); if (listed) pickWait(waitResults[waitSelected]); else e.target.blur(); }
+ else if (e.key === "Escape" && !$("#p-waits-list").hidden) { e.stopPropagation(); closeWaits(); }
else if (e.key === "Escape") cancelField(e, panelWaits);
});
$("#p-waits").addEventListener("blur", (e) => {
- if (panelTask && e.target.value.trim() !== panelWaits) patchTask({ waits_on: e.target.value });
+ closeWaits();
+ e.target.value = e.target.value.replace(/[,\s]+$/, "");
+ if (panelTask && e.target.value !== panelWaits) patchTask({ waits_on: e.target.value });
});
$("#p-comment-form").addEventListener("submit", async (e) => {
diff --git a/src/index.html b/src/index.html
index 96f881e..7b9d40d 100644
--- a/src/index.html
+++ b/src/index.html
@@ -332,6 +332,14 @@ html:not([data-hide~="waiting"]) .card.waiting:not(:hover) { opacity: .6; }
[data-hide~="images"] .panel .thumbs { display: none; }
.links { display: flex; flex-wrap: wrap; gap: 4px; }
#p-waits-links:not(:empty) { margin-top: 8px; }
+.waits-field { display: block; position: relative; }
+.suggest { position: absolute; z-index: 5; top: calc(100% + 10px); left: -10px; right: -10px; max-height: 280px; padding: 4px; background: var(--menu); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
+.suggest .result { align-items: center; padding: 6px 8px; }
+.suggest .result.selected { background: var(--active); }
+.suggest .result .title { flex: 1; min-width: 0; }
+.suggest .result .meta { margin: 0; }
+.suggest .result .mono { flex: none; color: var(--faint); font-size: 12px; }
+.suggest .note { display: block; padding: 8px; }
.links .tag { border: 0; max-width: 100%; }
.links .tag:hover, .links .tag:focus-visible { background: var(--active); }
.links span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; }
@@ -582,7 +590,7 @@ html:not(.ready) aside { visibility: hidden; }
<div data-prop="tags">Tags <span><input class="inline" id="p-tags" placeholder="Add tags, like bug, ui" autocomplete="off" spellcheck="false"></span></div>
<div data-prop="url">URL <span><input class="inline" id="p-url" type="url" placeholder="Add a link, like a pull request" autocomplete="off" spellcheck="false"></span></div>
<div data-prop="human">Human <span class="human-field"><label class="switch"><input type="checkbox" id="p-human" aria-label="Human task"><span></span></label><span class="hint">Agents skip it</span></span></div>
- <div data-prop="waiting">Waits on <span><input class="inline" id="p-waits" placeholder="Add tasks, like api#12" autocomplete="off" spellcheck="false"><span class="links" id="p-waits-links"></span></span></div>
+ <div data-prop="waiting">Waits on <span><span class="waits-field"><input class="inline" id="p-waits" placeholder="Type to find a task, or api#12" autocomplete="off" spellcheck="false" role="combobox" aria-autocomplete="list" aria-controls="p-waits-list" aria-expanded="false"><span class="results suggest" id="p-waits-list" role="listbox" hidden></span></span><span class="links" id="p-waits-links"></span></span></div>
<div data-prop="waiting" id="p-blocks-row">Blocks <span class="links" id="p-blocks"></span></div>
<div data-prop="created">Created <span id="p-created"></span></div>
<div data-prop="updated">Updated <span id="p-updated"></span></div>