From e9402d0c1673d3dc8afcca26bb344b82fa11caf0 Mon Sep 17 00:00:00 2001 From: Nick Beckley Date: Mon, 16 Nov 2026 17:17:08 +0000 Subject: [PATCH] Complete Writer Phase 2C refinements and unify current work actions --- Docs/Writer/Writer3/Help-Coverage.md | 8 +++++- Docs/Writer/Writer3/Implementation-Tracker.md | 6 ++++- Docs/Writer/Writer3/Phase2C-Issues.md | 27 +++++++++++++++++++ PlotLine.Tests/Browser/writer3-focus-live.cjs | 15 +++++++++++ PlotLine.Tests/Browser/writer3-focus.cjs | 18 +++++++++++++ PlotLine.Tests/Browser/writer3-refinement.cjs | 22 +++++++++++++++ .../Browser/writer3-visual-capture.cjs | 8 ++++++ PlotLine.Tests/WriterNavigationTests.cs | 3 +++ PlotLine/Controllers/WriterController.cs | 4 ++- .../Articles/Workspace/Writer3-explore.md | 2 +- .../Help/Articles/Workspace/Writer3-layout.md | 6 ++++- .../Help/Articles/Workspace/Writer3-plan.md | 2 +- .../Articles/Workspace/Writer3-reflect.md | 2 +- .../Help/Articles/Workspace/Writer3-review.md | 2 +- .../Help/Articles/Workspace/Writer3-write.md | 14 ++++++++-- PlotLine/Models/WriterWork.cs | 2 +- .../Services/Writer/WriterFocusActivities.cs | 13 +++++++++ .../Views/Shared/_WriterWorkToolbar.cshtml | 8 +++--- PlotLine/Views/Writer/Destination.cshtml | 1 + PlotLine/Views/Writer/_WriterFocusForm.cshtml | 13 +++++++++ PlotLine/Views/Writer/_WriterWrite.cshtml | 14 ++++++---- PlotLine/wwwroot/css/writer3.css | 18 +++++++++++++ PlotLine/wwwroot/js/writer-focus.js | 21 +++++++++++++++ PlotLine/wwwroot/js/writer-work.js | 5 +++- PlotLine/wwwroot/js/writer3-workspace.js | 13 ++++++++- 25 files changed, 226 insertions(+), 21 deletions(-) create mode 100644 Docs/Writer/Writer3/Phase2C-Issues.md create mode 100644 PlotLine.Tests/Browser/writer3-focus-live.cjs create mode 100644 PlotLine.Tests/Browser/writer3-focus.cjs create mode 100644 PlotLine.Tests/Browser/writer3-refinement.cjs create mode 100644 PlotLine.Tests/Browser/writer3-visual-capture.cjs create mode 100644 PlotLine/Services/Writer/WriterFocusActivities.cs create mode 100644 PlotLine/Views/Writer/_WriterFocusForm.cshtml create mode 100644 PlotLine/wwwroot/js/writer-focus.js diff --git a/Docs/Writer/Writer3/Help-Coverage.md b/Docs/Writer/Writer3/Help-Coverage.md index c40e7289..33508ad4 100644 --- a/Docs/Writer/Writer3/Help-Coverage.md +++ b/Docs/Writer/Writer3/Help-Coverage.md @@ -85,4 +85,10 @@ Existing workspace.overview now describes the preserved Writing desk at /Writer/ ## Phase 2B layout Help -`writer3.layout` uses the existing Markdown tag helper beside each split-destination heading. Covers pointer/keyboard resizing, minimum widths, collapse/restore, independent device preferences, responsive overlay/focus, storage failure and standalone-window separation. The five destination articles also explain the controls. Browser popup, PWA drawer and full article are qualification gates. +`writer3.layout` uses the existing Markdown tag helper beside the labelled layout controls on each split destination. Covers pointer/keyboard resizing, minimum widths, collapse/restore, independent device preferences, responsive overlay/focus, storage failure and standalone-window separation. The five destination articles also explain the controls. Browser popup, PWA drawer and full article are qualification gates. + +## Phase 2C Help review + +Destination Help remains at the heading. The layout tooltip/popup icon is grouped with Show/Hide companion and Layout Help, removing ambiguous adjacent heading icons. `writer3.layout` now explains browser modifier shortcuts, PWA Page Help with collapsed ribbon, and control locations. Five destination articles and Write session grouping are updated. Existing micro/quick/full content, popup, drawer and full article are exercised in rendered qualification. Standalone Context/Intent authority and media/accepted-text boundaries remain unchanged. + +Phase2C amendment: `writer3.write` explains the single working-focus selection, separate save/record/plan actions, actual objective/session mappings, explicit proofreading recording choice, recording-only activities, active-target differences and optional book-scoped planning. Existing working-context/session/native and planning Help remain authoritative; no data consolidation. diff --git a/Docs/Writer/Writer3/Implementation-Tracker.md b/Docs/Writer/Writer3/Implementation-Tracker.md index a2cef4a8..626ad77a 100644 --- a/Docs/Writer/Writer3/Implementation-Tracker.md +++ b/Docs/Writer/Writer3/Implementation-Tracker.md @@ -1,6 +1,6 @@ # Writer 3.0 implementation tracker -Baseline: `9a8b9a3`, shared branch `codex/word-companion-native-phase1-20261104`, 16 November 2026. The original kickoff authorised Phase 1 implementation and Development deployment; the master specification governs product direction even though its header says Proposed. The subsequent Phase2A kickoff explicitly authorised Home, navigation, destination shells and Development deployment; Phase2B was subsequently explicitly authorised for layout infrastructure and Development deployment; Phase2C remains unauthorised. No feature is retired. Unrelated investigation file is preserved. +Baseline: `9a8b9a3`, shared branch `codex/word-companion-native-phase1-20261104`, 16 November 2026. The original kickoff authorised Phase 1 implementation and Development deployment; the master specification governs product direction even though its header says Proposed. The subsequent Phase2A kickoff explicitly authorised Home, navigation, destination shells and Development deployment; Phase2B was subsequently explicitly authorised for layout infrastructure and Development deployment; Phase2C is explicitly authorised for inspection, bounded corrections and final Development qualification; Phase3 remains unauthorised. No feature is retired. Unrelated investigation file is preserved. ## Phase 1 screen and interaction states before implementation @@ -336,3 +336,7 @@ Home, five destination shells, Plan/Reflect Dashboard and contextual existing ri ## Phase 2B completion — 16 November 2026 Application `10bf9db9061fdec340acf7ff0df96f3dfd299814`, release `10bf9db-20261116T164516Z`. Shared viewport composition, pointer/keyboard split, collapse/restore, narrow overlay, per-actor/per-destination device preferences, compact Home spacing and existing-system layout Help delivered. No schema, author-story-data, native protocol or standalone-window changes. Build0warnings/errors; full harness584 PASS; isolated and authenticated Development workspace matrices200 cases each; navigation168 cases; legacy desk48 cases; Reader/Intent/native-follow/reference/audio preservation passed. Live scoped author-data hashes identical; fixture account/projects removed. DLL hash/metadata matched; service active, TLS GET200, warning journal clear. Physical Windows/installed PWA/real media/multi-monitor and assistive-technology checks remain manual. [Phase2B report and screenshots](Phase2B-Report.md). Phase2C not started. + +## Phase 2C authorised scope + +[Observed issue register](Phase2C-Issues.md). Pre-change authenticated Development capture complete; correcting observed Explore marker wrapping, collapsed reading widths, Help placement, session hierarchy and modified-key interception. Reuse current routes/ribbon/workspace and storage. No future feature integration. Full regression, browser matrices and Development acceptance pending. Phase3 not started. diff --git a/Docs/Writer/Writer3/Phase2C-Issues.md b/Docs/Writer/Writer3/Phase2C-Issues.md new file mode 100644 index 00000000..6a15c7a3 --- /dev/null +++ b/Docs/Writer/Writer3/Phase2C-Issues.md @@ -0,0 +1,27 @@ +# Phase 2C inspection and issue register + +Baseline: deployed10bf9db / source01c1197. Authenticated Development renders captured **before any layout changes** using a disposable author and saved scene, at1440×900,1024×900,390×844, Home and all five destinations; Write/Explore expanded/collapsed or narrow overlay variants. Existing six-screen mockup used for hierarchy/density, not literal controls. No horizontal/vertical document overflow in the18 baseline normal states. Before screenshots and geometry are retained in Phase2C evidence. + +| Issue | Evidence | Bounded correction | +|---|---|---| +| Explore number01 breaks into two lines at1024px | before/Explore-1024.png | Non-shrinking two-character marker; allow adjacent copy to wrap | +| Collapsed Write session descriptions/rules span the entire wide panel | before/Write-1440-collapsed.png | Limit content reading width while allowing the panel to use available space | +| Two anonymous Help icons beside destination title, plus separate Layout Help | before/Write-1440.png; same across destinations | Move existing Markdown layout Help icon beside labelled layout controls; retain destination Help at heading and existing drawer button | +| Session activity selector competes with saved focus without its own heading | before/Write-1440.png | Label the existing always-available session group; preserve DOM/controls and semantics | +| Divider consumes modified Left/Right including Alt+Left browser history | before-modifier.log: browserHistoryShortcutPrevented=true | Reserve only unmodified/Shift arrows for resizing; leave Ctrl/Alt/Meta navigation to browser/OS | + +Home cards are balanced, aligned, dominant and fit the desktop viewport; preserve them. Plan, Review and Reflect have clear primary actions and appropriate empty/evidence copy; apply shared utility/readability corrections only. Tall panels reflect viewport allocation, not permission to fill empty space with unrelated content. No mock insights, new planning engine, guided exploration or integrated Context/Intent editing. + +Qualification: existing matrices plus targeted rendered checks for marker wrapping, Help placement, reading width, modified-key preservation, reduced motion, independent panel scrolling, overlay tab exit and active audio-control reachability. Physical Windows/installed PWA/media/multiple-monitor acceptance remains manual. + +## Additional authorised Current Work correction + +The user’s mid-batch amendment identifies duplicated objective and session activity/chapter selectors, especially in the empty/edit state. Integrate into2C before qualification/deployment; retain completed visual work and shared branch. + +One editor now chooses activity/chapter/optional scene. Save working focus uses existing SaveObjective only. Record this session bridges that selection to the unchanged WriterWork session-start implementation, with its antiforgery, busy guard, stable retry UUID and canonical SQL. Plan writing time is an optional GET to the book-scoped planner with a validated activity-derived goal category, without saving/recording. Existing schedule chapter/scene allocation remains there; no new scene scheduling engine. + +Actual objective activities from WriterObjective model/SQL: Drafting, Revising, Editing, Researching, Proofreading. Actual session kinds from WriterWork controller/SQL: Writing, Editing, Planning, Reading, AudioReview. Preserve established Drafting→Writing, Revising/Editing→Editing and Researching→Planning adapters, and announce the recording type. Proofreading has no automatic adapter: require explicit Editing or Reading choice. Planning/Reading/AudioReview are recording-only options and cannot be saved to objective storage. AudioReview still requires a chapter. + +Saved focus is read-only on return, with a Change action and optional recording/planning actions. New Write renders no duplicate session selectors. Existing active controls remain in the same client-owned DOM and show actual activity/chapter; explicit text distinguishes the active recording from saved focus. Objective edits do not issue a session retarget. Legacy desk and other independent session entry points remain unchanged. No database consolidation, migration or native protocol change. + +Qualification also caught a tooltip overlay intercepting adjacent layout controls after regrouping; the existing tooltip receives a scoped non-interactive class, while the interactive Help popup/article are unchanged. Visual inspection of the unified form caught its inherited white-on-gold Save label; scoped existing theme tokens now provide the correct foreground, with an explicit four-theme contrast assertion. Neither correction changes global Help or button styling. diff --git a/PlotLine.Tests/Browser/writer3-focus-live.cjs b/PlotLine.Tests/Browser/writer3-focus-live.cjs new file mode 100644 index 00000000..9bc7f58c --- /dev/null +++ b/PlotLine.Tests/Browser/writer3-focus-live.cjs @@ -0,0 +1,15 @@ +// Explicit writes only to the supplied dedicated disposable Development fixture. +const{chromium}=require('playwright'),assert=require('node:assert/strict'),fs=require('node:fs'); +(async()=>{const w=JSON.parse(fs.readFileSync(process.env.PD_WRITER3_IDENTITY));assert(w.Database==='PlotDirector_Development'&&w.Email.endsWith('@example.invalid'));const b=await chromium.launch();try{for(const pwa of[false,true]){const c=await b.newContext({viewport:{width:1440,height:900}});await c.addInitScript(id=>localStorage.setItem('plotdirector.desktop.v1.'+id,JSON.stringify({dismissedAt:Date.now()})),w.UserID);if(pwa)await c.addInitScript(()=>Object.defineProperty(navigator,'standalone',{value:true}));const p=await c.newPage(),base='https://dev.plotdirector.com',url=`${base}/Writer/Write?projectId=${w.project}&bookId=${w.book}`; +await p.goto(base+'/Account/Login');await p.locator('[name=Email]').fill(w.Email);await p.locator('[name=Password]').fill(w.Password);await Promise.all([p.waitForURL('**/Projects'),p.locator('button[type=submit]').click()]);const state=async()=>await(await p.request.get(`${base}/Writer/Work/State?bookId=${w.book}`)).json(); +await p.goto(url+'&setup=true');await p.locator('[data-focus-activity]').selectOption('Drafting');await p.locator('[data-objective-chapter]').selectOption(String(w.chapter));await p.locator('[data-objective-scene]').selectOption(String(w.scene));await Promise.all([p.waitForURL(u=>u.pathname==='/Writer/Write'&&!u.searchParams.has('setup')),p.locator('[data-save-focus]').click()]);assert.equal((await state()).session,null,'save does not start session');assert(await p.getByRole('link',{name:'Open current scene',exact:true}).isVisible()); +await p.locator('[data-record-focus]:enabled').waitFor();await p.locator('[data-record-focus]').click();await p.locator('[data-work-current]:visible').waitFor();const active=(await state()).session;assert.equal(active.kind,'Writing');assert.equal(active.chapterID,w.chapter); +await p.goto(url+'&setup=true');await p.locator('[data-work-current]:visible').waitFor();assert(await p.locator('[data-record-focus]').isHidden());await p.locator('[data-objective-chapter]').selectOption('');await p.locator('[data-focus-activity]').selectOption('Editing');await Promise.all([p.waitForURL(u=>u.pathname==='/Writer/Write'&&!u.searchParams.has('setup')),p.locator('[data-save-focus]').click()]);await p.locator('[data-focus-session-difference]:visible').waitFor();assert((await p.locator('[data-focus-session-difference]').textContent()).includes('differs'));assert.equal((await state()).session.sessionID,active.sessionID);assert.equal((await state()).session.chapterID,w.chapter); +await p.locator('[data-work-note]').fill('Disposable unified workflow acceptance note');await p.locator('[data-work-end]').click();await p.locator('[data-work-current]').waitFor({state:'hidden'});assert.equal((await state()).session,null); +// Canonical endpoint rejects impossible scene/chapter combinations and unsupported objective activities. +const token=await p.locator('[data-work-start] [name=__RequestVerificationToken]').inputValue();for(const fields of[{Activity:'Editing',ChapterID:'',SceneID:String(w.scene)},{Activity:'AudioReview',ChapterID:String(w.chapter),SceneID:''}]){const response=await p.request.post(base+'/Writer/SaveObjective',{form:{__RequestVerificationToken:token,BookID:String(w.book),...fields}});assert.equal(response.status(),200);assert(response.url().includes('setup=True')||response.url().includes('setup=true'));} +await p.goto(url);assert.equal(await p.getByRole('link',{name:'Open current scene',exact:true}).count(),0,'invalid submissions preserve valid whole-book focus');assert.equal((await state()).session,null); +assert.equal((await p.request.post(base+'/Writer/SaveObjective',{form:{BookID:String(w.book),Activity:'Drafting'}})).status(),400,'antiforgery retained'); +await p.goto(url+'&setup=true');await p.locator('[data-focus-activity]').selectOption('Editing');await p.locator('[data-plan-focus]').click();await p.waitForURL('**/Writer/ScheduleSetup?*');assert.equal(new URL(p.url()).searchParams.get('bookId'),String(w.book));assert.equal(await p.locator('[name=GoalType]').inputValue(),'Revision');assert.equal((await state()).session,null); +await p.goto(url+'&setup=true');await p.locator('[data-focus-activity]').selectOption('Revising');await p.locator('[data-objective-chapter]').selectOption(String(w.chapter));await p.locator('[data-objective-scene]').selectOption(String(w.scene));await Promise.all([p.waitForURL(u=>u.pathname==='/Writer/Write'&&!u.searchParams.has('setup')),p.locator('[data-save-focus]').click()]);await c.close();} +console.log('PASS authenticated Development unified workflow: real objective create/change, explicit Writing session, active target/ID isolation, note/end, invalid scene and unsupported objective rejection, antiforgery400, optional scoped revision planning; fixture focus restored; browser/simulated PWA.');}finally{await b.close()}})().catch(e=>{console.error(e.message);process.exitCode=1}); diff --git a/PlotLine.Tests/Browser/writer3-focus.cjs b/PlotLine.Tests/Browser/writer3-focus.cjs new file mode 100644 index 00000000..1d84c9f9 --- /dev/null +++ b/PlotLine.Tests/Browser/writer3-focus.cjs @@ -0,0 +1,18 @@ +const{chromium}=require('playwright'),assert=require('node:assert/strict'); +(async()=>{const b=await chromium.launch();try{for(const pwa of[false,true]){ +const c=await b.newContext({viewport:{width:1440,height:900}});await c.addInitScript(()=>localStorage.setItem('plotdirector.desktop.v1.4',JSON.stringify({dismissedAt:Date.now()})));if(pwa)await c.addInitScript(()=>Object.defineProperty(navigator,'standalone',{value:true})); +let session=null,starts=[],saves=[],blockStart=null;await c.route('**/Writer/Work/**',async r=>{const action=new URL(r.request().url()).pathname.split('/').pop();if(action==='State')return r.fulfill({json:{session,defaultPauseOnEdit:true}});const d=Object.fromEntries(new URLSearchParams(r.request().postData()));assert(d.__RequestVerificationToken);if(action==='Start'){starts.push(d);if(blockStart)await blockStart;session={sessionID:d.requestId,kind:d.kind,chapterID:Number(d.chapterId)||null,chapterTitle:d.chapterId==='22'?'The harbour':'The crossing',startedUtc:new Date().toISOString(),engagedSeconds:0,playbackSeconds:0,uniqueSeconds:0,pauseOnEdit:true,live:false,sequence:0};}if(action==='End')session=null;await r.fulfill({status:200,body:''});}); +await c.route('**/Writer/SaveObjective',async r=>{saves.push(Object.fromEntries(new URLSearchParams(r.request().postData())));assert(saves.at(-1).__RequestVerificationToken);await r.fulfill({status:200,contentType:'text/html',body:'

