Refine inline focus layout and retain independently collapsible Review context

This commit is contained in:
Nick Beckley 2026-11-18 12:29:29 +00:00
parent 98bce93ffc
commit 64bd3c9acf
9 changed files with 16 additions and 12 deletions

View File

@ -12,7 +12,7 @@ await p.goto(route('Explore'));await p.locator('[data-discovery-tiles] [data-til
await p.goto(route('Review')+'&chapterId='+w.chapter);await p.locator('[data-review-intentions-slot] [data-review-intentions]').waitFor();assert(await p.locator('.reader-page').isVisible());const paragraph=p.locator('[data-paragraph-id][data-scene-id]').filter({hasText:'recorded first paragraph'}).first();await paragraph.click();await p.locator('[data-review-record]').click();await p.locator('[data-review-cancel]').click();await p.locator('[data-review-intentions-slot]').getByText('Disposable review scene',{exact:true}).waitFor();await shot('Review-context');await p.locator('#reader-focus').click();await p.locator('.reader-controls a[rel=next]').click();assert.equal(await p.locator('.manuscript-reader').getAttribute('data-focus'),'true');await p.locator('#reader-focus').click();await p.goto(route('Review')+'&reading=true&chapterId='+w.chapter);assert.equal(await p.locator('.manuscript-reader').getAttribute('data-reading'),'true');await shot('Reading-mode');
// An explicit session is a separate action, never a side effect of choosing focus.
await p.goto(route('Write'));const token=await p.locator('input[name=__RequestVerificationToken]').first().inputValue();const session=require('crypto').randomUUID();assert.equal((await p.request.post(base+'/Writer/Work/Start',{form:{bookId:w.book,kind:'Planning',requestId:session,__RequestVerificationToken:token}})).status(),200);assert.equal((await p.request.post(base+'/Writer/Work/End',{form:{bookId:w.book,sessionId:session,note:'Considered the next writing step',__RequestVerificationToken:token}})).status(),200);
await p.goto(`${base}/Writer/ScheduleSetup?projectId=${w.project}&bookId=${w.book}`);await p.locator('[name=PlanName]').fill('Disposable Phase 2 writing plan');const today=new Date(),end=new Date(Date.now()+28*86400000);await p.locator('[name=StartDate]').fill(today.toISOString().slice(0,10));await p.locator('[name=DeadlineDate]').fill(end.toISOString().slice(0,10));for(const box of await p.locator('input[type=checkbox][name$=".IsAvailable"]').all())await box.check();await p.getByRole('button',{name:'Review activities',exact:true}).click();await p.waitForURL(/PlanActivities|SchedulePreview/);if(p.url().includes('PlanActivities')){await p.locator('[name=Confirm]').check();await p.getByRole('button',{name:'Commit reviewed schedule'}).click();await p.waitForURL(/SchedulePreview/);}const planId=new URL(p.url()).searchParams.get('writingPlanId');assert(planId);await p.goto(route('Plan'));assert((await p.locator('.writer3-main').textContent()).includes('Scheduled writing activities'));await p.goto(`${base}/Writer/EditWritingPlan?writingPlanId=${planId}`);assert(await p.locator('[name=PlanName]').isVisible());await p.goto(route('Reflect'));await p.locator('.writer-month-grid').waitFor();const month=await p.locator('.writer-section-heading h2').first().textContent();await p.getByRole('link',{name:'Previous month',exact:true}).click();assert(p.url().includes('/Writer/Reflect'));assert.notEqual(await p.locator('.writer-section-heading h2').first().textContent(),month);await p.locator('.writer-month-grid a').first().click();assert(p.url().includes('day='));await shot('Reflect-day');
if(w.planId){await p.goto(`${base}/Writer/PlanActivities?writingPlanId=${w.planId}`);}else{await p.goto(`${base}/Writer/ScheduleSetup?projectId=${w.project}&bookId=${w.book}`);await p.locator('[name=PlanName]').fill('Disposable Phase 2 writing plan');const today=new Date(),end=new Date(Date.now()+28*86400000);await p.locator('[name=StartDate]').fill(today.toISOString().slice(0,10));await p.locator('[name=DeadlineDate]').fill(end.toISOString().slice(0,10));for(const box of await p.locator('input[type=checkbox][name$=".IsAvailable"]').all())await box.check();await p.getByRole('button',{name:'Review activities',exact:true}).click();await p.waitForURL(/PlanActivities|SchedulePreview/);}if(p.url().includes('PlanActivities')){await p.locator('input[type=checkbox][name=Confirm]').check();await p.getByRole('button',{name:'Commit reviewed schedule'}).click();await p.waitForURL(/SchedulePreview/);}const planId=new URL(p.url()).searchParams.get('writingPlanId');assert(planId);await p.goto(route('Plan'));assert((await p.locator('.writer3-main').textContent()).includes('Scheduled writing activities'));await p.goto(`${base}/Writer/EditWritingPlan?writingPlanId=${planId}`);assert(await p.locator('[name=PlanName]').isVisible());await p.goto(route('Reflect'));await p.locator('.writer-month-grid').waitFor();const month=await p.locator('.writer-section-heading h2').first().textContent();await p.getByRole('link',{name:'Previous month',exact:true}).click();assert(p.url().includes('/Writer/Reflect'));assert.notEqual(await p.locator('.writer-section-heading h2').first().textContent(),month);await p.locator('.writer-month-grid a').first().click();assert(p.url().includes('day='));await shot('Reflect-day');
for(const d of ['Write','Explore','Plan','Review','Reflect']){await p.goto(route(d));await p.waitForTimeout(150);await shot('Working-'+d);}
for(const width of [1920,1366,800])for(const d of ['Write','Explore','Plan','Review','Reflect']){await p.setViewportSize({width,height:1000});await p.goto(route(d));await p.evaluate(()=>PlotLineHelpDrawer.open('writer3.layout'));await p.locator('.help-drawer-article').waitFor();assert(await p.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+2),d+' '+width);await shot(d+'-'+width+'-panels');const collapse=p.locator('[data-ribbon-collapse]');await collapse.click();assert(await p.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+2));if(await p.locator('[data-guidance-collapse]').isVisible())await p.locator('[data-guidance-collapse]').click();await p.locator('[data-help-collapse]').count().then(async n=>{if(n)await p.locator('[data-help-collapse]').click();});await shot(d+'-'+width+'-collapsed');}
assert.deepEqual(errors,[]);console.log('PASS Phase 2 authenticated four fixtures, AJAX focus and no sessions, discovery preferences, canonical questionnaire, saved guidance, Review/Reading/Focus scene context, Reflect month/day, three widths and panel/ribbon states');await context.close();}finally{await browser.close();}})().catch(e=>{console.error(e.stack);process.exitCode=1});

