diff --git a/Docs/WordCompanion/2026-11-08-import-progress-navigation.md b/Docs/WordCompanion/2026-11-08-import-progress-navigation.md new file mode 100644 index 00000000..c2e6a38a --- /dev/null +++ b/Docs/WordCompanion/2026-11-08-import-progress-navigation.md @@ -0,0 +1,43 @@ +# Existing import progress and resume regression — 8 November 2026 + +## Today's actual import (read-only investigation) + +Project **8174**, book **10152**, **The Alpha Flame**. All times below are London/GMT. + +The Development access log records: + +- 18:10:15 — start import; writing software/project selected; book saved at 18:11:00. +- **18:39:06 — Word capture POST returned HTTP 403**, followed immediately by the existing client's request-cleanup DELETE, which returned 200. +- 18:49:25 and 18:56:10 — the normal `POST /onboarding/start-import` action was used again. The old implementation cleared scan state and software selection instead of resuming. +- 18:56:13–14 — Back actions left the saved wizard at **Welcome**. + +Before any changes/deployment, the database had **zero accepted captures, zero manuscript builds and no Story Intelligence jobs/runs**. Book 10152 has not completed import or scene detection. The prior transfer **failed**, rather than continuing in the background. Its intermediate reading/chapter-discovery progress is not recoverable from an accepted server snapshot. The source Word document was not changed by this investigation. No scan, import or analysis was restarted, cancelled, reset or duplicated by Atlas. + +The precise 403 validation reason was not logged. The existing native capture request has a fixed 20-minute lifetime; elapsed time from book selection to submission was approximately 28 minutes, making expiry a plausible cause, not a proven diagnosis. User/project/document/session/grant checks can also reject submission. This navigation correction does not weaken those checks, claim to recover the rejected payload or silently retry it. + +## Why the bar disappeared + +The strip with the right-hand **Book** button still existed in `_Layout.cshtml`, `StoryIntelligenceGlobalProgressService` and `story-intelligence-global-progress.js`. Its discovery/visibility logic queried only active Story Intelligence run summaries. Word scanning and core chapter/scene review do not create those run records, so the strip was hidden during that earlier phase. Recent migrations **242/243 did not remove it**; today's onboarding completion timestamp was null. The former long-running analysis strip and the early Word capture stage were different states in the existing flow. + +A second confirmed navigation defect made the failure look like nothing had started: the Projects/ribbon **Import a manuscript** action called `StartManuscriptImportSetupAsync`, which unconditionally cleared the existing scan and reset setup. Access history confirms that reset action was invoked after the failed submission. + +## 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. +- 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. + +## Returning to today's book + +`https://dev.plotdirector.com/onboarding` opens the existing saved setup. **For this attempt it is Welcome**, not the lost scan progress screen. There is no accepted capture to link to chapter review. The change prevents another navigation reset and restores visibility/resume for future in-flight stages; it does not manufacture missing progress or automatically restart the failed transfer. Project/book selection is retained. + +## Verification + +Focused managed regressions use the real existing scan store and durable-capture interface: navigation/refresh retain the same ScanID; Import never invokes Clear; accepted capture reload restores its exact review preview; running scene detection and required location/character review remain discoverable; genuine core completion removes core progress; optional analysis retains the original Book link; revoked permission hides stale book information. + +Browser regression exercises the actual shared progress script with its existing SignalR watcher, recreated-page restore, correct links and core-to-optional transition, and asserts that no Start/Scan/Build request is invoked by progress navigation. Existing native import connectivity tests are retained. + +Deployment evidence is appended after rollout. The failed transfer was already cleaned up before this task; service replacement is permitted only after checking that no new import or running job has started. diff --git a/PlotLine.Tests/Browser/import-progress-navigation.cjs b/PlotLine.Tests/Browser/import-progress-navigation.cjs new file mode 100644 index 00000000..0c07f60b --- /dev/null +++ b/PlotLine.Tests/Browser/import-progress-navigation.cjs @@ -0,0 +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%/); +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: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'); +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 new file mode 100644 index 00000000..35c337a7 --- /dev/null +++ b/PlotLine.Tests/ImportProgressNavigationTests.cs @@ -0,0 +1,56 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging.Abstractions; +using PlotLine.Data; +using PlotLine.Models; +using PlotLine.Services; +internal static class ImportProgressNavigationTests +{ + private sealed class Capture : IManuscriptCaptureRepository + { + public ManuscriptScanPreview? Saved;public int Clears; + public Task Save(ManuscriptScanPreview p){Saved=p;return Task.CompletedTask;} + public Task@(ViewData["NativeCapture"] is true ? "Once your manuscript has been received, scene detection runs on PlotDirector’s server. You may close Word. Native Companion imports do not write scene markers to Word." : "Keep Word open while PlotDirector detects scenes and writes the scene markers.")
-Detecting scenes
- +