fix: reset mobile work detail position (Closes #777)
All checks were successful
CI / lint (pull_request) Successful in 1m25s
CI / build-release (pull_request) Successful in 5s
CI / release-candidate (pull_request) Has been skipped

This commit is contained in:
timmy 2026-08-13 22:28:08 +00:00
parent 35f3999787
commit 83be8fcdbe
14 changed files with 90 additions and 19 deletions

View File

@ -929,6 +929,10 @@
panel: qs('#update-sheet .update-sheet-panel'), panel: qs('#update-sheet .update-sheet-panel'),
jump: qs('#jump-update-new-activity'), jump: qs('#jump-update-new-activity'),
}); });
const issueDetailPosition = createWorkDetailPosition({ panel: qs('#issue-sheet .issue-sheet-panel') });
const pullDetailPosition = createWorkDetailPosition({ panel: qs('#pull-sheet .pull-sheet-panel') });
const reviewDetailPosition = createWorkDetailPosition({ panel: qs('#review-sheet .review-sheet-panel') });
const workDetailIdentity = (kind, item) => kind + ':' + item.key;
qs('#jump-update-new-activity').addEventListener('click', () => updateReadPosition.jump()); qs('#jump-update-new-activity').addEventListener('click', () => updateReadPosition.jump());
qs('#focus-update-reply').addEventListener('click', () => { qs('#focus-update-reply').addEventListener('click', () => {
const composer = qs('#update-reply'); const composer = qs('#update-reply');
@ -3166,6 +3170,7 @@
async function openIssueSheet(item, trigger, offlineDetail = null) { async function openIssueSheet(item, trigger, offlineDetail = null) {
if (!item) return; if (!item) return;
issueDetailPosition.open(workDetailIdentity('issue', item));
qs('#issue-planning').inert = false; qs('#issue-planning').inert = false;
qs('#issue-handoff').inert = false; qs('#issue-handoff').inert = false;
selectedIssue = item; selectedIssue = item;
@ -3358,6 +3363,7 @@
async function openPullSheet(item, trigger, offlineDetail = null) { async function openPullSheet(item, trigger, offlineDetail = null) {
if (!item) return; if (!item) return;
if (!await ensurePullWorkflow(trigger)) return; if (!await ensurePullWorkflow(trigger)) return;
pullDetailPosition.open(workDetailIdentity('pull', item));
if (!createPullSheet.sameTarget(selectedPull, item)) pullAttachmentController.clear(); if (!createPullSheet.sameTarget(selectedPull, item)) pullAttachmentController.clear();
qs('#pull-review').inert = false; qs('#pull-review').inert = false;
qs('#pull-ownership').inert = false; qs('#pull-ownership').inert = false;
@ -3958,6 +3964,7 @@
async function openReviewSheet(item, trigger, cachedDetail = null) { async function openReviewSheet(item, trigger, cachedDetail = null) {
if (!item || !await ensurePullWorkflow(trigger)) return; if (!item || !await ensurePullWorkflow(trigger)) return;
reviewDetailPosition.open(workDetailIdentity('review', item));
selectedReview = item; selectedReview = item;
reviewTrigger = trigger; reviewTrigger = trigger;
offlineReview = Boolean(cachedDetail); offlineReview = Boolean(cachedDetail);

View File

@ -1091,6 +1091,7 @@
<script src="static/update-triage-session.js"></script> <script src="static/update-triage-session.js"></script>
<script src="static/update-review-handoff.js"></script> <script src="static/update-review-handoff.js"></script>
<script src="static/update-read-position.js"></script> <script src="static/update-read-position.js"></script>
<script src="static/work-detail-position.js"></script>
<script src="static/update-triage-launcher.js"></script> <script src="static/update-triage-launcher.js"></script>
<script src="static/update-triage-gesture.js"></script> <script src="static/update-triage-gesture.js"></script>
<script src="static/update-decision-transaction.js"></script> <script src="static/update-decision-transaction.js"></script>

View File

@ -1,6 +1,6 @@
const BASE = new URL('./', self.location.href).pathname; const BASE = new URL('./', self.location.href).pathname;
importScripts(BASE + 'static/background-issue-sync.js'); importScripts(BASE + 'static/background-issue-sync.js');
const CACHE = 'stackchain-dashboard-shell-v100'; const CACHE = 'stackchain-dashboard-shell-v101';
const OFFLINE_LEASE_URL = new URL(BASE + '__offline-session-lease', self.location.origin).href; const OFFLINE_LEASE_URL = new URL(BASE + '__offline-session-lease', self.location.origin).href;
const OUTAGE_STATUSES = new Set([500, 502, 503, 504]); const OUTAGE_STATUSES = new Set([500, 502, 503, 504]);
const NAVIGATION_TIMEOUT_MS = self.__STACKCHAIN_NAVIGATION_TIMEOUT_MS || 4000; const NAVIGATION_TIMEOUT_MS = self.__STACKCHAIN_NAVIGATION_TIMEOUT_MS || 4000;
@ -79,6 +79,7 @@ const SHELL = [
BASE + 'static/update-triage-session.js', BASE + 'static/update-triage-session.js',
BASE + 'static/update-review-handoff.js', BASE + 'static/update-review-handoff.js',
BASE + 'static/update-read-position.js', BASE + 'static/update-read-position.js',
BASE + 'static/work-detail-position.js',
BASE + 'static/update-triage-launcher.js', BASE + 'static/update-triage-launcher.js',
BASE + 'static/update-triage-gesture.js', BASE + 'static/update-triage-gesture.js',
BASE + 'static/update-decision-transaction.js', BASE + 'static/update-decision-transaction.js',

View File

@ -0,0 +1 @@
(function(r,f){if(typeof module==='object'&&module.exports)module.exports=f;else r.createWorkDetailPosition=f})(typeof self!=='undefined'?self:this,function(o){let i='';return{open(n){n=String(n||'');if(n&&n===i)return false;i=n;o.panel.scrollTop=0;return true}}});

View File

@ -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 { display:grid; grid-template-columns:repeat(2,minmax(0,1fr));' in html
assert '.update-reply-actions button { min-height:44px;' in html assert '.update-reply-actions button { min-height:44px;' in html
worker = (Path(__file__).parents[1] / "frontend" / "service-worker.js").read_text() worker = (Path(__file__).parents[1] / "frontend" / "service-worker.js").read_text()
assert "stackchain-dashboard-shell-v100" in worker assert "stackchain-dashboard-shell-v101" in worker

View File

@ -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(): def test_later_sync_ships_atomically_in_the_offline_shell():
source = (Path(__file__).parents[1] / "frontend" / "service-worker.js").read_text() source = (Path(__file__).parents[1] / "frontend" / "service-worker.js").read_text()
assert "stackchain-dashboard-shell-v100" in source assert "stackchain-dashboard-shell-v101" in source
assert "BASE + 'static/later-sync.js'" in source assert "BASE + 'static/later-sync.js'" in source

View File

@ -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 { 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 pre { max-width:100%; overflow-x:auto;" in css
assert ".markdown-content a { min-height:44px;" in css assert ".markdown-content a { min-height:44px;" in css
assert "stackchain-dashboard-shell-v100" in worker assert "stackchain-dashboard-shell-v101" in worker

View File

@ -45,7 +45,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])) 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 local_assets <= shell_assets, f"Offline shell is missing: {sorted(local_assets - shell_assets)}"
assert "stackchain-dashboard-shell-v100" in worker assert "stackchain-dashboard-shell-v101" in worker
def test_all_conversation_composers_offer_accessible_mobile_mentions(): def test_all_conversation_composers_offer_accessible_mobile_mentions():

View File

@ -214,7 +214,7 @@ def test_mobile_dashboard_mounts_phone_safe_device_setup_flow():
assert "promptStorage:localStorage" in dashboard assert "promptStorage:localStorage" in dashboard
assert "pushControllerReady.then(ensureDeviceSetup)" in dashboard assert "pushControllerReady.then(ensureDeviceSetup)" in dashboard
assert "BASE + 'static/mobile-device-setup.js'" in worker assert "BASE + 'static/mobile-device-setup.js'" in worker
assert "stackchain-dashboard-shell-v100" in worker assert "stackchain-dashboard-shell-v101" in worker
assert ".device-setup-panel" in css assert ".device-setup-panel" in css
assert ".device-readiness-card" in css assert ".device-readiness-card" in css
assert "overflow-x:hidden" in css assert "overflow-x:hidden" in css

View File

@ -410,7 +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(): def test_plan_today_controller_is_available_in_the_offline_shell():
source = SERVICE_WORKER.read_text() source = SERVICE_WORKER.read_text()
assert "stackchain-dashboard-shell-v100" in source assert "stackchain-dashboard-shell-v101" in source
assert "BASE + 'static/plan-today.js'" in source assert "BASE + 'static/plan-today.js'" in source
assert "BASE + 'static/plan-today-readiness.js'" in source assert "BASE + 'static/plan-today-readiness.js'" in source
assert "BASE + 'static/plan-today-preview.js'" in source assert "BASE + 'static/plan-today-preview.js'" in source

View File

@ -150,7 +150,7 @@ async function dispatchPush(payload) {{
def test_resumable_today_session_ships_in_a_new_offline_shell(): def test_resumable_today_session_ships_in_a_new_offline_shell():
source = WORKER.read_text() source = WORKER.read_text()
assert "stackchain-dashboard-shell-v100" in source assert "stackchain-dashboard-shell-v101" in source
assert "BASE + 'static/my-work.js'" in source assert "BASE + 'static/my-work.js'" in source
assert "BASE + 'static/dashboard.js'" in source assert "BASE + 'static/dashboard.js'" in source
assert "BASE + 'static/dashboard.css'" in source assert "BASE + 'static/dashboard.css'" in source
@ -159,14 +159,14 @@ def test_resumable_today_session_ships_in_a_new_offline_shell():
def test_ownership_exit_runtime_rolls_the_offline_shell_cache(): def test_ownership_exit_runtime_rolls_the_offline_shell_cache():
source = WORKER.read_text() source = WORKER.read_text()
assert "stackchain-dashboard-shell-v100" in source assert "stackchain-dashboard-shell-v101" in source
assert "BASE + 'static/dashboard.js'" in source assert "BASE + 'static/dashboard.js'" in source
def test_offline_review_next_ships_today_completion_atomically(): def test_offline_review_next_ships_today_completion_atomically():
source = WORKER.read_text() source = WORKER.read_text()
assert "stackchain-dashboard-shell-v100" in source assert "stackchain-dashboard-shell-v101" in source
assert "BASE + 'static/today-completion.js'" in source assert "BASE + 'static/today-completion.js'" in source
assert "BASE + 'static/dashboard.js'" in source assert "BASE + 'static/dashboard.js'" in source
@ -174,7 +174,7 @@ def test_offline_review_next_ships_today_completion_atomically():
def test_duplicate_aware_capture_ships_in_a_new_offline_shell(): def test_duplicate_aware_capture_ships_in_a_new_offline_shell():
source = WORKER.read_text() source = WORKER.read_text()
assert "stackchain-dashboard-shell-v100" in source assert "stackchain-dashboard-shell-v101" in source
assert "BASE + 'static/create-issue-sheet.js'" in source assert "BASE + 'static/create-issue-sheet.js'" in source
assert "BASE + 'static/dashboard.js'" in source assert "BASE + 'static/dashboard.js'" in source
@ -182,14 +182,14 @@ def test_duplicate_aware_capture_ships_in_a_new_offline_shell():
def test_exact_later_picker_ships_atomically_in_a_new_offline_shell(): def test_exact_later_picker_ships_atomically_in_a_new_offline_shell():
source = WORKER.read_text() source = WORKER.read_text()
assert "stackchain-dashboard-shell-v100" in source assert "stackchain-dashboard-shell-v101" in source
assert "BASE + 'static/later-picker.js'" in source assert "BASE + 'static/later-picker.js'" in source
def test_navigation_deadline_ships_in_a_new_shell_cache(): def test_navigation_deadline_ships_in_a_new_shell_cache():
source = WORKER.read_text() source = WORKER.read_text()
assert "stackchain-dashboard-shell-v100" in source assert "stackchain-dashboard-shell-v101" in source
assert "BASE + 'static/dashboard.css'" in source assert "BASE + 'static/dashboard.css'" in source
assert "BASE + 'static/dashboard.js'" in source assert "BASE + 'static/dashboard.js'" in source
assert "BASE + 'static/install-app.js'" in source assert "BASE + 'static/install-app.js'" in source
@ -198,21 +198,21 @@ def test_navigation_deadline_ships_in_a_new_shell_cache():
def test_today_convergence_ships_in_a_new_shell_cache(): def test_today_convergence_ships_in_a_new_shell_cache():
source = WORKER.read_text() source = WORKER.read_text()
assert "stackchain-dashboard-shell-v100" in source assert "stackchain-dashboard-shell-v101" in source
assert "BASE + 'static/today-sync.js'" in source assert "BASE + 'static/today-sync.js'" in source
def test_mobile_search_viewport_ships_in_a_new_offline_shell(): def test_mobile_search_viewport_ships_in_a_new_offline_shell():
source = WORKER.read_text() source = WORKER.read_text()
assert "stackchain-dashboard-shell-v100" in source assert "stackchain-dashboard-shell-v101" in source
assert "BASE + 'static/mobile-search-viewport.js'" in source assert "BASE + 'static/mobile-search-viewport.js'" in source
def test_update_ownership_flow_ships_atomically_in_a_new_offline_shell(): def test_update_ownership_flow_ships_atomically_in_a_new_offline_shell():
source = WORKER.read_text() source = WORKER.read_text()
assert "stackchain-dashboard-shell-v100" in source assert "stackchain-dashboard-shell-v101" in source
assert "BASE + 'static/update-ownership.js'" in source assert "BASE + 'static/update-ownership.js'" in source
@ -761,7 +761,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(): def test_queue_today_ships_atomically_in_a_new_offline_shell():
source = WORKER.read_text() source = WORKER.read_text()
assert "stackchain-dashboard-shell-v100" in source assert "stackchain-dashboard-shell-v101" in source
assert "BASE + 'static/queue-today.js'" in source assert "BASE + 'static/queue-today.js'" in source
@ -849,6 +849,7 @@ def test_install_precaches_complete_subpath_scoped_app_shell():
"/dashboard/static/update-triage-session.js", "/dashboard/static/update-triage-session.js",
"/dashboard/static/update-review-handoff.js", "/dashboard/static/update-review-handoff.js",
"/dashboard/static/update-read-position.js", "/dashboard/static/update-read-position.js",
"/dashboard/static/work-detail-position.js",
"/dashboard/static/update-triage-launcher.js", "/dashboard/static/update-triage-launcher.js",
"/dashboard/static/update-triage-gesture.js", "/dashboard/static/update-triage-gesture.js",
"/dashboard/static/update-decision-transaction.js", "/dashboard/static/update-decision-transaction.js",

View File

@ -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(): def test_readiness_runtime_is_available_in_offline_shell():
service_worker = SERVICE_WORKER.read_text() service_worker = SERVICE_WORKER.read_text()
assert "const CACHE = 'stackchain-dashboard-shell-v100';" in service_worker assert "const CACHE = 'stackchain-dashboard-shell-v101';" in service_worker
assert "BASE + 'static/today-readiness.js'" in service_worker assert "BASE + 'static/today-readiness.js'" in service_worker

View File

@ -127,7 +127,7 @@ sync.enqueueConfiguration(120, {{'issue:r:1:':60}});
def test_inflight_today_drain_ships_in_a_new_offline_shell(): def test_inflight_today_drain_ships_in_a_new_offline_shell():
source = (Path(__file__).parents[1] / "frontend" / "service-worker.js").read_text() source = (Path(__file__).parents[1] / "frontend" / "service-worker.js").read_text()
assert "stackchain-dashboard-shell-v100" in source assert "stackchain-dashboard-shell-v101" in source
assert "BASE + 'static/today-sync.js'" in source assert "BASE + 'static/today-sync.js'" in source

View File

@ -0,0 +1,60 @@
import json
import subprocess
from pathlib import Path
import pytest
from tests.dashboard_bundle import dashboard
POSITIONER = Path(__file__).resolve().parents[1] / "frontend" / "work-detail-position.js"
def run_positioner(script: str) -> dict:
source = f"const createPositioner = require({json.dumps(str(POSITIONER))});\n" + script
result = subprocess.run(["node", "-e", source], capture_output=True, text=True)
assert result.returncode == 0, result.stderr
return json.loads(result.stdout)
def test_different_work_item_resets_to_top_while_same_item_keeps_position():
result = run_positioner("""
const panel = {scrollTop:640};
const positioner = createPositioner({panel});
const first = positioner.open('issue:stackchain/dashboard#41');
panel.scrollTop = 380;
const same = positioner.open('issue:stackchain/dashboard#41');
const changed = positioner.open('pull:stackchain/dashboard#42');
process.stdout.write(JSON.stringify({first, same, changed, top:panel.scrollTop}));
""")
assert result == {"first": True, "same": False, "changed": True, "top": 0}
def test_each_panel_tracks_its_own_visible_identity():
result = run_positioner("""
const issuePanel = {scrollTop:500};
const pullPanel = {scrollTop:700};
const issue = createPositioner({panel:issuePanel});
const pull = createPositioner({panel:pullPanel});
issue.open('issue:stackchain/dashboard#8');
pull.open('pull:stackchain/dashboard#9');
issuePanel.scrollTop = 220;
pullPanel.scrollTop = 330;
issue.open('issue:stackchain/dashboard#8');
pull.open('review:stackchain/dashboard#9');
process.stdout.write(JSON.stringify({issueTop:issuePanel.scrollTop, pullTop:pullPanel.scrollTop}));
""")
assert result == {"issueTop": 220, "pullTop": 0}
@pytest.mark.anyio
async def test_dashboard_positions_issue_pull_and_review_openers():
html = await dashboard()
assert '<script src="static/work-detail-position.js"></script>' in html
assert "issueDetailPosition.open(workDetailIdentity('issue', item))" in html
assert "pullDetailPosition.open(workDetailIdentity('pull', item))" in html
assert "reviewDetailPosition.open(workDetailIdentity('review', item))" in html
assert "BASE + 'static/work-detail-position.js'" in (POSITIONER.parent / "service-worker.js").read_text()