From ba322b1e5402f0532225f6ef974ed315f41d0aaf Mon Sep 17 00:00:00 2001 From: Nick Beckley Date: Fri, 20 Nov 2026 19:57:16 +0000 Subject: [PATCH] Remove redundant page-level narrative focus readouts --- PlotLine.Tests/Browser/focus-synchronisation.cjs | 11 ++++++++++- PlotLine/Views/Writer/Index.cshtml | 3 +-- PlotLine/Views/Writer/_WriterWrite.cshtml | 1 - PlotLine/wwwroot/js/narrative-focus-workspaces.js | 2 +- PlotLine/wwwroot/js/narrative-focus.js | 1 - 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/PlotLine.Tests/Browser/focus-synchronisation.cjs b/PlotLine.Tests/Browser/focus-synchronisation.cjs index 45256f0c..889b7861 100644 --- a/PlotLine.Tests/Browser/focus-synchronisation.cjs +++ b/PlotLine.Tests/Browser/focus-synchronisation.cjs @@ -26,7 +26,7 @@ const base=process.env.PD_NARRATIVE_TEST_URL||'http://127.0.0.1:5238'; await p.locator('[data-focus-toggle]').click();await p.locator('[data-focus-position]').selectOption('22/32');await p.waitForURL(/Chapters\/Details\/22/);await p.waitForFunction(()=>window.PlotDirectorNarrativeFocus?.state.sceneID===32);assert.equal(await p.locator('[data-focus-chapter]').getAttribute('data-chapter'),'22'); await command('previous');await p.waitForURL(/Chapters\/Details\/21/);await p.waitForFunction(()=>window.PlotDirectorNarrativeFocus?.state.sceneID===101);assert.equal(await p.locator('[data-pd-context=scene][aria-current=location]').getAttribute('data-pd-context-id'),'101'); const form=p.locator('[data-focus-chapter] form:has(input[name=overwriteAuthor])');await form.locator('input[type=checkbox]').check();await set({chapterID:22,sceneID:32});assert.equal(await p.locator('[data-focus-chapter]').getAttribute('data-chapter'),'21');await go();assert.match(await p.locator('[data-focus-workspace-status]').textContent(),/Save or cancel/);await form.evaluate(n=>n.reset());await go();await p.waitForURL(/Chapters\/Details\/22/);await p.waitForFunction(()=>window.PlotDirectorNarrativeFocus?.state.sceneID===32); - const version=(await state()).version;await go();assert.equal((await state()).version,version,'aligned Chapter Go retains scene and version'); + const version=(await state()).version;await go();assert.equal((await state()).version,version,'aligned Chapter Go retains scene and version');assert.equal(await p.locator('[data-focus-workspace-status]').count(),0,'aligned chapter has no status strip or empty wrapper'); await p.goto(base+'/Writer/Review?projectId=7&bookId=12');await positioned(32);let baseline=await position();assert(baseline.id,'initial Review load positions verified scene');await clear();await go();await positioned(32);assert.deepEqual(await position(),baseline,'initial load and Go use identical accepted target and offset'); for(const scene of [31,101,32]){const chapter=scene===32?22:21;await choose(chapter+'/'+scene);baseline=await position();assert.equal((await p.evaluate(()=>window.__focusEvents.length)),1,'one authoritative event per successful selection');assert.equal(baseline.id,await p.locator(`[data-paragraph-id][data-scene-id="${scene}"]`).first().getAttribute('data-paragraph-id'));await clear();await go();await positioned(scene);assert.deepEqual(await position(),baseline,'Go leaves identical scene position unchanged');} // Return to the same scene through canonical ribbon stepping and recent history. @@ -45,6 +45,15 @@ const base=process.env.PD_NARRATIVE_TEST_URL||'http://127.0.0.1:5238'; if(installed){const divider=await p.locator(active+' .pd-ribbon-focus').evaluate(n=>{const s=getComputedStyle(n);return {width:s.borderRightWidth,style:s.borderRightStyle,color:s.borderRightColor};});assert.equal(divider.width,'1px');assert.equal(divider.style,'solid');} await p.route('**/StoryPoint?*',r=>r.fulfill({status:503,body:'Synthetic unavailable snapshot'}));await p.route('**/StoryPoint/Index?*',r=>r.fulfill({status:503,body:'Synthetic unavailable snapshot'}));await go();assert.match(await p.locator('[data-focus-workspace-status]').textContent(),/could not be loaded/); await p.goto(base+'/fixture?desktop=Characters');await p.waitForFunction(()=>window.PlotDirectorNarrativeFocus);assert(await p.locator(active+' [data-global-focus=go]').isDisabled());assert.match(await p.locator(active+' [data-global-focus=go]').getAttribute('title'),/does not support/); + // Success locations belong in the header, not duplicate page-level status strips. + for(const path of ['/Chapters/Details/21','/Writer/Chapter/21','/fixture?record=Chapters','/Scenes/Edit/31','/Writer/Index?projectId=7&bookId=12','/Writer/Write?projectId=7&bookId=12&objective=true','/fixture?desktop=Books','/fixture?desktop=StoryPoint','/fixture?record=Characters','/fixture?page=maps']){ + await p.goto(base+path);await p.waitForFunction(()=>window.PlotDirectorNarrativeFocus); + assert.equal(await p.locator('[data-focus-workspace-status]').count(),0,path+' has no redundant strip'); + assert.doesNotMatch(await p.locator('main').first().innerText(),/Displaying current focus|Current narrative location:|Current Focus:/i,path); + assert.equal(await p.locator('[data-writer-global-location]').count(),0); + assert(await p.locator('[data-focus-label]').count());assert(await p.locator('[data-narrative-status][role=status]').count(),'header accessibility status retained'); + if(path==='/Chapters/Details/21')for(const width of [1666,950]){await p.setViewportSize({width,height:1050});await p.screenshot({path:`/tmp/pd-focus-text-${installed?'pwa':'browser'}-${width}.png`});} + } console.log(`PASS ${installed?'installed Chromium PWA':'Chromium'} focus synchronisation: stable-ID chapter follow/dirty guard/Go, identical initial/header/recent/ribbon/Go/refresh accepted positions, canonical boundaries, stale anchor/response rejection, missing-map fallback, repeatable sticky/narrow offsets, disabled explanations and Focus/Help divider.`); }finally{await c.close();await b?.close();fs.rmSync(profile,{recursive:true,force:true});} })().catch(e=>{console.error(e.stack);process.exitCode=1;}); diff --git a/PlotLine/Views/Writer/Index.cshtml b/PlotLine/Views/Writer/Index.cshtml index 63983728..966b1ed8 100644 --- a/PlotLine/Views/Writer/Index.cshtml +++ b/PlotLine/Views/Writer/Index.cshtml @@ -3,7 +3,6 @@ ViewData["Title"] = "Writer Home"; ViewData["ProjectSection"] = "Writer"; ViewData["ShellClass"] = "pd-writer writer3-shell"; - var focus = Model.NarrativeFocus?.Label; }
@@ -13,7 +12,7 @@

