Complete Writer Phase 2C refinements and unify current work actions

This commit is contained in:
Nick Beckley 2026-11-16 17:17:08 +00:00
parent 01c1197c92
commit e9402d0c16
25 changed files with 226 additions and 21 deletions

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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});

View File

@ -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:'<p>Working focus saved by fixture</p>'});});
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});

View File

@ -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.max<measures.width-100,'collapsed content has a comfortable reading width');await p.locator('.writer3-layout-tools button').first().click();
if(!pwa){await p.locator('[data-help-key="writer3.layout"] button').click();await p.locator('.plotline-help-popover').waitFor();await p.keyboard.press('Escape');}
assert.equal((await p.request.get(base+`/Help/Article/writer3.${d.toLowerCase()}`)).status(),200);
}
await p.setViewportSize({width:1024,height:900});await p.goto(url('Explore'));await settle(p);assert(await p.locator('.writer3-path-mark').evaluateAll(ns=>ns.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});

View File

@ -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});

View File

@ -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<IWriterWorkspaceService>((n,a)=>
{

View File

@ -218,7 +218,7 @@ public sealed class WriterController(
return View(nameof(SchedulePreview), model);
}
public async Task<IActionResult> ScheduleSetup(int? projectId, int? bookId = null)
public async Task<IActionResult> 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);
}

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -69,4 +69,4 @@ public sealed class WriterWorkPage
public IReadOnlyList<WriterWorkSession> Sessions { get; set; } = [];
public IReadOnlyList<WriterWorkDay> Days { get; set; } = [];
}
public sealed record WriterWorkToolbar(int BookID,int? ChapterID,string? ChapterTitle,IReadOnlyList<WriterObjectiveChoice>? Choices=null,string DefaultKind="Writing");
public sealed record WriterWorkToolbar(int BookID,int? ChapterID,string? ChapterTitle,IReadOnlyList<WriterObjectiveChoice>? Choices=null,string DefaultKind="Writing",bool Unified=false);

View File

@ -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.
};
}

View File

@ -1,15 +1,17 @@
@model PlotLine.Models.WriterWorkToolbar
<section class="writer-work-toolbar" data-writer-work data-book-id="@Model.BookID" data-fixed-chapter="@Model.ChapterID" aria-label="Writing Rhythm and Audio Review">
<form data-work-start>
<section class="writer-work-toolbar" data-writer-work data-book-id="@Model.BookID" data-fixed-chapter="@Model.ChapterID" data-unified-work="@Model.Unified.ToString().ToLowerInvariant()" aria-label="Writing Rhythm and Audio Review">
<form data-work-start hidden="@Model.Unified">
@Html.AntiForgeryToken()
@if(Model.Unified){<input type="hidden" name="kind" value="@Model.DefaultKind" /><input type="hidden" name="chapterId" value="@Model.ChapterID" /><button type="submit" hidden>Record this session</button>}else{
<div class="button-row">
<label>Activity<select name="kind" class="form-select"><option value="Writing" selected="@(Model.DefaultKind=="Writing")">Writing</option><option value="Editing" selected="@(Model.DefaultKind=="Editing")">Editing</option><option value="Planning" selected="@(Model.DefaultKind=="Planning")">Planning</option><option value="Reading" selected="@(Model.DefaultKind=="Reading")">Reading review</option><option value="AudioReview" selected="@(Model.DefaultKind=="AudioReview")">Audio Review</option></select></label>
@if(Model.Choices!=null){<label>Chapter<select name="chapterId" class="form-select"><option value="">Whole book</option>@foreach(var choice in Model.Choices.DistinctBy(x=>x.ChapterID)){<option value="@choice.ChapterID" selected="@(Model.ChapterID==choice.ChapterID)">@choice.ChapterTitle</option>}</select></label>}
else{<span>@Model.ChapterTitle</span><input type="hidden" name="chapterId" value="@Model.ChapterID" />}
<button class="btn btn-primary" type="submit">Start session</button>
</div>
}
</form>
<div data-work-current hidden><strong data-work-label></strong><span data-work-elapsed></span><span data-work-measured></span>
<div data-work-current hidden><p data-work-bound hidden="@(!Model.Unified)"></p><strong data-work-label></strong><span data-work-elapsed></span><span data-work-measured></span>
<label>Return / review note (optional)<textarea data-work-note class="form-control" maxlength="2000" rows="2"></textarea></label>
<button class="btn btn-outline-secondary" data-work-end type="button">End session &amp; save note</button>
</div>