View File

@ -40,3 +40,7 @@ Return to Word reuses the verified, acknowledged Companion handoff. Open paragra
Expand Reading & Audio Review to use the existing recording and supported native playback controls. Record observations while preserving the actual session target, playback and return note. Audio time is not a paragraph anchor. Native pause-on-edit and media safeguards are unchanged.
Your observations are distinct from recorded intentions and saved automated findings. Saved assessments & other tools opens existing Intent evidence, Context and the book's analysis/review tools. Opening Review starts no analysis. Assessments remain explicit actions with their original provenance and freshness.
# Chapter intentions beside your reading
Chapter intentions and reliable scene context can be collapsed independently of observations. At wide working widths they sit beside the canonical manuscript; at smaller widths they come before it. Scene context uses accepted paragraph assignments and falls back to the chapter where those assignments are uncertain.

View File

@ -1,6 +1,6 @@
@model WriterDashboardViewModel
@{var objective=Model.Objective;}
<form asp-action="SaveObjective" asp-controller="Writer" method="post" class="writer-objective-form" data-focus-form data-focus-wizard>
<form asp-action="SaveObjective" asp-controller="Writer" method="post" class="writer-focus-wizard" data-focus-form data-focus-wizard>
<input type="hidden" name="BookID" value="@Model.BookID" />
<p data-focus-step-label role="status">Step 1 of 3</p>
<fieldset data-focus-step="0"><legend>What are you doing?</legend>

View File

