diff --git a/frontend/dashboard.js b/frontend/dashboard.js
index 98ebb2c..cf7f79b 100644
--- a/frontend/dashboard.js
+++ b/frontend/dashboard.js
@@ -1466,6 +1466,9 @@
}
function closePlanToday(navigate = true) {
+ planTodayReadiness.cancel();
+ qs('#build-today-plan').disabled = false;
+ qs('#plan-today-build-status').textContent = '';
if (navigate) {
taskOverlayHistory.close();
return;
@@ -1514,28 +1517,30 @@
},
});
+ const planTodayReadiness = createPlanTodayReadiness({
+ concurrency:3,
+ identity:item => todayWork.identity(item),
+ inspect:async item => {
+ if (item.kind !== 'issue') return { status:'ready' };
+ const detail = await inspectTodayDependencies(item);
+ if (!detail.available) return { status:'unverified' };
+ if (detail.dependencies.length) return {
+ status:'blocked', reason:detail.dependencies.length + ' open ' +
+ (detail.dependencies.length === 1 ? 'dependency' : 'dependencies'),
+ };
+ return { status:'ready' };
+ },
+ });
+
async function buildTodayPlan() {
const button = qs('#build-today-plan');
const state = planToday.snapshot();
const candidates = state.ids.map(id => planToday.item(id)).concat(planToday.candidates());
button.disabled = true;
qs('#plan-today-build-status').textContent = 'Checking readiness and fitting your highest-ranked work…';
- const checks = await Promise.all(candidates.map(async item => {
- const id = todayWork.identity(item);
- if (item.kind !== 'issue') return [id, { status:'ready' }];
- try {
- const detail = await inspectTodayDependencies(item);
- if (!detail.available) return [id, { status:'unverified' }];
- if (detail.dependencies.length) return [id, {
- status:'blocked', reason:detail.dependencies.length + ' open ' +
- (detail.dependencies.length === 1 ? 'dependency' : 'dependencies'),
- }];
- return [id, { status:'ready' }];
- } catch (_error) {
- return [id, { status:'unverified' }];
- }
- }));
- planToday.buildRecommendation(Object.fromEntries(checks));
+ const checks = await planTodayReadiness.run(candidates);
+ if (!checks) return;
+ planToday.buildRecommendation(checks);
button.disabled = false;
renderPlanToday();
}
diff --git a/frontend/index.html b/frontend/index.html
index 41c73df..1401d4f 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -907,6 +907,7 @@
+
diff --git a/frontend/plan-today-readiness.js b/frontend/plan-today-readiness.js
new file mode 100644
index 0000000..e1af113
--- /dev/null
+++ b/frontend/plan-today-readiness.js
@@ -0,0 +1,41 @@
+function createPlanTodayReadiness({ identity, inspect, concurrency = 3 }) {
+ const workerCount = Math.max(1, Math.floor(Number(concurrency) || 1));
+ let generation = 0;
+
+ async function run(items) {
+ const runGeneration = ++generation;
+ const candidates = Array.from(items || []);
+ const results = new Array(candidates.length);
+ let next = 0;
+
+ async function worker() {
+ while (next < candidates.length) {
+ const index = next;
+ next += 1;
+ const item = candidates[index];
+ let result;
+ try {
+ result = await inspect(item);
+ } catch (_error) {
+ result = { status:'unverified' };
+ }
+ results[index] = [identity(item), result];
+ }
+ }
+
+ await Promise.all(Array.from(
+ { length:Math.min(workerCount, candidates.length) },
+ () => worker(),
+ ));
+ if (runGeneration !== generation) return null;
+ return Object.fromEntries(results);
+ }
+
+ function cancel() {
+ generation += 1;
+ }
+
+ return { run, cancel };
+}
+
+if (typeof module !== 'undefined' && module.exports) module.exports = createPlanTodayReadiness;
diff --git a/frontend/service-worker.js b/frontend/service-worker.js
index d876037..b914f05 100644
--- a/frontend/service-worker.js
+++ b/frontend/service-worker.js
@@ -1,6 +1,6 @@
const BASE = new URL('./', self.location.href).pathname;
importScripts(BASE + 'static/background-issue-sync.js');
-const CACHE = 'stackchain-dashboard-shell-v94';
+const CACHE = 'stackchain-dashboard-shell-v95';
const OFFLINE_LEASE_URL = new URL(BASE + '__offline-session-lease', self.location.origin).href;
const OUTAGE_STATUSES = new Set([500, 502, 503, 504]);
const NAVIGATION_TIMEOUT_MS = self.__STACKCHAIN_NAVIGATION_TIMEOUT_MS || 4000;
@@ -41,6 +41,7 @@ const SHELL = [
BASE + 'static/comment-next.js',
BASE + 'static/update-reply-read-next.js',
BASE + 'static/plan-today.js',
+ BASE + 'static/plan-today-readiness.js',
BASE + 'static/plan-today-preview.js',
BASE + 'static/today-sync.js',
BASE + 'static/today-rollover.js',
diff --git a/tests/test_comment_next.py b/tests/test_comment_next.py
index 1e62ce2..9cec075 100644
--- a/tests/test_comment_next.py
+++ b/tests/test_comment_next.py
@@ -303,4 +303,4 @@ async def test_unread_update_offers_reply_mark_read_and_next_independent_of_toda
assert '.update-reply-actions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr));' in html
assert '.update-reply-actions button { min-height:44px;' in html
worker = (Path(__file__).parents[1] / "frontend" / "service-worker.js").read_text()
- assert "stackchain-dashboard-shell-v94" in worker
+ assert "stackchain-dashboard-shell-v95" in worker
diff --git a/tests/test_frontend_bundle.py b/tests/test_frontend_bundle.py
index 565102f..ba09a0b 100644
--- a/tests/test_frontend_bundle.py
+++ b/tests/test_frontend_bundle.py
@@ -187,7 +187,7 @@ def test_legacy_cache_marker_is_normalized_out_of_build_identity(tmp_path):
worker = changed_frontend / "service-worker.js"
worker.write_text(
worker.read_text().replace(
- "const CACHE = 'stackchain-dashboard-shell-v94';",
+ "const CACHE = 'stackchain-dashboard-shell-v95';",
"const CACHE = 'stackchain-dashboard-shell-v999';",
)
)
diff --git a/tests/test_later_sync.py b/tests/test_later_sync.py
index 7a2c9c0..5137f83 100644
--- a/tests/test_later_sync.py
+++ b/tests/test_later_sync.py
@@ -347,5 +347,5 @@ async def test_dashboard_syncs_every_later_change_and_exposes_account_status():
def test_later_sync_ships_atomically_in_the_offline_shell():
source = (Path(__file__).parents[1] / "frontend" / "service-worker.js").read_text()
- assert "stackchain-dashboard-shell-v94" in source
+ assert "stackchain-dashboard-shell-v95" in source
assert "BASE + 'static/later-sync.js'" in source
diff --git a/tests/test_markdown_renderer.py b/tests/test_markdown_renderer.py
index fc7edca..58b2bd5 100644
--- a/tests/test_markdown_renderer.py
+++ b/tests/test_markdown_renderer.py
@@ -137,4 +137,4 @@ def test_markdown_work_bodies_are_mobile_safe_block_containers():
assert ".markdown-content { min-width:0; max-width:100%; overflow-wrap:anywhere;" in css
assert ".markdown-content pre { max-width:100%; overflow-x:auto;" in css
assert ".markdown-content a { min-height:44px;" in css
- assert "stackchain-dashboard-shell-v94" in worker
+ assert "stackchain-dashboard-shell-v95" in worker
diff --git a/tests/test_mobile_composer_integration.py b/tests/test_mobile_composer_integration.py
index 81df2c7..e814253 100644
--- a/tests/test_mobile_composer_integration.py
+++ b/tests/test_mobile_composer_integration.py
@@ -41,7 +41,7 @@ def test_offline_shell_contains_every_local_dashboard_runtime_asset():
shell_assets = set(re.findall(r"BASE \+ '([^']+)'", worker.split("async function sessionCsrf", 1)[0]))
assert local_assets <= shell_assets, f"Offline shell is missing: {sorted(local_assets - shell_assets)}"
- assert "stackchain-dashboard-shell-v94" in worker
+ assert "stackchain-dashboard-shell-v95" in worker
def test_all_conversation_composers_offer_accessible_mobile_mentions():
diff --git a/tests/test_mobile_device_setup.py b/tests/test_mobile_device_setup.py
index 1b9bc9b..97fd928 100644
--- a/tests/test_mobile_device_setup.py
+++ b/tests/test_mobile_device_setup.py
@@ -186,7 +186,7 @@ def test_mobile_dashboard_mounts_phone_safe_device_setup_flow():
assert "promptStorage:localStorage" in dashboard
assert "pushControllerReady.then(ensureDeviceSetup)" in dashboard
assert "BASE + 'static/mobile-device-setup.js'" in worker
- assert "stackchain-dashboard-shell-v94" in worker
+ assert "stackchain-dashboard-shell-v95" in worker
assert ".device-setup-panel" in css
assert ".device-readiness-card" in css
assert "overflow-x:hidden" in css
diff --git a/tests/test_plan_today.py b/tests/test_plan_today.py
index d07e4ef..602e32c 100644
--- a/tests/test_plan_today.py
+++ b/tests/test_plan_today.py
@@ -410,6 +410,7 @@ async def test_plan_today_wires_cancel_back_and_success_through_overlay_history(
def test_plan_today_controller_is_available_in_the_offline_shell():
source = SERVICE_WORKER.read_text()
- assert "stackchain-dashboard-shell-v94" in source
+ assert "stackchain-dashboard-shell-v95" in source
assert "BASE + 'static/plan-today.js'" in source
+ assert "BASE + 'static/plan-today-readiness.js'" in source
assert "BASE + 'static/plan-today-preview.js'" in source
diff --git a/tests/test_plan_today_readiness.py b/tests/test_plan_today_readiness.py
new file mode 100644
index 0000000..1e740e5
--- /dev/null
+++ b/tests/test_plan_today_readiness.py
@@ -0,0 +1,94 @@
+import json
+import subprocess
+from pathlib import Path
+
+import pytest
+
+from tests.dashboard_bundle import dashboard
+
+
+READINESS = Path(__file__).parents[1] / "frontend" / "plan-today-readiness.js"
+
+
+def run_node(script: str) -> dict:
+ result = subprocess.run(["node", "-e", script], check=True, capture_output=True, text=True)
+ return json.loads(result.stdout)
+
+
+def test_plan_readiness_bounds_concurrency_and_preserves_ranked_order():
+ script = f"""
+const createReadiness = require({json.dumps(str(READINESS))});
+let active = 0;
+let peak = 0;
+const completed = [];
+const delays = {{1:40, 2:5, 3:20, 4:1, 5:10, 6:2}};
+const readiness = createReadiness({{
+ concurrency:3,
+ identity:item => 'issue:' + item.number,
+ inspect:async item => {{
+ active += 1;
+ peak = Math.max(peak, active);
+ await new Promise(resolve => setTimeout(resolve, delays[item.number]));
+ completed.push(item.number);
+ active -= 1;
+ return item.number === 4 ? {{status:'blocked', reason:'Waiting'}} : {{status:'ready'}};
+ }},
+}});
+readiness.run([1,2,3,4,5,6].map(number => ({{kind:'issue', number}}))).then(result => {{
+ process.stdout.write(JSON.stringify({{peak, completed, entries:Object.entries(result)}}));
+}});
+"""
+ result = run_node(script)
+ assert result["peak"] == 3
+ assert result["completed"] != [1, 2, 3, 4, 5, 6]
+ assert result["entries"] == [
+ ["issue:1", {"status": "ready"}],
+ ["issue:2", {"status": "ready"}],
+ ["issue:3", {"status": "ready"}],
+ ["issue:4", {"status": "blocked", "reason": "Waiting"}],
+ ["issue:5", {"status": "ready"}],
+ ["issue:6", {"status": "ready"}],
+ ]
+
+
+def test_plan_readiness_supersedes_stale_builds_and_normalizes_real_failures():
+ script = f"""
+const createReadiness = require({json.dumps(str(READINESS))});
+let releaseFirst;
+const firstGate = new Promise(resolve => {{ releaseFirst = resolve; }});
+const readiness = createReadiness({{
+ concurrency:2,
+ identity:item => 'issue:' + item.number,
+ inspect:async item => {{
+ if (item.number === 1) await firstGate;
+ if (item.number === 3) throw new Error('upstream details');
+ return {{status:'ready'}};
+ }},
+}});
+const stale = readiness.run([{{number:1}}, {{number:2}}]);
+const current = readiness.run([{{number:3}}, {{number:4}}]);
+current.then(currentResult => {{
+ releaseFirst();
+ stale.then(staleResult => process.stdout.write(JSON.stringify({{staleResult, currentResult}})));
+}});
+"""
+ assert run_node(script) == {
+ "staleResult": None,
+ "currentResult": {
+ "issue:3": {"status": "unverified"},
+ "issue:4": {"status": "ready"},
+ },
+ }
+
+
+@pytest.mark.anyio
+async def test_dashboard_uses_bounded_supersedable_readiness_for_build_my_today():
+ html = await dashboard()
+
+ assert '' in html
+ assert "const planTodayReadiness = createPlanTodayReadiness({" in html
+ assert "concurrency:3" in html
+ assert "const checks = await planTodayReadiness.run(candidates);" in html
+ assert "if (!checks) return;" in html
+ assert "planTodayReadiness.cancel();" in html
+ assert "Promise.all(candidates.map" not in html
diff --git a/tests/test_service_worker.py b/tests/test_service_worker.py
index 332f25c..401f1ff 100644
--- a/tests/test_service_worker.py
+++ b/tests/test_service_worker.py
@@ -145,7 +145,7 @@ async function dispatchPush(payload) {{
def test_resumable_today_session_ships_in_a_new_offline_shell():
source = WORKER.read_text()
- assert "stackchain-dashboard-shell-v94" in source
+ assert "stackchain-dashboard-shell-v95" in source
assert "BASE + 'static/my-work.js'" in source
assert "BASE + 'static/dashboard.js'" in source
assert "BASE + 'static/dashboard.css'" in source
@@ -154,14 +154,14 @@ def test_resumable_today_session_ships_in_a_new_offline_shell():
def test_ownership_exit_runtime_rolls_the_offline_shell_cache():
source = WORKER.read_text()
- assert "stackchain-dashboard-shell-v94" in source
+ assert "stackchain-dashboard-shell-v95" in source
assert "BASE + 'static/dashboard.js'" in source
def test_offline_review_next_ships_today_completion_atomically():
source = WORKER.read_text()
- assert "stackchain-dashboard-shell-v94" in source
+ assert "stackchain-dashboard-shell-v95" in source
assert "BASE + 'static/today-completion.js'" in source
assert "BASE + 'static/dashboard.js'" in source
@@ -169,7 +169,7 @@ def test_offline_review_next_ships_today_completion_atomically():
def test_duplicate_aware_capture_ships_in_a_new_offline_shell():
source = WORKER.read_text()
- assert "stackchain-dashboard-shell-v94" in source
+ assert "stackchain-dashboard-shell-v95" in source
assert "BASE + 'static/create-issue-sheet.js'" in source
assert "BASE + 'static/dashboard.js'" in source
@@ -177,14 +177,14 @@ def test_duplicate_aware_capture_ships_in_a_new_offline_shell():
def test_exact_later_picker_ships_atomically_in_a_new_offline_shell():
source = WORKER.read_text()
- assert "stackchain-dashboard-shell-v94" in source
+ assert "stackchain-dashboard-shell-v95" in source
assert "BASE + 'static/later-picker.js'" in source
def test_navigation_deadline_ships_in_a_new_shell_cache():
source = WORKER.read_text()
- assert "stackchain-dashboard-shell-v94" in source
+ assert "stackchain-dashboard-shell-v95" in source
assert "BASE + 'static/dashboard.css'" in source
assert "BASE + 'static/dashboard.js'" in source
assert "BASE + 'static/install-app.js'" in source
@@ -193,21 +193,21 @@ def test_navigation_deadline_ships_in_a_new_shell_cache():
def test_today_convergence_ships_in_a_new_shell_cache():
source = WORKER.read_text()
- assert "stackchain-dashboard-shell-v94" in source
+ assert "stackchain-dashboard-shell-v95" in source
assert "BASE + 'static/today-sync.js'" in source
def test_mobile_search_viewport_ships_in_a_new_offline_shell():
source = WORKER.read_text()
- assert "stackchain-dashboard-shell-v94" in source
+ assert "stackchain-dashboard-shell-v95" in source
assert "BASE + 'static/mobile-search-viewport.js'" in source
def test_update_ownership_flow_ships_atomically_in_a_new_offline_shell():
source = WORKER.read_text()
- assert "stackchain-dashboard-shell-v94" in source
+ assert "stackchain-dashboard-shell-v95" in source
assert "BASE + 'static/update-ownership.js'" in source
@@ -654,7 +654,7 @@ def test_one_session_bound_csrf_proof_is_reused_for_a_background_drain():
def test_queue_today_ships_atomically_in_a_new_offline_shell():
source = WORKER.read_text()
- assert "stackchain-dashboard-shell-v94" in source
+ assert "stackchain-dashboard-shell-v95" in source
assert "BASE + 'static/queue-today.js'" in source
@@ -704,6 +704,7 @@ def test_install_precaches_complete_subpath_scoped_app_shell():
"/dashboard/static/comment-next.js",
"/dashboard/static/update-reply-read-next.js",
"/dashboard/static/plan-today.js",
+ "/dashboard/static/plan-today-readiness.js",
"/dashboard/static/plan-today-preview.js",
"/dashboard/static/today-sync.js",
"/dashboard/static/today-rollover.js",
diff --git a/tests/test_today_readiness.py b/tests/test_today_readiness.py
index 842b32a..a9e30c0 100644
--- a/tests/test_today_readiness.py
+++ b/tests/test_today_readiness.py
@@ -221,7 +221,7 @@ async def test_today_blocker_opens_existing_preview_and_preserves_readiness_gate
def test_readiness_runtime_is_available_in_offline_shell():
service_worker = SERVICE_WORKER.read_text()
- assert "const CACHE = 'stackchain-dashboard-shell-v94';" in service_worker
+ assert "const CACHE = 'stackchain-dashboard-shell-v95';" in service_worker
assert "BASE + 'static/today-readiness.js'" in service_worker
diff --git a/tests/test_today_sync.py b/tests/test_today_sync.py
index e9eb81c..6ae65e6 100644
--- a/tests/test_today_sync.py
+++ b/tests/test_today_sync.py
@@ -127,7 +127,7 @@ sync.enqueueConfiguration(120, {{'issue:r:1:':60}});
def test_inflight_today_drain_ships_in_a_new_offline_shell():
source = (Path(__file__).parents[1] / "frontend" / "service-worker.js").read_text()
- assert "stackchain-dashboard-shell-v94" in source
+ assert "stackchain-dashboard-shell-v95" in source
assert "BASE + 'static/today-sync.js'" in source