View File

@ -26,6 +26,7 @@
<script src="~/js/writing-workspace.js" asp-append-version="true"></script>
<script src="~/js/writing-workspace-launcher.js" asp-append-version="true"></script>
@if(Model.Destination == "Write"){
<script src="~/js/writer-focus.js" asp-append-version="true"></script>
<script src="~/js/writer-objective.js" asp-append-version="true"></script>
<script src="~/js/writer-work.js" asp-append-version="true"></script>
}

View File

@ -0,0 +1,13 @@
@model WriterDashboardViewModel
@{ var objective = Model.Objective; }
<form asp-action="SaveObjective" method="post" class="writer-objective-form" data-focus-form>
<input type="hidden" name="BookID" value="@Model.BookID" />
<label>What am I doing?<select class="form-select" name="Activity" data-focus-activity>
@foreach(var activity in PlotLine.Services.Writer.WriterFocusActivities.ObjectiveKinds){<option value="@activity" data-session-kind="@PlotLine.Services.Writer.WriterFocusActivities.SessionKind(activity)" selected="@(objective?.Activity==activity)">@activity</option>}
@if(!Model.ActivityIsPrivate){<optgroup label="Session recording only"><option value="Planning" data-session-kind="Planning">Planning</option><option value="Reading" data-session-kind="Reading">Reading review</option><option value="AudioReview" data-session-kind="AudioReview">Audio Review</option></optgroup>}
</select></label>
<label>Which chapter?<select class="form-select" name="ChapterID" data-objective-chapter><option value="">Whole manuscript</option>@foreach(var chapter in Model.ObjectiveChoices.DistinctBy(x=>x.ChapterID)){<option value="@chapter.ChapterID" selected="@(objective?.ChapterID==chapter.ChapterID)">@chapter.ChapterTitle</option>}</select></label>
<label>Which scene? (optional)<select class="form-select" name="SceneID" data-objective-scene><option value="">No scene selected</option>@foreach(var scene in Model.ObjectiveChoices.Where(x=>x.SceneID.HasValue)){<option value="@scene.SceneID" data-chapter="@scene.ChapterID" selected="@(objective?.SceneID==scene.SceneID)">@scene.SceneTitle</option>}</select></label>
<div class="button-row"><button type="submit" class="btn btn-primary" data-save-focus>Save working focus</button>@if(!Model.ActivityIsPrivate){<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>
</form>
<p class="writer3-caption">Saving does not start recording. Planning opens this book’s existing schedule setup; chapter and scene allocations are chosen there. Planning does not save this selection.</p>

View File

@ -1,21 +1,25 @@
@model WriterDashboardViewModel
@{var focus = Model.Objective; var editing = Context.Request.Query["setup"] == "true"; var kind = focus?.Activity is "Revising" or "Editing" or "Proofreading" ? "Editing" : focus?.Activity == "Researching" ? "Planning" : "Writing";}
<div class="writer3-workspace" aria-label="Writing workspace">
<section class="writer3-panel writer3-main" tabindex="0" id="working-focus" aria-label="Current writing focus">
<section class="writer3-panel writer3-main" tabindex="0" id="working-focus" aria-label="Current writing focus" data-writer-focus data-saved-activity="@focus?.Activity" data-saved-session-kind="@PlotLine.Services.Writer.WriterFocusActivities.SessionKind(focus?.Activity)" data-saved-chapter="@focus?.ChapterID" data-book-id="@Model.BookID" data-plan-url="@Url.Action("ScheduleSetup", "Writer", new { bookId = Model.BookID, projectId = Model.ProjectID })">
<p class="eyebrow">Your current work</p>
@if(focus != null && !editing){
<h2>@(focus.SceneTitle ?? focus.ChapterTitle ?? "Your manuscript")</h2><p class="writer3-focus-kind">@focus.Activity</p><p>Return to this saved task. Write manuscript text in Word, and use the chapter or scene tools for your plan and notes.</p>
<h2>@(focus.SceneTitle ?? focus.ChapterTitle ?? "Your manuscript")</h2><p class="writer3-focus-kind">@focus.Activity</p>@if(focus.ChapterID.HasValue){<p class="writer3-caption">Chapter: @focus.ChapterTitle</p>}<p>Return to this saved task. Write manuscript text in Word, and use the chapter or scene tools for your plan and notes.</p>
<div class="button-row">
@if(focus.SceneID.HasValue){<a class="btn btn-primary writer3-cta" asp-controller="Scenes" asp-action="Edit" asp-route-id="@focus.SceneID">Open current scene <span aria-hidden="true">→</span></a>}
else if(focus.ChapterID.HasValue){<a class="btn btn-primary writer3-cta" asp-action="Chapter" asp-route-id="@focus.ChapterID">Open current chapter <span aria-hidden="true">→</span></a>}
else{<a class="btn btn-primary writer3-cta" asp-controller="Books" asp-action="Details" asp-route-id="@Model.BookID" asp-fragment="chapters">Open your chapters <span aria-hidden="true">→</span></a>}
<a asp-action="Write" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID" asp-route-setup="true">Change objective</a>
<a asp-action="Write" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID" asp-route-setup="true">Change working focus</a>
</div>
}else{
<h2>@(editing ? "Choose your working focus" : "Where would you like to begin?")</h2><p>Choose an activity and, if you like, a chapter or scene. You can start without a writing plan.</p>
<div id="objective-setup"><partial name="_ObjectiveForm" model="Model" /></div>
<div id="objective-setup"><partial name="_WriterFocusForm" model="Model" /></div>
}
@if(!Model.ActivityIsPrivate){<partial name="_WriterWorkToolbar" model="new PlotLine.Models.WriterWorkToolbar(Model.BookID!.Value, focus?.ChapterID, focus?.ChapterTitle, Model.ObjectiveChoices, kind)" />}
@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>}
<label data-record-kind-choice hidden>Record proofreading as<select class="form-select" data-record-kind><option value="">Choose a compatible recording activity</option><option value="Editing">Editing</option><option value="Reading">Reading review</option></select></label>
<p class="writer3-caption" data-focus-recording-hint></p><p role="status" data-focus-message></p><p class="writer3-caption" data-focus-session-difference hidden></p>
<div class="writer3-session-block"><h3>Work sessions &amp; Audio Review</h3><partial name="_WriterWorkToolbar" model="new PlotLine.Models.WriterWorkToolbar(Model.BookID!.Value, focus?.ChapterID, focus?.ChapterTitle, Model.ObjectiveChoices, kind, true)" /></div>}
else{<p class="muted">Work-session evidence is private to the book owner. Your chapter and scene tools remain available.</p>}
</section>
<aside class="writer3-panel writer3-reference" tabindex="0" aria-label="Writing tools">

