diff --git a/Docs/WordCompanion/2026-11-08-import-progress-navigation.md b/Docs/WordCompanion/2026-11-08-import-progress-navigation.md index c2e6a38a..0682e59d 100644 --- a/Docs/WordCompanion/2026-11-08-import-progress-navigation.md +++ b/Docs/WordCompanion/2026-11-08-import-progress-navigation.md @@ -24,11 +24,11 @@ A second confirmed navigation defect made the failure look like nothing had star ## Correction — existing components only - The existing global progress model/service now also projects the current authorised unfinished wizard, scan and build state. No new session store, import engine, hub, database table or parallel progress strip. -- The same strip and button area show Word reading, chapter review, scene detection, location/character review, failure or saved setup as appropriate. Both the strip text and action link navigate to the existing matching wizard route/preview. Pending setup is not labelled as running analysis. +- The same strip and button area show Word reading, chapter review, scene detection, location/character review, failure or saved setup as appropriate. The strip text links to the existing matching wizard route/preview; the right-hand **Book** button keeps its original book-details destination. Pending setup is not labelled as running analysis. - Core capture completion alone does not remove the strip: it remains through mandatory review, and disappears when persistent core completion is recorded. Optional Story Intelligence continues to use its existing counts, events and **Book** action independently. - Existing in-memory scene-build progress has a read-only getter and is hydrated on wizard reload. The existing scene-detection button stays disabled while that build is running; re-entry does not launch another build. - While core work exists, the existing authoritative SignalR watcher refreshes its snapshot every 15 seconds on a visible page and on return/reconnect. No extra connection or scanning request is created. -- The normal Import action resumes an unfinished selected-book setup without clearing capture/session/preferences. Explicit creation of a new setup after completed onboarding remains available through the existing flow. +- The normal global and same-book Import actions resume an unfinished selected-book setup without clearing capture/session/preferences. Explicit creation of a new setup after completed onboarding remains available through the existing flow. ## Returning to today's book diff --git a/PlotLine.Tests/Browser/import-progress-navigation.cjs b/PlotLine.Tests/Browser/import-progress-navigation.cjs index 0c07f60b..8b272184 100644 --- a/PlotLine.Tests/Browser/import-progress-navigation.cjs +++ b/PlotLine.Tests/Browser/import-progress-navigation.cjs @@ -1,9 +1,9 @@ const {chromium}=require('playwright'),fs=require('node:fs'),path=require('node:path'),assert=require('node:assert/strict'); (async()=>{const browser=await chromium.launch();try{const page=await browser.newPage();const core={BookID:10,BookTitle:'Fixture',Stage:'Scanning Word',Message:'Reading paragraphs',PercentComplete:42,ResumeUrl:'/onboarding'}; -async function boot(seed){await page.goto('about:blank');await page.setContent(`
`);await page.evaluate(seed=>{const strip=document.querySelector('[data-story-intelligence-global-strip]');strip.dataset.coreImport=JSON.stringify(seed);window.snapshot={coreImport:seed,books:[]};window.calls=[];window.handlers={};window.signalR={HubConnectionBuilder:class{withUrl(){return this;}withAutomaticReconnect(){return this;}build(){return{state:'Connected',on(n,f){handlers[n]=f;},onreconnected(){},onclose(){},start:async()=>{},invoke:async n=>{calls.push(n);return snapshot;}}}}};},seed);await page.addScriptTag({content:fs.readFileSync(path.join(__dirname,'../../PlotLine/wwwroot/js/story-intelligence-global-progress.js'),'utf8')});await page.waitForFunction(()=>calls.includes('WatchGlobalStoryIntelligenceProgress'));} -await boot(core);const strip=page.locator('[data-story-intelligence-global-strip]'),link=page.locator('[data-story-intelligence-global-action]');await page.waitForTimeout(50);assert.equal(await strip.isVisible(),true);assert.match(await strip.innerText(),/Scanning Word/);assert.equal(await link.getAttribute('href'),'/onboarding');assert.equal(await link.innerText(),'Return to import');assert.match(await page.locator('[data-story-intelligence-global-bar]').getAttribute('style'),/42%/); +async function boot(seed){await page.goto('about:blank');await page.setContent(``);await page.evaluate(seed=>{const strip=document.querySelector('[data-story-intelligence-global-strip]');strip.dataset.coreImport=JSON.stringify(seed);window.snapshot={coreImport:seed,books:[]};window.calls=[];window.handlers={};window.signalR={HubConnectionBuilder:class{withUrl(){return this;}withAutomaticReconnect(){return this;}build(){return{state:'Connected',on(n,f){handlers[n]=f;},onreconnected(){},onclose(){},start:async()=>{},invoke:async n=>{calls.push(n);return snapshot;}}}}};},seed);await page.addScriptTag({content:fs.readFileSync(path.join(__dirname,'../../PlotLine/wwwroot/js/story-intelligence-global-progress.js'),'utf8')});await page.waitForFunction(()=>calls.includes('WatchGlobalStoryIntelligenceProgress'));} +await boot(core);const strip=page.locator('[data-story-intelligence-global-strip]'),link=page.locator('[data-story-intelligence-global-link]'),book=page.locator('[data-story-intelligence-global-action]');await page.waitForTimeout(50);assert.equal(await strip.isVisible(),true);assert.match(await strip.innerText(),/Scanning Word/);assert.equal(await link.getAttribute('href'),'/onboarding');assert.equal(await book.innerText(),'Book');assert.equal(await book.getAttribute('href'),'/Books/Details/10');assert.match(await page.locator('[data-story-intelligence-global-bar]').getAttribute('style'),/42%/); await boot(core);assert.equal(await strip.isVisible(),true);assert.equal(await link.getAttribute('href'),'/onboarding'); -await page.evaluate(()=>handlers.StoryIntelligenceGlobalProgressChanged({coreImport:{bookTitle:'Fixture',stage:'Review chapters',message:'Capture saved',resumeUrl:'/onboarding/scan-review?previewId=123'},books:[]}));assert.match(await link.getAttribute('href'),/scan-review\?previewId=123/);assert.match(await strip.innerText(),/Review chapters/); +await page.evaluate(()=>handlers.StoryIntelligenceGlobalProgressChanged({coreImport:{bookID:10,bookTitle:'Fixture',stage:'Review chapters',message:'Capture saved',resumeUrl:'/onboarding/scan-review?previewId=123'},books:[]}));assert.match(await link.getAttribute('href'),/scan-review\?previewId=123/);assert.match(await strip.innerText(),/Review chapters/); await page.evaluate(()=>handlers.StoryIntelligenceGlobalProgressChanged({coreImport:null,books:[]}));assert.equal(await strip.isVisible(),false); -await page.evaluate(()=>handlers.StoryIntelligenceGlobalProgressChanged({coreImport:null,books:[{bookID:10,projectID:9,bookTitle:'Fixture',status:'Pending',pendingRunCount:1,hasActiveRuns:true,totalExpectedScenes:4,completedScenes:0,updatedUtc:new Date().toISOString()}],hasActiveWork:true,activeBookCount:1,status:'Running',totalExpectedScenes:4,completedScenes:0}));assert.equal(await strip.isVisible(),true);assert.equal(await link.getAttribute('href'),'/Books/Details/10');assert.equal(await link.innerText(),'Book'); +await page.evaluate(()=>handlers.StoryIntelligenceGlobalProgressChanged({coreImport:null,books:[{bookID:10,projectID:9,bookTitle:'Fixture',status:'Pending',pendingRunCount:1,hasActiveRuns:true,totalExpectedScenes:4,completedScenes:0,updatedUtc:new Date().toISOString()}],hasActiveWork:true,activeBookCount:1,status:'Running',totalExpectedScenes:4,completedScenes:0}));assert.equal(await strip.isVisible(),true);assert.equal(await link.getAttribute('href'),'/Books/Details/10');assert.equal(await book.innerText(),'Book'); assert.equal(await page.evaluate(()=>calls.some(n=>/Start|Scan|Build/.test(n))),false);console.log('PASS existing global strip: Word scan visibility, recreated-page restore, exact review navigation, core completion hiding, independent optional AI Book link, and watch-only requests');}finally{await browser.close();}})().catch(e=>{console.error(e);process.exit(1);}); diff --git a/PlotLine.Tests/ImportProgressNavigationTests.cs b/PlotLine.Tests/ImportProgressNavigationTests.cs index 35c337a7..8e0bf4dc 100644 --- a/PlotLine.Tests/ImportProgressNavigationTests.cs +++ b/PlotLine.Tests/ImportProgressNavigationTests.cs @@ -35,9 +35,9 @@ internal static class ImportProgressNavigationTests var started=await scans.StartAsync(7,8,9,10);await scans.ProgressAsync(7,new(){OnboardingID=8,Message="Reading paragraphs",PercentComplete=42}); var first=await Progress().GetForCurrentUserAsync();var second=await Progress().GetForCurrentUserAsync(); Check(first.HasActiveWork&&first.CoreImport?.Stage=="Scanning Word"&&second.CoreImport?.PercentComplete==42&&(await scans.GetStateAsync(7,8)).ScanID==started.ScanID,"navigation away and refresh keep the same running Word scan and expose it through existing global progress"); - var ctor=typeof(OnboardingService).GetConstructors().Single();var deps=new Dictionary