Continue Writing

Work on your chapters, scenes
and manuscript.

- @(focus != null ? $"Current Focus: {focus}" : "Choose your narrative location in Current Focus.") + @if(Model.NarrativeFocus?.ChapterID == null){Choose your narrative location in Current Focus.} Go to Write
diff --git a/PlotLine/Views/Writer/_WriterWrite.cshtml b/PlotLine/Views/Writer/_WriterWrite.cshtml index 8eff19cd..fa5cc2f0 100644 --- a/PlotLine/Views/Writer/_WriterWrite.cshtml +++ b/PlotLine/Views/Writer/_WriterWrite.cshtml @@ -3,7 +3,6 @@

Saved Writer objective

-

Current narrative location: @(Model.NarrativeFocus?.Label ?? "Choose in Current Focus")

Objective target: @(focus?.SceneTitle ?? focus?.ChapterTitle ?? "Across the book"). This target changes only when you edit the objective.

diff --git a/PlotLine/wwwroot/js/narrative-focus-workspaces.js b/PlotLine/wwwroot/js/narrative-focus-workspaces.js index ecda1f8e..4cde8acf 100644 --- a/PlotLine/wwwroot/js/narrative-focus-workspaces.js +++ b/PlotLine/wwwroot/js/narrative-focus-workspaces.js @@ -58,7 +58,7 @@ chapterPage.querySelectorAll('[aria-current=location]').forEach(n=>n.removeAttribute('aria-current')); const scene=focus.sceneID?chapterPage.querySelector(`[data-pd-context="scene"][data-pd-context-id="${focus.sceneID}"]`):null; if(focus.sceneID&&!scene){offer('The focused scene is not present in this chapter view.','Refresh chapter',()=>{const url=new URL(location.href);url.searchParams.set('retainNarrativeFocus','true');location.assign(url);});return;} - offer('Displaying Current Focus: '+focus.label); + document.querySelector('[data-focus-workspace-status]')?.remove(); const target=scene||chapterPage.querySelector('h1');if(scene)scene.setAttribute('aria-current','location');target?.scrollIntoView({block:'center',behavior:'instant'}); } registry.register({canGo:scope,unavailable:'Choose a chapter in this chapter page’s book',go:align}); diff --git a/PlotLine/wwwroot/js/narrative-focus.js b/PlotLine/wwwroot/js/narrative-focus.js index 35f4645c..28327a39 100644 --- a/PlotLine/wwwroot/js/narrative-focus.js +++ b/PlotLine/wwwroot/js/narrative-focus.js @@ -26,7 +26,6 @@ } function publish(){document.querySelector('[data-focus-workspace-status]')?.remove();render();try{if(state.bookID)localStorage.setItem(scopeKey,String(state.bookID));}catch{} for(const card of document.querySelectorAll('.timeline-scene-card[data-scene-id]')){const current=Number(card.dataset.sceneId)===state.sceneID;card.classList.toggle('pd-current-narrative-focus',current);if(current)card.setAttribute('aria-current','location');else if(card.getAttribute('aria-current')==='location')card.removeAttribute('aria-current');} - const locationLabel=document.querySelector('[data-writer-global-location]');if(locationLabel)locationLabel.textContent='Current narrative location: '+currentLabel(); for(const link of document.querySelectorAll('[data-focus-reference-link]')){const url=new URL(link.href);url.searchParams.delete('chapterId');url.searchParams.delete('sceneId');if(state.chapterID)url.searchParams.set('chapterId',state.chapterID);if(state.sceneID)url.searchParams.set('sceneId',state.sceneID);link.href=url;} window.dispatchEvent(new CustomEvent('plotdirector:narrative-focus-changed',{detail:state}));} async function refresh(){if(!state.bookID)return;if(busy){refreshQueued=true;return;}refreshQueued=false;const mine=++epoch;try{const response=await fetch(`/NarrativeFocus/Read?projectId=${state.projectID}&bookId=${state.bookID}`,{cache:'no-store'});if(!response.ok||response.redirected)throw Error();const fresh=await response.json();if(mine!==epoch||busy)return;if(fresh.version!==state.version){state=fresh;publish();}else{state=fresh;render();}}catch{if(mine===epoch&&!busy)status.textContent='Current focus could not be refreshed. Your edits are retained.';}}