View File

@ -40,3 +40,21 @@
.writer3-shell:has(.writer3-viewport)>main{padding-bottom:0!important}
.writer3-split[data-narrow=true] .writer3-companion-close{display:block}
/* Phase2C: observed wrapping, reading width and utility hierarchy. */
.writer3-path-mark{flex:0 0 2ch;white-space:nowrap;overflow-wrap:normal}
.writer3-explore-paths>a>div{min-width:0}
.writer3-layout-tools{align-items:center}
.writer3-layout-tools .plotline-help-icon-wrapper{margin:0}
.writer3-split[data-collapsed=true]>.writer3-main>*{max-width:80ch}
.writer3-session-block{margin-top:1.4rem;padding-top:1.1rem;border-top:1px solid var(--pd-border-subtle)}
.writer3 .writer3-session-block .writer-work-toolbar{margin:0;padding:.4rem 0 0;border:0}
.writer3 .writer-work-toolbar .muted{max-width:80ch}
.writer3-focus-actions{margin-top:1.1rem}
.writer3 [data-record-kind-choice]{max-width:36ch;margin-top:1rem}
.writer3 [data-focus-message]:empty,.writer3 [data-focus-recording-hint]:empty{display:none}
.writer3-layout-tools .plotline-help-icon{min-height:0}
.writer3-layout-tooltip{pointer-events:none}
.writer3 [data-save-focus]{background:var(--pd-accent);border-color:var(--pd-accent);color:var(--pd-on-accent)!important}
.writer3 [data-save-focus]:hover{background:var(--pd-accent-hover);border-color:var(--pd-accent-hover)}

View File