Working focus saved by fixture

'});}); +const p=await c.newPage(),errors=[];p.on('pageerror',e=>errors.push(e.message));const url='http://127.0.0.1:5238/Writer/Write?projectId=7&bookId=12'; +await p.goto(url);await p.locator('[data-record-focus]:enabled').waitFor();for(const theme of ['modern-dark','modern-light','warm-dark','plotdirector']){await p.evaluate(t=>window.PlotDirectorApplyApplicationTheme(t),theme);await p.locator('[data-save-focus]').screenshot({animations:'disabled'});const contrast=await p.locator('[data-save-focus]').evaluate(n=>{const lum=s=>s.match(/[\d.]+/g).slice(0,3).map(Number).map(x=>{x/=255;return x<=.04045?x/12.92:((x+.055)/1.055)**2.4}).reduce((v,x,i)=>v+x*[.2126,.7152,.0722][i],0),c=getComputedStyle(n),a=lum(c.color),b=lum(c.backgroundColor);return(Math.max(a,b)+.05)/(Math.min(a,b)+.05)});assert(contrast>=4.5,'Save focus label contrast '+theme);} +assert.equal(await p.locator('select[name=ChapterID]').count(),1);assert.equal(await p.locator('[data-work-start] select').count(),0,'one chapter/activity selection');assert.equal(await p.locator('[data-focus-activity]').count(),1); +await p.locator('[data-objective-chapter]').selectOption('21');await p.locator('[data-objective-scene]').selectOption('31');await p.locator('[data-objective-chapter]').selectOption('22');assert.equal(await p.locator('[data-objective-scene]').inputValue(),'');assert(await p.locator('[data-objective-scene] option[value="31"]').evaluate(n=>n.disabled));await p.locator('[data-objective-scene]').selectOption('32'); +await p.locator('[data-save-focus]').click();assert.equal(saves.length,1);assert.equal(saves[0].ChapterID,'22');assert.equal(saves[0].SceneID,'32');assert.equal(starts.length,0,'saving never starts recording'); +await p.goto(url+'&objective=true');assert.equal(await p.locator('[data-focus-form]').count(),0,'saved focus is read-only by default');assert(await p.getByRole('link',{name:'Change working focus'}).isVisible());await p.locator('[data-record-focus]:enabled').waitFor();let release;blockStart=new Promise(r=>release=r);await p.locator('[data-record-focus]').click();await p.locator('[data-record-focus]').dispatchEvent('click');release();blockStart=null;await p.locator('[data-work-current]:visible').waitFor();assert.equal(starts.length,1);assert.equal(starts[0].chapterId,'21');assert.equal(starts[0].kind,'Editing');assert.equal(saves.length,1,'recording never saves objective');assert(await p.locator('[data-record-focus]').isHidden()); +const activeId=session.sessionID;await p.goto(url+'&objective=true&setup=true');await p.locator('[data-work-current]:visible').waitFor();await p.locator('[data-objective-chapter]').selectOption('22');assert.equal(session.sessionID,activeId);assert.equal(session.chapterID,21);assert(await p.locator('[data-record-focus]').isHidden()); +session={...session,chapterID:22,chapterTitle:'The harbour',kind:'Writing'};await p.reload();await p.locator('[data-focus-session-difference]:visible').waitFor();assert((await p.locator('[data-focus-session-difference]').textContent()).includes('differs'));assert((await p.locator('[data-work-bound]').textContent()).includes('The harbour')); +session=null;await p.goto(url+'&setup=true');await p.locator('[data-record-focus]:enabled').waitFor();await p.locator('[data-focus-activity]').selectOption('Proofreading');await p.locator('[data-record-focus]').click();assert.equal(starts.length,1);assert(await p.locator('[data-record-kind-choice]').isVisible());await p.locator('[data-record-kind]').selectOption('Reading');await p.locator('[data-record-focus]').click();await p.locator('[data-work-current]:visible').waitFor();assert.equal(starts.at(-1).kind,'Reading'); +session=null;await p.goto(url+'&setup=true');await p.locator('[data-record-focus]:enabled').waitFor();await p.locator('[data-focus-activity]').selectOption('AudioReview');assert(await p.locator('[data-save-focus]').isDisabled());await p.locator('[data-record-focus]').click();assert.equal(starts.length,2,'Audio Review requires chapter');await p.locator('[data-objective-chapter]').selectOption('21');await p.locator('[data-record-focus]').click();await p.locator('[data-work-audio]:visible').waitFor();assert.equal(starts.at(-1).kind,'AudioReview'); +session=null;await p.goto(url+'&setup=true');await p.locator('[data-focus-activity]').selectOption('Editing');await p.locator('[data-plan-focus]').click();await p.waitForURL('**/Writer/ScheduleSetup?*');assert.equal(new URL(p.url()).searchParams.get('bookId'),'12');assert.equal(new URL(p.url()).searchParams.get('focusActivity'),'Editing');assert.equal(saves.length,1);assert.equal(starts.length,3); +await p.goto(url+'&setup=true');await p.locator('#appBookMenu').click();await p.locator('[data-app-book-choice="13"]').click();await p.waitForURL('**bookId=13*');assert.equal(await p.locator('[data-objective-chapter] option[value="21"]').count(),0);assert.equal(await p.locator('[data-objective-scene]').inputValue(),'');assert.deepEqual(errors,[]);await c.close();} +console.log('PASS unified current work: one selector set, save-only, explicit recording/idempotent repeat, saved display/change, active/mismatched targets, explicit proofreading choice, AudioReview chapter rule, dependent scenes, optional scoped scheduling and book-switch clearing in browser/simulated PWA.');}finally{await b.close()}})().catch(e=>{console.error(e.stack);process.exitCode=1}); diff --git a/PlotLine.Tests/Browser/writer3-refinement.cjs b/PlotLine.Tests/Browser/writer3-refinement.cjs new file mode 100644 index 00000000..361347e2 --- /dev/null +++ b/PlotLine.Tests/Browser/writer3-refinement.cjs @@ -0,0 +1,22 @@ +const{chromium}=require('playwright'),assert=require('node:assert/strict'),fs=require('node:fs'); +const live=!!process.env.PD_WRITER3_IDENTITY,w=live?JSON.parse(fs.readFileSync(process.env.PD_WRITER3_IDENTITY)):null,base=live?'https://dev.plotdirector.com':'http://127.0.0.1:5238';if(live)assert(w.Database==='PlotDirector_Development'&&w.Email.endsWith('@example.invalid')); +const url=d=>`${base}/Writer/${d}?projectId=${w?.project||7}&bookId=${w?.book||12}${live?'':'&objective=true&populated=true'}`; +const settle=p=>p.evaluate(()=>new Promise(r=>requestAnimationFrame(()=>requestAnimationFrame(r)))); +(async()=>{const b=await chromium.launch();try{for(const pwa of[false,true]){ +const c=await b.newContext({viewport:{width:1440,height:900},reducedMotion:'reduce'});if(pwa)await c.addInitScript(()=>Object.defineProperty(navigator,'standalone',{value:true}));await c.addInitScript(id=>localStorage.setItem('plotdirector.desktop.v1.'+id,JSON.stringify({dismissedAt:Date.now()})),w?.UserID||4);const p=await c.newPage(),errors=[];p.on('pageerror',e=>errors.push(e.message)); +if(live){await p.goto(base+'/Account/Login');await p.locator('[name=Email]').fill(w.Email);await p.locator('[name=Password]').fill(w.Password);await Promise.all([p.waitForURL('**/Projects'),p.locator('button[type=submit]').click()]);} +else await c.route('**/Writer/Work/State?*',r=>r.fulfill({json:{session:null,defaultPauseOnEdit:true}})); +for(const d of['Write','Explore','Plan','Review','Reflect']){ +await p.goto(url(d));await settle(p);assert.equal(await p.locator('.writer3-title [data-help-key="writer3.layout"]').count(),0,'heading has destination Help only');assert(await p.locator('.writer3-layout-tools [data-help-key="writer3.layout"]').isVisible()); +const sep=p.getByRole('separator',{name:'Resize contextual companion'});assert(await sep.evaluate(n=>{for(const modifier of['altKey','ctrlKey','metaKey']){const e=new KeyboardEvent('keydown',{key:'ArrowLeft',[modifier]:true,bubbles:true,cancelable:true});n.dispatchEvent(e);if(e.defaultPrevented)return false;}return true;}),'browser/OS modified shortcuts remain available'); +await p.locator('.writer3-layout-tools button').first().click();const measures=await p.locator('.writer3-main').evaluate(n=>({width:n.clientWidth,max:Math.max(...[...n.children].map(x=>x.getBoundingClientRect().width))}));assert(measures.maxns.every(n=>{const r=document.createRange();r.selectNodeContents(n);return r.getClientRects().length===1;})),'01/02/03 remain on one line'); +await p.setViewportSize({width:390,height:844});await p.goto(url('Explore'));await p.locator('.writer3-layout-tools button').first().click();await p.locator('.writer3-link-list a').last().focus();await p.keyboard.press('Tab');await settle(p);assert(await p.locator('.writer3-reference').isHidden(),'keyboard exit closes overlay without trapping navigation'); +await p.setViewportSize({width:1440,height:900});await p.goto(url('Write'));assert(await p.getByRole('heading',{name:'Work sessions & Audio Review',exact:true}).isVisible()); +if(!live){await p.setViewportSize({width:1440,height:700});const session={sessionID:'22222222-2222-2222-2222-222222222222',kind:'AudioReview',bookID:12,chapterID:21,chapterTitle:'Bound chapter',startedUtc:new Date().toISOString(),engagedSeconds:60,playbackSeconds:10,uniqueSeconds:10,pauseOnEdit:true,live:true,playbackState:'playing',capabilities:'play,pause,back15,forward15',sequence:1};await p.route('**/Writer/Work/State?*',r=>r.fulfill({json:{session}}));await p.reload();await p.locator('[data-work-audio]:visible').waitFor();await p.locator('[data-work-note]').fill('Unsaved audio note');const before=await p.locator('[data-writer-work]').elementHandle();await p.locator('.writer3-layout-tools button').first().click();await p.locator('[data-media-command="pause"]').scrollIntoViewIfNeeded();assert(await p.locator('[data-media-command="pause"]').isVisible());assert(await before.evaluate(n=>n===document.querySelector('[data-writer-work]')));assert.equal(await p.locator('[data-work-note]').inputValue(),'Unsaved audio note');assert(await p.locator('.writer3-main').evaluate(n=>n.scrollTop>0));assert.equal(await p.evaluate(()=>window.scrollY),0,'audio controls scroll within main, not document');} +assert.deepEqual(errors,[]);await c.close();} +console.log(`PASS Phase2C ${live?'authenticated Development':'isolated MVC'}: marker line wrapping, Help placement/popup, readable collapsed content, browser modifier shortcuts, reduced-motion context, overlay Tab exit, five Help articles and existing session heading${live?'':', retained active AudioReview DOM/notes and independent scroll to media controls'}.`); +}finally{await b.close()}})().catch(e=>{console.error(e.stack);process.exitCode=1}); diff --git a/PlotLine.Tests/Browser/writer3-visual-capture.cjs b/PlotLine.Tests/Browser/writer3-visual-capture.cjs new file mode 100644 index 00000000..5f7f81d8 --- /dev/null +++ b/PlotLine.Tests/Browser/writer3-visual-capture.cjs @@ -0,0 +1,8 @@ +// Read-only authenticated Development screenshots; requires a dedicated disposable identity. +const{chromium}=require('playwright'),fs=require('node:fs'),assert=require('node:assert/strict'); +(async()=>{const w=JSON.parse(fs.readFileSync(process.env.PD_WRITER3_IDENTITY)),out=process.env.PD_WRITER3_SCREENSHOTS;assert(w.Database==='PlotDirector_Development'&&out&&w.Email.endsWith('@example.invalid'));fs.mkdirSync(out,{recursive:true});const b=await chromium.launch();try{const p=await b.newPage({viewport:{width:1440,height:1000}});await p.goto('https://dev.plotdirector.com/Account/Login');await p.locator('[name=Email]').fill(w.Email);await p.locator('[name=Password]').fill(w.Password);await Promise.all([p.waitForURL('**/Projects'),p.locator('button[type=submit]').click()]);const records=[]; +for(const width of[1440,1024,390])for(const d of['Index','Write','Explore','Plan','Review','Reflect']){ +await p.setViewportSize({width,height:width===390?844:900});await p.goto(`https://dev.plotdirector.com/Writer/${d}?projectId=${w.project}&bookId=${w.book}`);await p.evaluate(()=>window.PlotDirectorApplyApplicationTheme('modern-dark'));await p.evaluate(()=>{for(const k of Object.keys(localStorage).filter(k=>k.startsWith('plotdirector.writerLayout.')))localStorage.removeItem(k)});await p.reload();await p.evaluate(()=>window.PlotDirectorApplyApplicationTheme('modern-dark'));await p.evaluate(()=>new Promise(r=>requestAnimationFrame(()=>requestAnimationFrame(r))));await p.mouse.move(0,0); +await p.screenshot({path:`${out}/${d}-${width}.png`,fullPage:true,animations:"disabled"});records.push({destination:d,width,...await p.evaluate(()=>({overflowX:document.documentElement.scrollWidth-innerWidth,overflowY:document.documentElement.scrollHeight-innerHeight,heading:document.querySelector('.writer3 h1')?.textContent.trim()}))}); +if(['Write','Explore'].includes(d)){const t=p.locator('.writer3-layout-tools button').first();await t.click();await p.mouse.move(0,0);await p.screenshot({path:`${out}/${d}-${width}-${await p.locator('.writer3-reference').isHidden()?'collapsed':'companion'}.png`,fullPage:true,animations:"disabled"});} +}console.log(JSON.stringify(records,null,2));}finally{await b.close()}})().catch(e=>{console.error(e.message);process.exitCode=1}); diff --git a/PlotLine.Tests/WriterNavigationTests.cs b/PlotLine.Tests/WriterNavigationTests.cs index 99977c01..3de8145e 100644 --- a/PlotLine.Tests/WriterNavigationTests.cs +++ b/PlotLine.Tests/WriterNavigationTests.cs @@ -10,6 +10,9 @@ internal static class WriterNavigationTests public static async Task Run() { void Check(bool ok,string why){if(!ok)throw new Exception(why);Console.WriteLine("PASS Writer navigation "+why);} + Check(PlotLine.Services.Writer.WriterFocusActivities.SessionKind("Drafting")=="Writing" && PlotLine.Services.Writer.WriterFocusActivities.SessionKind("Researching")=="Planning" && PlotLine.Services.Writer.WriterFocusActivities.SessionKind("Revising")=="Editing", "objective activity mappings use supported session types"); + Check(PlotLine.Services.Writer.WriterFocusActivities.SessionKind("Proofreading")==null && PlotLine.Services.Writer.WriterFocusActivities.SessionKind("Unknown")==null, "ambiguous or unsupported recording activity requires explicit compatible choice"); + Check(!PlotLine.Services.Writer.WriterFocusActivities.ObjectiveKinds.Contains("AudioReview") && PlotLine.Services.Writer.WriterFocusActivities.SessionKind("AudioReview")=="AudioReview", "session-only activities never become objective types"); var allowed=true;int reads=0; var workspace=NativeWorkflowTests.Proxy((n,a)=> { diff --git a/PlotLine/Controllers/WriterController.cs b/PlotLine/Controllers/WriterController.cs index d27fe782..92ae8df6 100644 --- a/PlotLine/Controllers/WriterController.cs +++ b/PlotLine/Controllers/WriterController.cs @@ -218,7 +218,7 @@ public sealed class WriterController( return View(nameof(SchedulePreview), model); } - public async Task ScheduleSetup(int? projectId, int? bookId = null) + public async Task ScheduleSetup(int? projectId, int? bookId = null, string? focusActivity = null) { if (bookId.HasValue && bookRepository != null) { @@ -230,6 +230,8 @@ public sealed class WriterController( var model = await writingSchedule.GetScheduleSetupAsync(projectId); model.BookID = bookId; if(objectives!=null&&bookId.HasValue&&int.TryParse(User.FindFirstValue(ClaimTypes.NameIdentifier),out var author)){var objective=(await objectives.Read(author,bookId.Value)).Objective;if(objective?.Activity is "Revising" or "Editing" or "Proofreading")model.GoalType="Revision";} + if (PlotLine.Services.Writer.WriterFocusActivities.ObjectiveKinds.Contains(focusActivity)) + model.GoalType = focusActivity is "Revising" or "Editing" or "Proofreading" ? "Revision" : "FirstDraft"; await writingSchedule.PopulateScheduleSetupOptionsAsync(model); return View(model); } diff --git a/PlotLine/Help/Articles/Workspace/Writer3-explore.md b/PlotLine/Help/Articles/Workspace/Writer3-explore.md index a0e559a2..e90b7a13 100644 --- a/PlotLine/Help/Articles/Workspace/Writer3-explore.md +++ b/PlotLine/Help/Articles/Workspace/Writer3-explore.md @@ -19,4 +19,4 @@ The full specialist workspaces retain their existing editing, permissions and so # Arrange your workspace -Drag the divider or focus it and use Left/Right arrow keys to resize the contextual companion. Hide companion gives your main task the full width; Show companion restores it. Each destination remembers its width and desktop visibility on this browser. In narrow windows the companion opens as an overlay; use Back to workspace or Escape to return. Workspace Layout Help beside the heading explains keyboard controls, storage and the independent standalone Context/Intent windows. +Drag the divider or focus it and use Left/Right arrow keys to resize the contextual companion. Hide companion gives your main task the full width; Show companion restores it. Each destination remembers its width and desktop visibility on this browser. In narrow windows the companion opens as an overlay; use Back to workspace or Escape to return. Workspace Layout Help beside Show/Hide companion explains keyboard controls, storage and the independent standalone Context/Intent windows. diff --git a/PlotLine/Help/Articles/Workspace/Writer3-layout.md b/PlotLine/Help/Articles/Workspace/Writer3-layout.md index 192fa05e..5b4c73e5 100644 --- a/PlotLine/Help/Articles/Workspace/Writer3-layout.md +++ b/PlotLine/Help/Articles/Workspace/Writer3-layout.md @@ -15,7 +15,7 @@ Write, Explore, Plan, Review and Reflect fill the available space below the appl # Resize with a pointer or keyboard -Drag the handle between the panels with a mouse or touch pointer. Panel widths stay within usable limits. Tab to “Resize contextual companion” and use Left arrow to widen the companion or Right arrow to narrow it. Hold Shift for larger steps. Home selects the narrowest width; End selects the widest. The separator announces its width to assistive technology. +Drag the handle between the panels with a mouse or touch pointer. Panel widths stay within usable limits. Tab to “Resize contextual companion” and use Left arrow to widen the companion or Right arrow to narrow it. Hold Shift for larger steps. Ctrl, Alt and Meta combinations keep their browser or operating-system meaning; for example, Alt+Left remains browser Back. Home selects the narrowest width; End selects the widest. The separator announces its width to assistive technology. # Hide and restore @@ -32,3 +32,7 @@ Width and desktop visibility are stored independently for each destination and s # Separate reference windows The contextual companion currently contains existing tool links and summaries. Open Context and Open Intent still launch the independent reference windows, with their own pinned selections, Word following and Display Setup. Resizing or hiding this panel does not change working focus, Reader selection, verified Word position or active session binding. Full integrated Context and Intent editing is a later phase. + +# Find layout Help + +Layout Help and its adjacent question-mark icon sit with Show/Hide companion. The icon provides the existing tooltip and quick popup; Layout Help opens the full drawer. The question mark beside the destination title explains that destination. On PWA, Page Help remains in the contextual ribbon; expand the ribbon when it is collapsed. diff --git a/PlotLine/Help/Articles/Workspace/Writer3-plan.md b/PlotLine/Help/Articles/Workspace/Writer3-plan.md index 1337f589..d38c1db4 100644 --- a/PlotLine/Help/Articles/Workspace/Writer3-plan.md +++ b/PlotLine/Help/Articles/Workspace/Writer3-plan.md @@ -21,4 +21,4 @@ Preview and manage links preserve the book and include project-wide All Books pl # Arrange your workspace -Drag the divider or focus it and use Left/Right arrow keys to resize the contextual companion. Hide companion gives your main task the full width; Show companion restores it. Each destination remembers its width and desktop visibility on this browser. In narrow windows the companion opens as an overlay; use Back to workspace or Escape to return. Workspace Layout Help beside the heading explains keyboard controls, storage and the independent standalone Context/Intent windows. +Drag the divider or focus it and use Left/Right arrow keys to resize the contextual companion. Hide companion gives your main task the full width; Show companion restores it. Each destination remembers its width and desktop visibility on this browser. In narrow windows the companion opens as an overlay; use Back to workspace or Escape to return. Workspace Layout Help beside Show/Hide companion explains keyboard controls, storage and the independent standalone Context/Intent windows. diff --git a/PlotLine/Help/Articles/Workspace/Writer3-reflect.md b/PlotLine/Help/Articles/Workspace/Writer3-reflect.md index c67038d3..703c8a7c 100644 --- a/PlotLine/Help/Articles/Workspace/Writer3-reflect.md +++ b/PlotLine/Help/Articles/Workspace/Writer3-reflect.md @@ -19,4 +19,4 @@ No retained evidence does not mean no writing took place. A baseline starts from # Arrange your workspace -Drag the divider or focus it and use Left/Right arrow keys to resize the contextual companion. Hide companion gives your main task the full width; Show companion restores it. Each destination remembers its width and desktop visibility on this browser. In narrow windows the companion opens as an overlay; use Back to workspace or Escape to return. Workspace Layout Help beside the heading explains keyboard controls, storage and the independent standalone Context/Intent windows. +Drag the divider or focus it and use Left/Right arrow keys to resize the contextual companion. Hide companion gives your main task the full width; Show companion restores it. Each destination remembers its width and desktop visibility on this browser. In narrow windows the companion opens as an overlay; use Back to workspace or Escape to return. Workspace Layout Help beside Show/Hide companion explains keyboard controls, storage and the independent standalone Context/Intent windows. diff --git a/PlotLine/Help/Articles/Workspace/Writer3-review.md b/PlotLine/Help/Articles/Workspace/Writer3-review.md index 527747c5..6f36e61c 100644 --- a/PlotLine/Help/Articles/Workspace/Writer3-review.md +++ b/PlotLine/Help/Articles/Workspace/Writer3-review.md @@ -23,4 +23,4 @@ Open Intent uses the existing standalone reference window. Its Evidence tab load # Arrange your workspace -Drag the divider or focus it and use Left/Right arrow keys to resize the contextual companion. Hide companion gives your main task the full width; Show companion restores it. Each destination remembers its width and desktop visibility on this browser. In narrow windows the companion opens as an overlay; use Back to workspace or Escape to return. Workspace Layout Help beside the heading explains keyboard controls, storage and the independent standalone Context/Intent windows. +Drag the divider or focus it and use Left/Right arrow keys to resize the contextual companion. Hide companion gives your main task the full width; Show companion restores it. Each destination remembers its width and desktop visibility on this browser. In narrow windows the companion opens as an overlay; use Back to workspace or Escape to return. Workspace Layout Help beside Show/Hide companion explains keyboard controls, storage and the independent standalone Context/Intent windows. diff --git a/PlotLine/Help/Articles/Workspace/Writer3-write.md b/PlotLine/Help/Articles/Workspace/Writer3-write.md index 02a7c36a..f09f3fda 100644 --- a/PlotLine/Help/Articles/Workspace/Writer3-write.md +++ b/PlotLine/Help/Articles/Workspace/Writer3-write.md @@ -19,8 +19,18 @@ The existing session controls are available to the book owner. Starting and endi # Change focus -Change objective opens the existing activity/chapter/scene form. Saving it changes your return target, not manuscript text or scene Revision Status. A scene must belong to the selected chapter/book. You may choose the whole manuscript. Book switching loads that book’s objective rather than retaining stale IDs. +Change working focus opens one activity/chapter/scene editor. Saving it changes your return target, not manuscript text or scene Revision Status. A scene must belong to the selected chapter/book. You may choose the whole manuscript. Book switching loads that book’s objective rather than retaining stale IDs. # Arrange your workspace -Drag the divider or focus it and use Left/Right arrow keys to resize the contextual companion. Hide companion gives your main task the full width; Show companion restores it. Each destination remembers its width and desktop visibility on this browser. In narrow windows the companion opens as an overlay; use Back to workspace or Escape to return. Workspace Layout Help beside the heading explains keyboard controls, storage and the independent standalone Context/Intent windows. +Drag the divider or focus it and use Left/Right arrow keys to resize the contextual companion. Hide companion gives your main task the full width; Show companion restores it. Each destination remembers its width and desktop visibility on this browser. In narrow windows the companion opens as an overlay; use Back to workspace or Escape to return. Workspace Layout Help beside Show/Hide companion explains keyboard controls, storage and the independent standalone Context/Intent windows. + +The activity/chapter/scene selectors appear once in the working-focus editor. The **Work sessions & Audio Review** group keeps active recording controls accessible within the main scrolling region, without a second Start form. Its chapter binding is separate from your saved objective and reference browsing; resizing or hiding the companion does not change it. + +# One selection, three optional actions + +Choose what you are doing, a chapter (or whole manuscript) and optionally a scene in that chapter. Changing chapter clears an incompatible scene. **Save working focus** saves your return target and does not start recording. **Record this session** explicitly starts the existing session for that selection without saving the objective. **Plan writing time** opens this book’s existing planner without saving or recording; a supported selected objective activity chooses the draft/revision goal category, and chapter/scene allocations are chosen in the planner. + +Drafting records as Writing; Revising/Editing as Editing; Researching as Planning. For Proofreading, explicitly choose Editing or Reading review before recording. Planning, Reading review and Audio Review are session-only activities and cannot be saved as objectives. Audio Review requires a chapter and still uses the existing Windows media support and explicit playback controls. + +A saved focus is shown on return; use Change working focus to edit it. During an active recording, the actual session activity/chapter and existing timing, note, end and audio controls remain available. No redundant Start form is shown. If the saved focus and session differ, the page says so. Saving/changing focus does not move or rebind the session, Reader or verified Word context. Existing independent recording entry points remain available on the retained Writing desk and Reader. diff --git a/PlotLine/Models/WriterWork.cs b/PlotLine/Models/WriterWork.cs index d50cbcee..6d668dd2 100644 --- a/PlotLine/Models/WriterWork.cs +++ b/PlotLine/Models/WriterWork.cs @@ -69,4 +69,4 @@ public sealed class WriterWorkPage public IReadOnlyList Sessions { get; set; } = []; public IReadOnlyList Days { get; set; } = []; } -public sealed record WriterWorkToolbar(int BookID,int? ChapterID,string? ChapterTitle,IReadOnlyList? Choices=null,string DefaultKind="Writing"); +public sealed record WriterWorkToolbar(int BookID,int? ChapterID,string? ChapterTitle,IReadOnlyList? Choices=null,string DefaultKind="Writing",bool Unified=false); diff --git a/PlotLine/Services/Writer/WriterFocusActivities.cs b/PlotLine/Services/Writer/WriterFocusActivities.cs new file mode 100644 index 00000000..687dbb0b --- /dev/null +++ b/PlotLine/Services/Writer/WriterFocusActivities.cs @@ -0,0 +1,13 @@ +namespace PlotLine.Services.Writer; + +// Presentation mapping only; objective and session storage retain their own allowed types. +public static class WriterFocusActivities +{ + public static readonly string[] ObjectiveKinds = ["Drafting", "Revising", "Editing", "Researching", "Proofreading"]; + public static string? SessionKind(string? activity) => activity switch + { + "Drafting" => "Writing", "Revising" or "Editing" => "Editing", "Researching" => "Planning", + "Reading" or "AudioReview" or "Planning" => activity, + _ => null // Proofreading requires an explicit compatible recording choice. + }; +} diff --git a/PlotLine/Views/Shared/_WriterWorkToolbar.cshtml b/PlotLine/Views/Shared/_WriterWorkToolbar.cshtml index b06ea2ac..7ae743f4 100644 --- a/PlotLine/Views/Shared/_WriterWorkToolbar.cshtml +++ b/PlotLine/Views/Shared/_WriterWorkToolbar.cshtml @@ -1,15 +1,17 @@ @model PlotLine.Models.WriterWorkToolbar -
-
+
+ @Html.AntiForgeryToken() + @if(Model.Unified){}else{
@if(Model.Choices!=null){} else{@Model.ChapterTitle}
+ } -