@ -2,10 +2,10 @@
<div class="writer3-workspace writer2-single" aria-label="Writing priorities">
<section class="writer3-panel writer3-main" data-writer-focus data-book-id="@Model.BookID" data-focus-url="@Url.Action("Focus","Writer",new{bookId=Model.BookID})">
<h2>Next activities</h2><p>Choose what deserves your attention next. Dates and schedules are optional.</p>
<section class="writer3-inset"><h3>Your next intended work</h3>
<section class="writer3-inset"><h3>Your next intended work</h3><div data-focus-summary>
@if(Model.Objective is {} focus){<p><strong>@focus.Activity · @(focus.SceneTitle??focus.ChapterTitle??"Across the book")</strong></p>@if(!string.IsNullOrWhiteSpace(focus.Intention)){<p class="review-recorded">@focus.Intention</p>}<a class="btn btn-primary" asp-action="Write" asp-route-bookId="@Model.BookID">Continue this work</a>}
else{<p>Start with one piece of work you would like to continue. It does not need a deadline.</p>}
<a class="btn btn-outline-secondary" asp-action="Write" asp-route-bookId="@Model.BookID" asp-route-setup="true" data-change-focus>@(Model.Objective==null?"Choose next work":"Change next work")</a>
</div><a class="btn btn-outline-secondary" asp-action="Write" asp-route-bookId="@Model.BookID" asp-route-setup="true" data-change-focus>@(Model.Objective==null?"Choose next work":"Change next work")</a>
<div id="objective-setup" hidden></div><p class="writer3-caption">This is your saved writing focus, not a completed task or a recorded session.</p></section>
@if(Model.PlannedActivities.Count>0){<h3>Scheduled writing activities</h3><ol class="writer2-activities">@foreach(var item in Model.PlannedActivities.Take(12)){<li><time>@item.ScheduledDate.ToString("ddd d MMM")</time><strong>@item.Kind · @item.Title</strong><span>@item.Status · @item.Minutes planned minutes</span>@if(item.SceneID.HasValue){<a asp-controller="Scenes" asp-action="Edit" asp-route-id="@item.SceneID">Work on this scene</a>}else{<a asp-action="Chapter" asp-route-id="@item.ChapterID">Work on this chapter</a>}</li>}</ol>}
else{<h3>Writing time ahead</h3><partial name="_WriterUpcoming" model="Model" />}

View File

@ -2,7 +2,7 @@
@{var reader=Model.ReviewReader;var word=new WriterDashboardViewModel{BookID=Model.BookID,ProjectID=Model.ProjectID,WordNavigationContext="review",Objective=reader?.Chapter==null?null:new(){ChapterID=reader.Chapter.ChapterID,ChapterTitle=reader.Chapter.ChapterTitle,Activity="Revising"}};}
<div class="writer3-workspace" aria-label="Manuscript review">
<section class="writer3-panel writer3-main" tabindex="0" aria-label="Accepted manuscript">
<details class="writer2-chapter-context" open><summary>Chapter intentions and verified scene context</summary><div data-review-intentions-slot><p>Loading recorded intentions…</p></div></details>
@if(reader?.Chapter!=null){<details class="writer2-chapter-context" open><summary>Chapter intentions and verified scene context</summary><div data-review-intentions-slot><p>Loading recorded intentions…</p></div></details>}
@if(reader!=null){<partial name="~/Views/ManuscriptReader/_Reader.cshtml" model="reader" />}
else{<h2>Read the accepted manuscript</h2><p>Select a book with chapters to review your accepted writing.</p><a asp-controller="Books" asp-action="Details" asp-route-id="@Model.BookID">Open your book</a>}
</section>

View File