@ -0,0 +1,21 @@
(() => {
const root=document.querySelector('[data-writer-focus]');if(!root)return;
const form=root.querySelector('[data-focus-form]'),activity=form?.querySelector('[data-focus-activity]'),chapter=form?.querySelector('[data-objective-chapter]');
const record=root.querySelector('[data-record-focus]'),save=form?.querySelector('[data-save-focus]'),choice=root.querySelector('[data-record-kind-choice]'),kindChoice=root.querySelector('[data-record-kind]'),message=root.querySelector('[data-focus-message]'),hint=root.querySelector('[data-focus-recording-hint]');
const objectives=['Drafting','Revising','Editing','Researching','Proofreading'];let active=null,known=false,pending=false,saving=false;
const selection=()=>({activity:activity?.value||root.dataset.savedActivity,chapter:chapter?.value||(!chapter?root.dataset.savedChapter:'')||''});
const kind=()=>(activity?activity.selectedOptions[0]?.dataset.sessionKind:root.dataset.savedSessionKind)||(selection().activity==='Proofreading'?kindChoice?.value:'');
function render(){const s=selection(),k=kind();if(save)save.disabled=saving||!objectives.includes(s.activity);
if(choice)choice.hidden=s.activity!=='Proofreading'||!!active;
if(record){record.hidden=!!active;record.disabled=!known||pending;}
if(hint)hint.textContent=active?'':!objectives.includes(s.activity)?'This activity can be recorded as a session; it cannot be saved as a working objective.':s.activity==='Proofreading'?'Choose Editing or Reading review explicitly to record proofreading.':`Optional recording uses the existing ${k} session type. Saving and planning remain separate.`;
const difference=root.querySelector('[data-focus-session-difference]');if(difference){difference.hidden=!active;difference.textContent=active?`Active recording: ${active.kind} · ${active.chapterTitle||'Whole manuscript'}. ${!root.dataset.savedActivity?'No working focus has been saved. ':String(active.chapterID||'')!==String(root.dataset.savedChapter||'')||root.dataset.savedSessionKind!==active.kind?'This differs from your saved working focus. ':''}Changing or saving focus does not retarget this session.`:'';}
}
root.addEventListener('plotdirector:work-state',e=>{known=true;active=e.detail.session;render();});
root.addEventListener('plotdirector:work-start-finished',()=>{pending=false;render();});
activity?.addEventListener('change',()=>{if(kindChoice)kindChoice.value='';render();});kindChoice?.addEventListener('change',render);
record?.addEventListener('click',()=>{if(active||pending||!known)return;const s=selection(),k=kind();if(!k){message.textContent='Choose a compatible session activity before recording.';kindChoice?.focus();return;}if(k==='AudioReview'&&!s.chapter){message.textContent='Choose a chapter for Audio Review.';chapter?.focus();return;}message.textContent='';pending=true;render();root.querySelector('[data-writer-work]').dispatchEvent(new CustomEvent('plotdirector:record-focus',{detail:{kind:k,chapter:s.chapter}}));});
form?.addEventListener('submit',e=>{if(saving||!objectives.includes(selection().activity)){e.preventDefault();return;}saving=true;render();});
root.querySelector('[data-plan-focus]')?.addEventListener('click',()=>{const url=new URL(root.dataset.planUrl,location.origin);url.searchParams.set('focusActivity',selection().activity);location.assign(url);});
render();
})();

View File

