summaryrefslogtreecommitdiff
path: root/web/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/app.js')
-rw-r--r--web/app.js17
1 files changed, 12 insertions, 5 deletions
diff --git a/web/app.js b/web/app.js
index a2b0ea9..408ffce 100644
--- a/web/app.js
+++ b/web/app.js
@@ -96,6 +96,12 @@ export function renderChangestatsBadge(stats, doc = (typeof document !== 'undefi
return span;
}
+function truncateToWordBoundary(text, maxLen = 120) {
+ if (!text || text.length <= maxLen) return text;
+ const cut = text.lastIndexOf(' ', maxLen);
+ return (cut > 0 ? text.slice(0, cut) : text.slice(0, maxLen)) + '…';
+}
+
function createTaskCard(task) {
const card = document.createElement('div');
card.className = 'task-card';
@@ -175,7 +181,7 @@ function createTaskCard(task) {
});
footer.appendChild(btn);
} else if (task.state === 'READY') {
- renderSubtaskRollup(task.id, footer);
+ renderSubtaskRollup(task, footer);
const acceptBtn = document.createElement('button');
acceptBtn.className = 'btn-accept';
acceptBtn.textContent = 'Accept';
@@ -196,7 +202,7 @@ function createTaskCard(task) {
if (task.question) {
renderQuestionFooter(task, footer);
} else {
- renderSubtaskRollup(task.id, footer);
+ renderSubtaskRollup(task, footer);
}
const cancelBtn = document.createElement('button');
cancelBtn.className = 'btn-cancel';
@@ -867,17 +873,18 @@ const STATE_EMOJI = {
READY: '👀', BLOCKED: '⏸',
};
-async function renderSubtaskRollup(taskId, footer) {
+async function renderSubtaskRollup(task, footer) {
footer.addEventListener('click', (e) => e.stopPropagation());
const container = document.createElement('div');
container.className = 'subtask-rollup';
footer.prepend(container);
try {
- const res = await fetch(`${API_BASE}/api/tasks/${taskId}/subtasks`);
+ const res = await fetch(`${API_BASE}/api/tasks/${task.id}/subtasks`);
const subtasks = await res.json();
if (!subtasks || subtasks.length === 0) {
- container.textContent = 'Waiting for subtasks…';
+ const blurb = task.description || task.name;
+ container.textContent = blurb ? truncateToWordBoundary(blurb) : 'Waiting for subtasks…';
return;
}
const ul = document.createElement('ul');