@ -17,7 +17,7 @@
}
</div>
<button type="button" class="btn btn-link" data-change-focus>Change focus</button>
<button type="button" class="btn btn-link" hidden="@(focus==null||editing)" data-change-focus>Change focus</button>
<div id="objective-setup" hidden="@(focus!=null&&!editing)">@if(focus==null||editing){<partial name="_WriterFocusForm" model="Model" />}</div>
@if(!Model.ActivityIsPrivate){
@if(focus != null && !editing){<div class="button-row writer3-focus-actions"><button type="button" class="btn btn-outline-primary" data-record-focus disabled>Record this session</button><button type="button" class="btn btn-outline-secondary" data-plan-focus>Plan writing time</button></div>}

View File

@ -108,13 +108,13 @@
/* Phase 2 working surfaces use the accepted shared shell and theme. */
.writer2-single{display:block}.writer2-single>.writer3-main{width:100%;max-width:none}
.writer2-explore{grid-template-columns:repeat(2,minmax(0,1fr));align-items:start}
.writer2-explore{grid-template-columns:repeat(auto-fit,minmax(min(100%,360px),1fr));align-items:start}
.writer2-explore>.writer3-panel{min-width:0;max-height:none;overflow:visible}
.writer2-tile{border-block-start:1px solid var(--pd-border);padding:1rem 0}.writer2-tile h3{font-size:1.2rem}.writer2-tile .button-row{margin-top:.6rem}.writer2-tile button:not(.btn){border:0;background:none;color:var(--pd-accent);text-decoration:underline;padding:.3rem}
[data-focus-wizard] fieldset{min-width:0;border:0;padding:.5rem 0}[data-focus-wizard] legend{font-size:1.15rem}[data-focus-wizard] label{display:block;margin:.6rem 0}[data-focus-wizard] textarea{width:100%}
.writer2-activities{padding-left:1.4rem}.writer2-activities li{padding:1rem;border-bottom:1px solid var(--pd-border)}.writer2-activities li>*{display:block}
.writer2-chapter-context{margin-bottom:1rem}.writer2-chapter-context>summary{cursor:pointer;color:var(--pd-accent)}
.writer3-destination:has(.manuscript-reader[data-reading=true]) .writer2-chapter-context{display:none}
@container (min-width:1200px){.writer3-main:has(.writer2-chapter-context){display:grid;grid-template-columns:minmax(180px, .28fr) minmax(0,1fr);gap:1rem;align-items:start}.writer2-chapter-context{position:sticky;top:var(--writer-sticky-top,8px);min-width:0}.writer3-main:has(.writer2-chapter-context)>.manuscript-reader{min-width:0}.writer3-main:has(.manuscript-reader[data-reading=true]){display:block}}
@container (min-width:1200px){.writer3-main:has(.writer2-chapter-context[open]){display:grid;grid-template-columns:minmax(180px, .28fr) minmax(0,1fr);gap:1rem;align-items:start}.writer2-chapter-context{position:sticky;top:var(--writer-sticky-top,8px);min-width:0}.writer3-main:has(.writer2-chapter-context)>.manuscript-reader{min-width:0}.writer3-main:has(.manuscript-reader[data-reading=true]){display:block}}
.writer3-destination .writer3-workspace{container-type:inline-size}
@media(max-width:1050px){.writer2-explore{grid-template-columns:minmax(0,1fr)}}

View File

@ -37,7 +37,7 @@
function replaceCard(card,doc){const fresh=doc.querySelector(`[data-key="${CSS.escape(card.dataset.key)}"]`);if(!fresh)throw Error('Saved record is not available');const clone=fresh.cloneNode(true),parent=card.parentElement;card.replaceWith(clone);bind(parent);clone.querySelector('[data-authoring-status]').textContent='Saved.';clone.querySelector('[data-authoring-edit]')?.focus();}
async function read(){const response=await fetch(root.dataset.inspectUrl,{cache:'no-store'});if(!response.ok)throw Error('Recorded information is unavailable');const doc=new DOMParser().parseFromString(await response.text(),'text/html');if(!doc.querySelector('[data-authoring-content]'))throw Error('Authorisation or recorded information is unavailable');return doc;}
let loadEpoch=0;
async function load(){const mine=++loadEpoch;if(!root.dataset.inspectUrl){root.replaceChildren();return;}try{const doc=await read();if(mine!==loadEpoch)return;root.replaceChildren(...doc.body.childNodes);bind(root);const references=document.querySelector('[data-authoring-references]'),template=root.querySelector('[data-authoring-companion]');if(references&&template)references.replaceChildren(template.content.cloneNode(true));}
async function load(){const mine=++loadEpoch;if(!root.dataset.inspectUrl){root.hidden=true;root.replaceChildren();return;}root.hidden=false;try{const doc=await read();if(mine!==loadEpoch)return;root.replaceChildren(...doc.body.childNodes);bind(root);const references=document.querySelector('[data-authoring-references]'),template=root.querySelector('[data-authoring-companion]');if(references&&template)references.replaceChildren(template.content.cloneNode(true));}
catch{root.replaceChildren();const p=document.createElement('p');p.textContent='Recorded information could not load. Your current work and existing editors remain available.';const retry=document.createElement('button');retry.type='button';retry.className='btn btn-outline-secondary';retry.textContent='Try again';retry.addEventListener('click',load);root.append(p,retry);}}
window.addEventListener('beforeunload',e=>{if(dirty()&&!allowLeave){e.preventDefault();e.returnValue='';}});
function guard(e){if(!dirty())return;const target=e.target.closest('a,form,[data-plan-focus]');if(!target||target.matches('[data-authoring-form],[data-work-start]')||target.target==='_blank'||target.hasAttribute('download'))return;if(target.tagName==='A'&&new URL(target.href,location.href).pathname===location.pathname&&new URL(target.href,location.href).search===location.search&&target.hash)return;if(!confirm(root.querySelector('[data-busy="true"]')?'A save is in progress and may finish after you leave. Leave this page?':'Leave without saving your inline edits?')){e.preventDefault();e.stopImmediatePropagation();}else allowLeave=true;}

View File

@ -7,12 +7,12 @@
function render(){form.querySelectorAll('[data-focus-step]').forEach((x,i)=>x.hidden=i!==step);form.querySelector('[data-focus-back]').hidden=step===0;form.querySelector('[data-focus-next]').hidden=step===2;form.querySelector('[data-save-focus]').hidden=step!==2;form.querySelector('[data-focus-step-label]').textContent=`Step ${step+1} of 3`;form.querySelector('[data-focus-confirmation]').textContent=`Save ${form.elements.Activity.value.toLowerCase()} · ${scene.value?scene.selectedOptions[0].textContent:chapter.selectedOptions[0].textContent}. No session will be recorded.`;}
chapter.addEventListener('change',filter);filter();render();
for(const [selector,direction] of [['[data-focus-next]',1],['[data-focus-back]',-1]])form.querySelector(selector).addEventListener('click',()=>{step+=direction;render();form.querySelector('[data-focus-step]:not([hidden]) select, [data-focus-step]:not([hidden]) textarea')?.focus();});
form.querySelector('[data-focus-cancel]').addEventListener('click',()=>{host.hidden=true;root.querySelector('[data-change-focus]')?.focus();});
form.querySelector('[data-focus-cancel]').addEventListener('click',()=>{host.hidden=true;const change=root.querySelector('[data-change-focus]');if(change)change.hidden=false;root.querySelector('[data-change-focus]')?.focus();});
form.addEventListener('submit',async e=>{e.preventDefault();if(e.defaultPrevented&&e.cancelBubble)return;if(busy)return;if(step!==2){step++;render();return;}busy=true;const button=form.querySelector('[data-save-focus]');button.disabled=true;form.querySelector('[data-focus-error]').textContent='';try{const response=await fetch(form.action,{method:'POST',body:new FormData(form),headers:{'X-Requested-With':'XMLHttpRequest'}});if(!response.ok)throw Error();const data=await response.json();if(!data.saved)throw Error();
root.dataset.savedActivity=data.activity;root.dataset.savedChapter=data.chapterID||'';root.dataset.savedSessionKind=data.sessionKind||'';
let summary=root.querySelector('[data-focus-summary]');if(!summary){summary=document.createElement('div');host.before(summary);}summary.replaceChildren();const h=document.createElement('h2');h.textContent=data.activity+' · '+data.title;const p=document.createElement('p');p.textContent=data.intention||'Your focus is saved. No recording has started.';const a=document.createElement('a');a.href=data.continueUrl;a.className='btn btn-primary';a.textContent='Continue this work';summary.append(h,p,a);host.hidden=true;busy=false;button.disabled=false;
let summary=root.querySelector('[data-focus-summary]');if(!summary){summary=document.createElement('div');host.before(summary);}summary.replaceChildren();const h=document.createElement('h2');h.textContent=data.activity+' · '+data.title;const p=document.createElement('p');p.textContent=data.intention||'Your focus is saved. No recording has started.';const a=document.createElement('a');a.href=data.continueUrl;a.className='btn btn-primary';a.textContent='Continue this work';summary.append(h,p,a);host.hidden=true;const change=root.querySelector('[data-change-focus]');if(change)change.hidden=false;busy=false;button.disabled=false;
window.dispatchEvent(new CustomEvent('plotdirector:focus-saved',{detail:data}));summary.tabIndex=-1;summary.focus();}catch{form.querySelector('[data-focus-error]').textContent='Your focus could not be confirmed. Your choices are retained; please try again.';busy=false;button.disabled=false;}});
}
root.querySelector('[data-change-focus]')?.addEventListener('click',async e=>{e.preventDefault();if(loading)return;if(host.querySelector('form')){host.hidden=false;return;}loading=true;host.hidden=false;host.textContent='Loading your focus…';try{const r=await fetch(root.dataset.focusUrl);if(!r.ok)throw Error();host.innerHTML=await r.text();initialise();}catch{host.textContent='Focus is temporarily unavailable. Try Change focus again.';}finally{loading=false;}});
root.querySelector('[data-change-focus]')?.addEventListener('click',async e=>{e.preventDefault();if(loading)return;e.currentTarget.hidden=true;if(host.querySelector('form')){host.hidden=false;return;}loading=true;host.hidden=false;host.textContent='Loading your focus…';try{const r=await fetch(root.dataset.focusUrl);if(!r.ok)throw Error();host.innerHTML=await r.text();initialise();}catch{host.textContent='Focus is temporarily unavailable. Try Change focus again.';}finally{loading=false;}});
initialise();
})();