@ -9,7 +9,9 @@
const changed=current?.sessionID!==session?.sessionID;current=session;
root.querySelector('[data-work-current]').hidden=!session;start.hidden=!!session;
root.querySelector('[data-work-audio]').hidden=session?.kind!=='AudioReview';
if(root.dataset.unifiedWork==='true')root.dispatchEvent(new CustomEvent('plotdirector:work-state',{bubbles:true,detail:{session}}));
if(!session)return;
const bound=root.querySelector('[data-work-bound]');if(bound)bound.textContent='Active recording: '+session.kind+' · '+(session.chapterTitle||'Whole manuscript');
root.querySelector('[data-work-end]').textContent=session.kind==='AudioReview'?'End Audio Review & save note':'End session & save note';
root.querySelector('[data-work-label]').textContent=session.kind+' session';
root.querySelector('[data-work-elapsed]').textContent=' · '+Math.max(0,Math.round((Date.now()-new Date(session.startedUtc))/60000))+' minutes elapsed';
@ -26,8 +28,9 @@
}
};
const refresh=async()=>{const response=await fetch('/Writer/Work/State?bookId='+encodeURIComponent(bookId));if(!response.ok)throw Error('Session history is private or temporarily unavailable.');const data=await response.json();render(data.session);if(!data.session)root.querySelector('[data-pause-on-edit]').checked=data.defaultPauseOnEdit;};
if(root.dataset.unifiedWork==='true')root.addEventListener('plotdirector:record-focus',event=>{if(current||busy)return;start.querySelector('[name=kind]').value=event.detail.kind;start.querySelector('[name=chapterId]').value=event.detail.chapter||'';start.requestSubmit();});
start.querySelector('[name=kind]').addEventListener('change',event=>{start.querySelector('button[type=submit]').textContent=event.target.value==='AudioReview'?'Start Audio Review':'Start session';});
start.addEventListener('submit',async event=>{event.preventDefault();if(busy)return;busy=true;try{const data=new FormData(start);const kind=data.get('kind'),chapterId=data.get('chapterId');if(kind==='AudioReview'&&!chapterId)throw Error('Choose a chapter for Audio Review.');const choice=kind+'/'+chapterId;if(lastChoice!==choice){startRequest=null;lastChoice=choice;}startRequest??=crypto.randomUUID();await post('Start',{kind,chapterId:chapterId||'',requestId:startRequest,pauseOnEdit:String(root.querySelector('[data-pause-on-edit]').checked)});startRequest=null;lastInput=Date.now();await refresh();notify('Session started. Leave it open only while you want to record this activity.');}catch(error){notify(error.message);}finally{busy=false;}});
start.addEventListener('submit',async event=>{event.preventDefault();if(busy)return;busy=true;try{const data=new FormData(start);const kind=data.get('kind'),chapterId=data.get('chapterId');if(kind==='AudioReview'&&!chapterId)throw Error('Choose a chapter for Audio Review.');const choice=kind+'/'+chapterId;if(lastChoice!==choice){startRequest=null;lastChoice=choice;}startRequest??=crypto.randomUUID();await post('Start',{kind,chapterId:chapterId||'',requestId:startRequest,pauseOnEdit:String(root.querySelector('[data-pause-on-edit]').checked)});startRequest=null;lastInput=Date.now();await refresh();notify('Session started. Leave it open only while you want to record this activity.');}catch(error){notify(error.message);}finally{busy=false;if(root.dataset.unifiedWork==='true')root.dispatchEvent(new CustomEvent('plotdirector:work-start-finished',{bubbles:true}));}});
root.querySelector('[data-work-end]').addEventListener('click',async()=>{if(!current||busy)return;busy=true;try{await post('End',{sessionId:current.sessionID,note:root.querySelector('[data-work-note]').value});await refresh();notify('Session ended. Your note was saved.');}catch(error){notify(error.message);}finally{busy=false;}});
root.querySelector('[data-pause-on-edit]').addEventListener('change',async event=>{if(!current)return;try{await post('Preference',{sessionId:current.sessionID,pauseOnEdit:String(event.target.checked)});}catch(error){notify(error.message);}});
for(const button of root.querySelectorAll('[data-media-command]'))button.addEventListener('click',async()=>{if(!current||busy)return;busy=true;try{await post('Command',{sessionId:current.sessionID,command:button.dataset.mediaCommand});notify('Command requested; waiting for the selected media session.');}catch(error){notify(error.message);}finally{busy=false;}});

View File

@ -26,7 +26,17 @@
const layoutHelp = document.createElement('button');
layoutHelp.type = 'button'; layoutHelp.className = 'btn btn-sm btn-outline-secondary';
layoutHelp.textContent = 'Layout Help'; layoutHelp.dataset.helpOpen = 'writer3.layout';
toolbar.append(layoutHelp); workspace.before(toolbar);
toolbar.append(layoutHelp);
// Keep the existing Markdown tooltip/popover beside the labelled layout controls.
const layoutArticle = root.querySelector('[data-help-key="writer3.layout"]');
if (layoutArticle) {
toolbar.append(layoutArticle);
layoutArticle.addEventListener('shown.bs.tooltip', event => {
const tip = document.getElementById(event.target.getAttribute('aria-describedby'));
tip?.classList.add('writer3-layout-tooltip');
});
}
workspace.before(toolbar);
companion.id = 'writer3-companion';
const close = document.createElement('button');
close.type = 'button'; close.className = 'writer3-companion-close btn btn-sm btn-outline-secondary';
@ -125,6 +135,7 @@
});
});
divider.addEventListener('keydown', event => {
if (event.altKey || event.ctrlKey || event.metaKey) return; // Preserve browser/OS navigation shortcuts.
const b = bounds(); let size = Math.max(b.min, Math.min(b.max, b.width * preference.width));
const step = event.shiftKey ? 50 : 10;
if (event.key === 'ArrowLeft') size += step;