From 62fa292f818073ca2cded067ed286c93a4663e48 Mon Sep 17 00:00:00 2001 From: Nick Beckley Date: Tue, 17 Nov 2026 14:57:56 +0000 Subject: [PATCH] Preserve Explore selection and authenticated tools throughout investigation navigation --- PlotLine.Tests/Browser/writer3-investigations.cjs | 2 +- PlotLine/Services/WriterNavigation.cs | 4 ++-- PlotLine/Views/Shared/_ApplicationNavigation.cshtml | 2 +- PlotLine/Views/Shared/_ApplicationShell.cshtml | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/PlotLine.Tests/Browser/writer3-investigations.cjs b/PlotLine.Tests/Browser/writer3-investigations.cjs index 48cf8614..7336fb26 100644 --- a/PlotLine.Tests/Browser/writer3-investigations.cjs +++ b/PlotLine.Tests/Browser/writer3-investigations.cjs @@ -2,7 +2,7 @@ const {chromium}=require('playwright'),assert=require('node:assert/strict'),fs=r const base=process.env.PD_INV_BASE||'http://127.0.0.1:5238',identity=process.env.PD_INV_IDENTITY?JSON.parse(fs.readFileSync(process.env.PD_INV_IDENTITY)):null,w=identity||{UserID:4,book:12,other:13,project:7}; const report=JSON.parse(fs.readFileSync(process.env.PD_INV_COVERAGE||'Docs/Writer/Writer3/Evidence/Phase3D1/simulation.json'));const path=report.RepresentativePaths.find(p=>p.concern==='story'&&p.target==='motivation'&&p.recommendations.includes('motivation'));assert(path,'unexpected destination witness'); (async()=>{const browser=await chromium.launch();try{for(const pwa of[false,true]){const c=await browser.newContext({viewport:{width:1440,height:1000}});await c.addInitScript(({user,pwa})=>{localStorage.setItem('plotdirector.desktop.v1.'+user,JSON.stringify({dismissedAt:Date.now()}));if(pwa)Object.defineProperty(navigator,'standalone',{value:true});},{user:w.UserID,pwa});const p=await c.newPage(),errors=[],external=[];p.on('pageerror',e=>errors.push(e.message));p.on('request',r=>{if(/openai|anthropic|generativelanguage|inference/i.test(r.url()))external.push(r.url());});if(identity){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()]);} -await p.goto(`${base}/Writer/Explore?projectId=${w.project}&bookId=${w.book}`);await p.getByRole('link',{name:'Explore a concern',exact:true}).click();assert((await p.locator('#investigation-question').textContent()).includes("What's troubling"));assert.equal(await p.locator('iframe').count(),0);assert((await p.locator('[data-ribbon-shell]').textContent()).includes('Explore'));if(process.env.PD_INV_SCREENSHOTS&&!pwa){fs.mkdirSync(process.env.PD_INV_SCREENSHOTS,{recursive:true});await p.screenshot({path:process.env.PD_INV_SCREENSHOTS+'/Explore-investigation-start.png'});} +await p.goto(`${base}/Writer/Explore?projectId=${w.project}&bookId=${w.book}`);await p.getByRole('link',{name:'Explore a concern',exact:true}).click();assert((await p.locator('#investigation-question').textContent()).includes("What's troubling"));assert.equal(await p.locator('iframe').count(),0);assert((await p.locator('#ribbon-panel-writer a[aria-current=page]').allTextContents()).some(t=>t.trim()==='Explore'));assert.equal(await p.locator('#ribbon-panel-writer a[href*="writing-problems"]').count(),0);if(process.env.PD_INV_SCREENSHOTS&&!pwa){fs.mkdirSync(process.env.PD_INV_SCREENSHOTS,{recursive:true});await p.screenshot({path:process.env.PD_INV_SCREENSHOTS+'/Explore-investigation-start.png'});} await p.locator('[name=concern][value=story]').check();await p.getByRole('button',{name:'Begin',exact:true}).click();await p.locator('[data-investigation-answer]').waitFor();const id=new URL(p.url()).searchParams.get('id'),url=p.url();const explanation=p.locator('#investigation-explanation');await explanation.fill('Unfinished explanation retained for later');await p.getByRole('button',{name:'Save for later',exact:true}).click();assert.equal(await p.locator('#investigation-explanation').inputValue(),'Unfinished explanation retained for later'); let firstQuestion;for(const entry of path.answers){const form=p.locator('[data-investigation-answer]');if(!await form.count())break;const current=await form.locator('[name=question]').inputValue();firstQuestion??=current;const expected=path.answers.find(x=>x.startsWith(current+'='));assert(expected,'dynamic current question is in deterministic witness');await form.locator(`[name=option][value="${expected.split('=')[1]}"]`).check();await form.locator('[name=explanation]').fill('Synthetic browser answer ');await form.locator('button[value=answer]').click();} assert.equal(await p.locator('[data-investigation-answer]').count(),0);assert((await p.locator('#investigation-question').textContent()).includes('possible next step'));assert((await p.locator('body').textContent()).includes('Character'));assert.equal(external.length,0);const open=p.locator('form[action$="/Open"]').first();const formData=await open.evaluate(f=>Object.fromEntries(new FormData(f)));formData.capability=await open.locator('[name=capability]').getAttribute('value');const destination=await p.request.post(base+'/Writer/Explore/Investigate/Open',{form:formData,maxRedirects:0});assert.equal(destination.status(),302);assert(!destination.headers().location.toLowerCase().includes('solver'));assert(destination.headers().location.includes('projectId='+w.project));assert(destination.headers().location.includes('bookId='+w.book));await p.reload(); diff --git a/PlotLine/Services/WriterNavigation.cs b/PlotLine/Services/WriterNavigation.cs index 77cd9546..bf9f70af 100644 --- a/PlotLine/Services/WriterNavigation.cs +++ b/PlotLine/Services/WriterNavigation.cs @@ -22,7 +22,7 @@ public static class WriterNavigation "Dashboard" => "Your plans, manuscript and recorded progress at a glance.", _ => "Choose where you would like to begin today." }; - public static IReadOnlyList RibbonGroups(string destination) + public static IReadOnlyList RibbonGroups(string destination,bool investigation=false) { var groups = new List { @@ -36,7 +36,7 @@ public static class WriterNavigation var context = destination switch { "Write" => new RibbonGroup("Current work", new("Chapters","bible","Books","Details","book"), new("Writing desk","writer","Writer","Overview","writerBook"), new("Writing Plan","calendar","Writer","WritingPlans","writerBook")), - "Explore" => new RibbonGroup("Story exploration", new("Problem Solver","point","WritingProblems","Index","global"), new("Story overview","timeline","Timeline","Index","writerBook")), + "Explore" => new RibbonGroup("Story exploration", investigation ? new("Guided investigation","point","WriterInvestigations","Index","writerBook") : new("Problem Solver","point","WritingProblems","Index","global"), new("Story overview","timeline","Timeline","Index","writerBook")), "Plan" => new RibbonGroup("Writing plans", new("Writing Plan","calendar","Writer","WritingPlans","writerBook"), new("Schedule Preview","calendar","Writer","SchedulePreview","writerBook")), "Review" => new RibbonGroup("Reading & review", new("Manuscript Reader","bible","ManuscriptReader","Index","writerBook"), new("Writing desk","writer","Writer","Overview","writerBook")), "Reflect" => new RibbonGroup("Writing history", new("Writing Journey","calendar","Writer","Journey","writerBook"), new("Reports","metrics","WritingActivity","Index","writerBook",OwnerOnly:true)), diff --git a/PlotLine/Views/Shared/_ApplicationNavigation.cshtml b/PlotLine/Views/Shared/_ApplicationNavigation.cshtml index 0c70477d..6eab4bdb 100644 --- a/PlotLine/Views/Shared/_ApplicationNavigation.cshtml +++ b/PlotLine/Views/Shared/_ApplicationNavigation.cshtml @@ -64,7 +64,7 @@
  • @foreach (var choice in Model.Books) { -
  • Book @choice.BookNumber: @choice.BookDisplayTitle
  • +
  • Book @choice.BookNumber: @choice.BookDisplayTitle
  • } @if (Model.Books.Count == 0) { diff --git a/PlotLine/Views/Shared/_ApplicationShell.cshtml b/PlotLine/Views/Shared/_ApplicationShell.cshtml index 0bd6a915..6c082169 100644 --- a/PlotLine/Views/Shared/_ApplicationShell.cshtml +++ b/PlotLine/Views/Shared/_ApplicationShell.cshtml @@ -130,7 +130,7 @@ @foreach (var category in ApplicationRibbon.Categories) {