diff --git a/Docs/Codex/CharacterAttributes.md b/Docs/Codex/CharacterAttributes.md index 2711c3df..1a0e1859 100644 --- a/Docs/Codex/CharacterAttributes.md +++ b/Docs/Codex/CharacterAttributes.md @@ -25,7 +25,7 @@ The directory retains its existing `CharacterCardLayout.ColumnSpan`, full `Defau | Deceased | attribute-flower | data-5 (existing purple theme palette) | | Male (canonical system value) | sex-male (Mars) | info | | Female (canonical system value) | sex-female (Venus) | data-7 (theme rose) | -| Other / custom / recorded legacy sex | sex-other (combined Venus/Mars) | data-5 | +| Other / custom / unrecognised recorded legacy sex | sex-other (combined Venus/Mars) | data-5 | | Quick Add included | attribute-pin | primary | | Quick Add excluded | attribute-unpin | secondary | @@ -74,3 +74,5 @@ The Character Editor concurrency version is sent explicitly as Dapper `DbType.Da Shared group order is Story importance, Life status, Sex, Character Type, Quick Add Bar, on the sidebar, cards and attribute menus. Filled and half-filled stars use the shared ribbon icon `Filled` metadata with compound even-odd SVG geometry; the remaining star is outlined. The same presentation metadata reaches directory icons and the existing context-menu icon catalogue. Custom Sex values retain their IDs and labels; they use the combined symbol without inferring Male/Female from arbitrary labels. Legacy recorded sex uses the shared fallback rather than another group's icon by position. Attribute gold/blue/neutral use existing `--pd-warning`, `--pd-info`, `--pd-muted`. Rose/purple data tones mix with theme text for contrast in light/dark palettes; no new hardcoded colour catalogue or wider icon migration is introduced. + +Recorded Male/Female text without a SexValueID uses exact trimmed, case-insensitive matching metadata from the system catalogue definitions. It shares Mars/Venus icons, blue/rose tones, filters/counts and current-value menu ticks with catalogue-backed values. No record is rewritten or inferred. Other/custom legacy labels remain recorded, with the combined symbol. Female uses the theme rose data tone directly (or a danger/character-tone rose blend) to retain its pink hue. diff --git a/Docs/Codex/NamesWorkspace.md b/Docs/Codex/NamesWorkspace.md index 7324081d..130c0189 100644 --- a/Docs/Codex/NamesWorkspace.md +++ b/Docs/Codex/NamesWorkspace.md @@ -44,3 +44,5 @@ Sort codes are `suggested`, `name-asc`, `name-desc`, `common-desc`, `common-asc` Migration 334 is required by the existing stored-procedure pagination architecture: sorting only a fetched page would be incorrect, and loading the whole catalogue to sort in application code would regress performance. It adds one optional, validated sort parameter to `GivenName_Search`; earlier numbered migrations remain immutable. No name-matching, occurrence retrieval, AI, allowance, character-data or catalogue-data migration is involved. Main details links contain no separate-window or Context bridge attributes. The Context controller explicitly opts its shared details model into those attributes. State includes the actual application/pane scroll host, not merely window scroll, and cached-history returns refresh through the existing workspace without replacing Context or changing manuscript focus. + +The main Names page mounts the existing `PlotDirectorWorkspaceSurface.split` divider for results/details. Its independent user-scoped local workspace preference survives refresh, navigation and PWA restart. Pointer/keyboard resizing changes only grid sizing; it does not call the search/verification lifecycle. Displayed widths are bounded by the available space without saving viewport clamps. The existing container breakpoint and Context pane architecture are unchanged. diff --git a/Docs/Codex/WorkspaceDividers.md b/Docs/Codex/WorkspaceDividers.md new file mode 100644 index 00000000..dc2d185b --- /dev/null +++ b/Docs/Codex/WorkspaceDividers.md @@ -0,0 +1,9 @@ +# Workspace dividers + +`workspace-surface.js` owns editor and management-panel resizing. `PlotDirectorWorkspaceSurface.split(root, options)` uses the same pointer capture, keyboard interaction, `.pd-panel-divider` styling and `plotdirector.workspace.panels.*` local preferences as the existing Maps, Relationships and Floor Plans panels. Its returned `dispose()` disconnects observers/listeners. Context's separate split-pane lifecycle is unchanged. + +Main Characters uses `characters.` (224–480px, 256px default, at least 320px for cards). Main Names uses `names.` (at least 280px results, 320px details, initial existing 1:0.8 proportions). The preference stores the author's chosen pixel width; window/container changes constrain only the displayed width and never save a temporary clamp. Keys are independent and persist across visits, refresh and installed-PWA restart in the same browser profile. They do not synchronise devices. + +Drag the visible gutter, use Left/Right (10px), Shift+Left/Right (40px), or Home/double-click to reset. Separators expose orientation, label and current/minimum/maximum width. Pointer capture and resize cursor/text-selection protection end on pointer up/cancel/lost capture. The handle does not accept HTML drag sources or intercept card/attribute drag targets. + +Characters retains its collapsed and narrow stacked modes, sticky sidebar and independent sidebar scrolling. Names retains its existing container breakpoint and narrow details/Back mode. Only main Names mounts this divider; Context does not. Resizing changes grid sizing only, without search, textual/AI requests, state reset or shared-focus changes. No database migration or new preference service is involved. diff --git a/PlotLine.Tests/Browser/character-attribute-icons.cjs b/PlotLine.Tests/Browser/character-attribute-icons.cjs index 071de2ca..bf1bcb34 100644 --- a/PlotLine.Tests/Browser/character-attribute-icons.cjs +++ b/PlotLine.Tests/Browser/character-attribute-icons.cjs @@ -1,8 +1,10 @@ const {chromium}=require('playwright'),assert=require('assert/strict'),fs=require('fs'),os=require('os'),path=require('path'); (async()=>{const installed=process.argv.includes('--installed'),base='http://127.0.0.1:5238',profile=installed?fs.mkdtempSync(path.join(os.tmpdir(),'pd-icons-pwa-')):null,b=installed?null:await chromium.launch(),c=installed?await chromium.launchPersistentContext(profile,{headless:false,viewport:{width:1920,height:1200}}):await b.newContext({viewport:{width:1920,height:1200}});let p=installed?c.pages()[0]:await c.newPage(),cdp;try{ if(installed){await p.goto(base+'/fixture?page=calendar-test');cdp=await c.browser().newBrowserCDPSession();await cdp.send('PWA.install',{manifestId:base+'/Projects',installUrlOrBundleUrl:p.url()});await cdp.send('PWA.changeAppUserSettings',{manifestId:base+'/Projects',displayMode:'standalone'});const opened=c.waitForEvent('page');await cdp.send('PWA.launch',{manifestId:base+'/Projects',url:p.url()});p=await opened;await p.waitForLoadState();assert(await p.evaluate(()=>matchMedia('(display-mode: standalone)').matches));} - const groups=await (await p.request.get(base+'/character-attribute-definitions-fixture')).json(),records=Array.from({length:48},(_,i)=>({id:i+1,name:`Fixture character ${i+1}`,version:'v1',values:{importance:['10','6','2',''][i%4],life:'',sex:['1','2','3','','legacy:Recorded legacy sex'][i%5],type:'unclassified',quickAdd:'0'}}));await p.route('**/CharacterAttributes/Directory?*',r=>r.fulfill({json:{canEdit:true,groups,characters:records}}));await p.goto(base+'/character-attributes-fixture?count=48');await p.locator('[data-attribute-indicators] svg').first().waitFor();assert.deepEqual(await p.locator('[data-attribute-groups] summary').allTextContents(),['Story importance','Life status','Sex','Character Type','Quick Add Bar']); + const groups=await (await p.request.get(base+'/character-attribute-definitions-fixture')).json(),records=Array.from({length:48},(_,i)=>({id:i+1,name:`Fixture character ${i+1}`,version:'v1',values:{importance:['10','6','2',''][i%4],life:'',sex:['1','2','3','','legacy:Recorded legacy sex','legacy:Male','legacy:Female','legacy: female '][i%8],type:'unclassified',quickAdd:'0'}}));await p.route('**/CharacterAttributes/Directory?*',r=>r.fulfill({json:{canEdit:true,groups,characters:records}}));await p.goto(base+'/character-attributes-fixture?count=48');await p.locator('[data-attribute-indicators] svg').first().waitFor();assert.deepEqual(await p.locator('[data-attribute-groups] summary').allTextContents(),['Story importance','Life status','Sex','Character Type','Quick Add Bar']); assert.equal(await p.locator('[data-attribute="importance"][data-value="10"] path').getAttribute('fill'),'currentColor');assert.equal(await p.locator('[data-attribute="importance"][data-value="6"] path').getAttribute('fill-rule'),'evenodd');assert.equal(await p.locator('[data-attribute="importance"][data-value="2"] path').getAttribute('fill'),'none'); + const male=p.locator('.character-card[data-drag-id="6"] [title="Sex: Male"]'),female=p.locator('.character-card[data-drag-id="7"] [title="Sex: Female"]');assert.equal(await male.locator('path').getAttribute('d'),groups.find(g=>g.id==='sex').values.find(v=>v.label==='Male').path);assert.equal(await female.locator('path').getAttribute('d'),groups.find(g=>g.id==='sex').values.find(v=>v.label==='Female').path);assert.equal(await p.locator('.character-card[data-drag-id="8"] [title="Sex: Female"]').count(),1);assert(await male.locator('svg').evaluate(n=>n.classList.contains('text-info')));assert(await female.locator('svg').evaluate(n=>n.classList.contains('text-data-7')));const maleFilter=p.locator('[data-attribute="sex"][data-value="1"] button').first();await maleFilter.click();assert(await p.locator('.character-card[data-drag-id="6"]').isVisible());assert(await p.locator('.character-card[data-drag-id="7"]').isHidden());await maleFilter.click(); + await p.locator('.character-card[data-drag-id="7"]').scrollIntoViewIfNeeded();await p.evaluate(()=>getSelection()?.removeAllRanges());await p.locator('.character-card[data-drag-id="7"]').click({button:'right'});await p.getByRole('menuitem',{name:'Sex',exact:true}).hover();assert.equal(await p.getByRole('menuitemradio',{name:'Female',exact:true}).getAttribute('aria-checked'),'true');assert.equal(await p.getByRole('menuitemradio',{name:'Male',exact:true}).getAttribute('aria-checked'),'false');await p.keyboard.press('Escape');await p.evaluate(()=>scrollTo({top:0,behavior:'instant'})); const out='/tmp/pd-ui-refinements';fs.mkdirSync(out,{recursive:true});const contrast=[]; for(const theme of ['plotdirector','modern-light','modern-dark','warm-light','warm-dark','rose-pink','baby-blue']){await p.evaluate(theme=>{document.documentElement.dataset.appTheme=theme;document.documentElement.dataset.bsTheme=theme.endsWith('dark')?'dark':'light';document.documentElement.dataset.theme=theme.endsWith('dark')?'dark':'light';},theme);const ratios=await p.evaluate(()=>{const canvas=document.createElement('canvas');canvas.width=canvas.height=1;const context=canvas.getContext('2d');function luminance(color){context.clearRect(0,0,1,1);context.fillStyle=color;context.fillRect(0,0,1,1);const rgb=[...context.getImageData(0,0,1,1).data].slice(0,3).map(x=>x/255).map(x=>x<=.04045?x/12.92:((x+.055)/1.055)**2.4);return .2126*rgb[0]+.7152*rgb[1]+.0722*rgb[2];}const bg=luminance(getComputedStyle(document.querySelector('[data-attribute-sidebar]')).backgroundColor);return [...document.querySelectorAll('[data-attribute="importance"] svg,[data-attribute="sex"] svg')].map(svg=>{const fg=luminance(getComputedStyle(svg).color);return (Math.max(fg,bg)+.05)/(Math.min(fg,bg)+.05)});});assert(ratios.every(x=>x>=3),theme+' icon contrast '+ratios);contrast.push({theme,minimumIconContrast:Math.min(...ratios)});for(const button of await p.getByRole('button',{name:/Dismiss .* notification/}).all())await button.click().catch(()=>{});await p.screenshot({path:`${out}/icons-${installed?'pwa':'browser'}-${theme}.png`});} const card=p.locator('.character-card').first(),box=await card.boundingBox();await card.click({button:'right',position:{x:box.width-8,y:box.height-8}});const menus=await p.getByRole('menuitem').allTextContents();assert(menus.indexOf('Story importance')n.getBoundingClientRect().widthg.id==='type')){ await forward('type','person',1);await page.waitForFunction(()=>document.querySelector('.character-card[data-drag-id="1"] [title="Character Type: Person"]')); await reverse(2,'type','artificial');await page.waitForFunction(()=>document.querySelector('.character-card[data-drag-id="2"] [title="Character Type: Artificial being"]')); diff --git a/PlotLine.Tests/Browser/character-ribbon.cjs b/PlotLine.Tests/Browser/character-ribbon.cjs index 196c5d4c..44abbf03 100644 --- a/PlotLine.Tests/Browser/character-ribbon.cjs +++ b/PlotLine.Tests/Browser/character-ribbon.cjs @@ -3,7 +3,7 @@ const {chromium}=require('playwright'),assert=require('assert/strict'),fs=requir await c.route('https://cdn.jsdelivr.net/**',r=>r.fulfill({contentType:'application/javascript',body:fs.readFileSync(path.join(__dirname,'node_modules',r.request().url().includes('chart.umd')?'chart.js/dist/chart.umd.js':'@microsoft/signalr/dist/browser/signalr.min.js'))})); if(installed){await p.goto(base+'/fixture?page=calendar-test');cdp=await c.browser().newBrowserCDPSession();await cdp.send('PWA.install',{manifestId:base+'/Projects',installUrlOrBundleUrl:p.url()});await cdp.send('PWA.changeAppUserSettings',{manifestId:base+'/Projects',displayMode:'standalone'});const opened=c.waitForEvent('page');await cdp.send('PWA.launch',{manifestId:base+'/Projects',url:p.url()});p=await opened;await p.waitForLoadState();assert(await p.evaluate(()=>matchMedia('(display-mode: standalone)').matches));} const errors=[];p.on('pageerror',e=>errors.push(e.message));let archivePosts=0;await p.route('**/Characters/Archive',r=>{archivePosts++;return r.fulfill({contentType:'text/html',body:'

Disposable archive endpoint

'})}); - for(const tab of ['overview','relationships','evolution','appearances','knowledge']){await p.goto(base+'/character-workspace-fixture?tab='+tab);await p.setViewportSize({width:1920,height:1080});const group=p.locator('[data-character-ribbon]');assert.deepEqual((await group.locator('.pd-ribbon-command span').allTextContents()).filter(text=>text!=='More'),['Edit Character','Merge Character','Reanalyse Biography','Archive Character']);assert.match(await group.getByRole('link',{name:'Merge Character',exact:true}).getAttribute('href'),/Characters\/Merge\/5/);assert.match(await group.locator('[data-character-reanalyse-form]').getAttribute('action'),/Characters\/Reanalyse/);assert.equal(await group.locator('[data-character-reanalyse-button] svg').count(),1);await p.getByRole('button',{name:'Export',exact:true}).click();const menu=p.locator('[data-character-actions-for="5"]');await menu.waitFor({state:'visible'});assert.deepEqual(await menu.locator('.dropdown-item').allTextContents(),['Export character','Markdown']);assert.equal(await menu.locator('form').count(),0);await p.keyboard.press('Escape');} + for(const tab of ['overview','relationships','evolution','appearances','knowledge']){await p.goto(base+'/character-workspace-fixture?tab='+tab);await p.setViewportSize({width:1920,height:1080});const group=p.locator('[data-character-ribbon]');assert.deepEqual((await group.locator('.pd-ribbon-command span').allTextContents()).filter(text=>text!=='More'),['Edit Character','Merge Character','Reanalyse Biography','Archive Character']);assert.deepEqual(await p.locator('#ribbon-panel-characters > .pd-ribbon-group').evaluateAll(nodes=>nodes.map(n=>n.getAttribute('aria-label'))),['Cast','Connections','Selected character','Output','Focus']);assert.match(await group.getByRole('link',{name:'Merge Character',exact:true}).getAttribute('href'),/Characters\/Merge\/5/);assert.match(await group.locator('[data-character-reanalyse-form]').getAttribute('action'),/Characters\/Reanalyse/);assert.equal(await group.locator('[data-character-reanalyse-button] svg').count(),1);await p.getByRole('button',{name:'Export',exact:true}).click();const menu=p.locator('[data-character-actions-for="5"]');await menu.waitFor({state:'visible'});assert.deepEqual(await menu.locator('.dropdown-item').allTextContents(),['Export character','Markdown']);assert.equal(await menu.locator('form').count(),0);await p.keyboard.press('Escape');} await p.locator('[data-character-ribbon] form[action*=Archive] button').click();await p.locator('#plotlineConfirmModal.show').waitFor();assert((await p.locator('[data-character-ribbon] form[action*=Archive]').getAttribute('data-confirm-message')).includes('data will be retained for restoration'));assert((await p.locator('#plotlineConfirmModal').innerText()).toLowerCase().includes('archiv'));assert.equal(archivePosts,0);await p.locator('#plotlineConfirmModal').getByRole('button',{name:'Cancel',exact:true}).last().click();await p.locator('#plotlineConfirmModal').waitFor({state:'hidden'});assert.equal(archivePosts,0); const out='/tmp/pd-ui-refinements';fs.mkdirSync(out,{recursive:true});for(const theme of ['plotdirector','modern-light','modern-dark','warm-light','warm-dark','rose-pink','baby-blue']){await p.evaluate(theme=>{document.documentElement.dataset.appTheme=theme;document.documentElement.dataset.bsTheme=theme.endsWith('dark')?'dark':'light';document.documentElement.dataset.theme=theme.endsWith('dark')?'dark':'light';},theme);await p.screenshot({path:`${out}/ribbon-${installed?'pwa':'browser'}-${theme}.png`});} for(const width of [1280,1920,2560,3840,768,390]){await p.setViewportSize({width,height:1080});await p.getByRole('button',{name:'Export',exact:true}).click();await p.locator('[data-character-actions-for="5"]').waitFor({state:'visible'});assert(await p.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+2));await p.keyboard.press('Escape');} diff --git a/PlotLine.Tests/Browser/context-names.cjs b/PlotLine.Tests/Browser/context-names.cjs index f6f71489..0148f710 100644 --- a/PlotLine.Tests/Browser/context-names.cjs +++ b/PlotLine.Tests/Browser/context-names.cjs @@ -6,7 +6,7 @@ const {chromium}=require('playwright'),assert=require('node:assert/strict'),fs=r await context.route('**/Writing/Context/Tabs/*',async r=>{const u=new URL(r.request().url());await r.fulfill({response:await r.fetch({url:base+'/context-tab-fixture/'+u.pathname.split('/').at(-1)+u.search})});}); const queries=[];await context.route('**/Writing/Context/Names/*',async r=>{const u=new URL(r.request().url()),part=u.pathname.split('/').at(-1).toLowerCase();queries.push({part,params:u.searchParams});await r.fulfill({response:await r.fetch({url:base+'/names-workspace-fixture/'+(part==='search'?'results':part)+u.search})});}); let page;if(installed){await persistent.pages()[0].goto(base+'/fixture?page=calendar-test');await cdp.send('PWA.install',{manifestId,installUrlOrBundleUrl:base+'/fixture?page=calendar-test'});await cdp.send('PWA.changeAppUserSettings',{manifestId,displayMode:'standalone'});const opened=persistent.waitForEvent('page');await cdp.send('PWA.launch',{manifestId,url:base+'/fixture?page=calendar-test'});page=await opened;await page.waitForLoadState();assert(await page.evaluate(()=>matchMedia('(display-mode: standalone)').matches));}else page=await context.newPage();const errors=[];page.on('pageerror',error=>errors.push(error.message));await page.goto(base+'/Writing/Context');await page.locator('[data-context-tab]').first().selectOption('names'); - const pane=index=>page.locator(`[data-context-pane="${index}"]`),first=pane(0);await first.locator('[data-name-select]').first().waitFor();assert.equal(queries.length,0); + const pane=index=>page.locator(`[data-context-pane="${index}"]`),first=pane(0);await first.locator('[data-name-select]').first().waitFor();assert.equal(queries.length,0);assert.equal(await page.locator('[data-single-panel]').count(),0,'Context keeps its existing split-pane architecture'); await first.locator('[name=Search]').fill('George');await first.locator('[data-names-filters] summary').click();await first.locator('[name=BirthYear]').fill('1850');await first.locator('[name=LocaleCode]').selectOption('fr-FR');await first.locator('[data-names-gender]').selectOption('Male:0.9');await first.locator('[name=NameType]').selectOption('Variant');await first.locator('[name=MinimumUsage]').selectOption('0.05');await first.locator('[name=PageSize]').selectOption('100');await first.locator('[data-names-search]').evaluate(f=>f.requestSubmit());await page.waitForFunction(()=>document.querySelectorAll('[data-context-pane="0"] [data-name-select]').length===100); const query=queries.at(-1).params;for(const [key,value]of Object.entries({contextBookId:'12',ProjectID:'7',Search:'George',BirthYear:'1850',LocaleCode:'fr-FR',GenderPreference:'Male',GenderThreshold:'0.9',NameType:'Variant',MinimumUsage:'0.05',PageSize:'100'}))assert.equal(query.get(key),value,key); await first.locator('[data-name-select]').first().click();await first.locator('[data-name-details-fragment]').waitFor();assert.equal(await first.locator('.names-association').count(),2);assert.equal(await first.locator('[data-context-workspace-target]').first().getAttribute('data-context-narrative'),'author');assert.equal(await first.getByRole('link',{name:'View Character',exact:true}).first().getAttribute('target'),'_blank');assert.equal(await first.getByRole('link',{name:'Edit Character',exact:true}).first().getAttribute('target'),'_blank');await first.locator('[data-name-copy]').click();assert.equal(await page.evaluate(()=>navigator.clipboard.readText()),'George 1'); diff --git a/PlotLine.Tests/Browser/directory-dividers.cjs b/PlotLine.Tests/Browser/directory-dividers.cjs new file mode 100644 index 00000000..8d7a560b --- /dev/null +++ b/PlotLine.Tests/Browser/directory-dividers.cjs @@ -0,0 +1,14 @@ +// Compiled production pages; the existing shared divider and local preference store. +const {chromium}=require('playwright'),assert=require('assert/strict'),fs=require('fs'),os=require('os'),path=require('path'); +(async()=>{const installed=process.argv.includes('--installed'),profile=fs.mkdtempSync(path.join(os.tmpdir(),'pd-directory-dividers-')),base='http://127.0.0.1:5238',manifestId=base+'/Projects',out='/tmp/pd-directory-dividers';fs.mkdirSync(out,{recursive:true});let c,cdp,p;const errors=[],calls={attributes:0,search:0,details:0,other:0},saved={},measurements=[]; +async function launch(restart=false){c=await chromium.launchPersistentContext(profile,{headless:!installed,viewport:{width:1920,height:1080}});p=c.pages()[0];await c.route('https://cdn.jsdelivr.net/**',r=>r.fulfill({contentType:'application/javascript',body:fs.readFileSync(path.join(__dirname,'node_modules',r.request().url().includes('chart.umd')?'chart.js/dist/chart.umd.js':'@microsoft/signalr/dist/browser/signalr.min.js'))}));const groups=await(await p.request.get(base+'/character-attribute-definitions-fixture')).json();await c.route('**/CharacterAttributes/Directory?*',r=>{calls.attributes++;return r.fulfill({json:{canEdit:true,groups,characters:Array.from({length:100},(_,n)=>({id:n+1,name:'Fixture character '+(n+1),version:'v1',values:{importance:'6',life:'',sex:'',type:'unclassified',quickAdd:'0'}}))}})});for(const part of ['Results','Details'])await c.route('**/Names/'+part+'?*',async r=>{calls[part==='Results'?'search':'details']++;const u=new URL(r.request().url());return r.fulfill({response:await p.request.get(base+'/names-workspace-fixture/'+part.toLowerCase()+'?'+u.searchParams)})});c.on('request',r=>{if(/\/NameVerification\/|\/CharacterAttributes\/(Assign|Undo)/.test(new URL(r.url()).pathname))calls.other++});await p.goto(base+'/fixture?page=calendar-test');if(installed){cdp=await c.browser().newBrowserCDPSession();if(!restart){await cdp.send('PWA.install',{manifestId,installUrlOrBundleUrl:p.url()});await cdp.send('PWA.changeAppUserSettings',{manifestId,displayMode:'standalone'})}const opened=c.waitForEvent('page');await cdp.send('PWA.launch',{manifestId,url:p.url()});p=await opened;await p.waitForLoadState();assert(await p.evaluate(()=>matchMedia('(display-mode: standalone)').matches));await p.setViewportSize({width:1920,height:1080})}p.on('pageerror',e=>errors.push(e.message));} +const width=selector=>p.locator(selector).evaluate(n=>n.getBoundingClientRect().width),pause=()=>p.evaluate(()=>new Promise(r=>requestAnimationFrame(()=>requestAnimationFrame(r)))); +async function drag(handle,delta){const b=await handle.boundingBox(),y=Math.max(220,Math.min(550,b.y+40));await p.mouse.move(b.x+b.width/2,y);await p.mouse.down();await p.mouse.move(b.x+b.width/2+delta,y,{steps:15});await p.mouse.up();await pause();assert.equal(await p.evaluate(()=>document.documentElement.classList.contains('pd-panel-resizing')),false)} +async function preference(name){return p.evaluate(name=>{const key=Object.keys(localStorage).find(k=>k.startsWith('plotdirector.workspace.panels.'+name+'.'));return {key,...JSON.parse(localStorage.getItem(key))}},name)} +try{await launch();await p.goto(base+'/character-attributes-fixture?count=100');await p.locator('[data-attribute-groups] details').first().waitFor();const ch=p.getByRole('separator',{name:'Resize Attributes panel'}),side='[data-attribute-sidebar]',grid='.character-card-grid';await ch.waitFor();const biographies=await p.locator('.visual-card-heading p.muted').allTextContents(),gridBefore=await width(grid),before={...calls};await drag(ch,160);assert(Math.abs(await width(side)-416)<2);assert(await width(grid)gridBefore+250);await p.locator('[data-attributes-toggle]').click();await ch.waitFor();assert(Math.abs(await width(side)-406)<2);await p.evaluate(()=>scrollTo({top:1200,behavior:'instant'}));const sticky=await p.locator(side).boundingBox();assert(sticky.y>=0&&sticky.y+sticky.height<=1081);await p.evaluate(()=>scrollTo({top:0,behavior:'instant'}));assert.deepEqual(await p.locator('.visual-card-heading p.muted').allTextContents(),biographies); +await p.goto(base+'/names-workspace-fixture/page');await p.locator('[name=Search]').fill('George');await p.locator('[name=SortOrder]').selectOption('name-desc');await p.waitForFunction(()=>JSON.parse(document.querySelector('[data-names-applied]').textContent).SortOrder==='name-desc');await p.locator('[data-name-select]').first().click();await p.locator('[data-name-details-fragment]').waitFor();const nh=p.getByRole('separator',{name:'Resize name results and details'}),results='[data-names-results-host]';await nh.waitFor();const initial=await width(results),namesBefore={...calls},selected=await p.locator('[data-name-details-fragment] h2').innerText();await drag(nh,-150);assert(Math.abs(await width(results)-(initial-150))<2);await drag(nh,5000);assert(await width('[data-names-details]')>=319);await drag(nh,-5000);assert(Math.abs(await width(results)-280)<2);await drag(nh,initial-150-280);saved.names=await preference('names');assert(saved.names.left!==saved.characters.left);assert.deepEqual(calls,namesBefore);assert.equal(await p.locator('[name=SortOrder]').inputValue(),'name-desc');assert.equal(await p.locator('[data-name-details-fragment] h2').innerText(),selected);await p.reload();await nh.waitFor();assert(Math.abs(await width(results)-saved.names.left)<2); +for(const kind of ['names','characters']){await p.goto(base+(kind==='names'?'/names-workspace-fixture/page':'/character-attributes-fixture?count=100'));const handle=kind==='names'?nh:ch;await handle.waitFor();for(const w of [1280,1920,2560,3840,800,390,1920]){await p.setViewportSize({width:w,height:1080});await pause();assert(await p.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+2),kind+' overflow '+w);if(w===390)assert(await handle.isHidden());const current=await preference(kind);assert.equal(current.left,saved[kind].left,'viewport changes must not overwrite preference');if(w===2560)await p.screenshot({path:`${out}/${installed?'pwa':'browser'}-${kind}-2560.png`});measurements.push({kind,viewport:w,leftWidth:await width(kind==='names'?results:side),columns:kind==='characters'?await p.locator(grid).evaluate(n=>getComputedStyle(n).gridTemplateColumns.split(' ').length):null});}for(const theme of ['plotdirector','modern-light','modern-dark','warm-light','warm-dark','rose-pink','baby-blue']){await p.evaluate(t=>{document.documentElement.dataset.appTheme=t;document.documentElement.dataset.bsTheme=t.endsWith('dark')?'dark':'light'},theme);await p.screenshot({path:`${out}/${installed?'pwa':'browser'}-${kind}-${theme}.png`})}} +// Persisted main Names state remains untouched by these panel controls; Context never mounts them. +await c.close();await launch(true);for(const kind of ['names','characters']){await p.goto(base+(kind==='names'?'/names-workspace-fixture/page':'/character-attributes-fixture?count=100'));await p.getByRole('separator').waitFor();assert(Math.abs(await width(kind==='names'?results:side)-saved[kind].left)<2,kind+' survives complete Chromium/PWA restart')} +assert.equal(calls.other,0);assert.deepEqual(errors,[]);fs.writeFileSync(`${out}/${installed?'pwa':'browser'}.json`,JSON.stringify({status:'passed',actualInstalledPwa:installed,restartedPersistentProfile:true,saved,calls,measurements,biographiesPreserved:true},null,2));console.log('PASS independent pointer/keyboard dividers, bounds, sticky/collapse, no lookup/AI requests on resize, navigation/refresh/profile restart, seven themes, 390–3840 widths and '+(installed?'actual installed PWA':'browser')); +}finally{if(cdp)await cdp.send('PWA.uninstall',{manifestId}).catch(()=>{});await c?.close();fs.rmSync(profile,{recursive:true,force:true})}})().catch(e=>{console.error(e.name+': '+e.message.split('Call log:')[0]);process.exitCode=1}); diff --git a/PlotLine.Tests/CharacterQuickAttributesTests.cs b/PlotLine.Tests/CharacterQuickAttributesTests.cs index a79db844..5583e1a1 100644 --- a/PlotLine.Tests/CharacterQuickAttributesTests.cs +++ b/PlotLine.Tests/CharacterQuickAttributesTests.cs @@ -17,6 +17,8 @@ internal static class CharacterQuickAttributesTests Check(ApplicationRibbon.Icon("attribute-star-filled").Filled&&ApplicationRibbon.Icon("attribute-star-half").Filled&&!ApplicationRibbon.Icon("attribute-star").Filled,"shared icon library supplies filled geometry without colour-only meaning"); var sex=CharacterQuickAttributes.Definitions([new(){CharacterSexValueID=1,SexName="Male",IsSystem=true},new(){CharacterSexValueID=2,SexName="Female",IsSystem=true},new(){CharacterSexValueID=3,SexName="Other",IsSystem=true},new(){CharacterSexValueID=4,SexName="Recorded custom sex"}]).Single(g=>g.Id=="sex"); Check(sex.Values.Select(v=>v.Icon).SequenceEqual(new[]{"help","sex-male","sex-female","sex-other","sex-other"})&&sex.RecordedFallback?.Icon=="sex-other","canonical and custom/legacy sex symbols preserve catalogue values and distinct shapes"); + Check(sex.Values.Single(v=>v.Value=="1").RecordedLabels?.Single()=="male"&&sex.Values.Single(v=>v.Value=="2").RecordedLabels?.Single()=="female"&&sex.Values.Single(v=>v.Value=="4").RecordedLabels is null,"recorded legacy Male/Female reuse system definitions without reclassifying custom text"); + Check(JsonSerializer.Serialize(CharacterQuickAttributes.Presentation(sex.Values.Single(v=>v.Value=="2"))).Contains("female"),"shared presentation carries legacy matching metadata for cards, filters and menus"); Check(CharacterTypes.Values.Select(v=>v.Value).Distinct().Count()==6 && !CharacterTypes.IsValid("human"),"six stable type codes reject invented classifications"); Check(new Character().CharacterTypeCode=="unclassified", "new/legacy projections remain Unclassified without inference"); Check(CharacterTypes.Definition("animal").Icon=="attribute-paw", "animal associations reuse the shared paw icon"); diff --git a/PlotLine/Services/CharacterQuickAttributes.cs b/PlotLine/Services/CharacterQuickAttributes.cs index 0143f79f..2cedefd0 100644 --- a/PlotLine/Services/CharacterQuickAttributes.cs +++ b/PlotLine/Services/CharacterQuickAttributes.cs @@ -2,7 +2,7 @@ using PlotLine.Models; namespace PlotLine.Services; // One vocabulary for the directory legend, indicators and assignment menus. -public sealed record CharacterQuickValue(string Value,string Label,string Icon,string Tone="secondary"); +public sealed record CharacterQuickValue(string Value,string Label,string Icon,string Tone="secondary",IReadOnlyList? RecordedLabels=null); public sealed record CharacterQuickGroup(string Id,string Label,IReadOnlyList Values, CharacterQuickValue? RecordedFallback=null); public static class CharacterQuickAttributes { @@ -16,12 +16,12 @@ public static class CharacterQuickAttributes private static CharacterQuickValue SexValue(CharacterSexValue value) { var (icon,tone)=(value.IsSystem?value.SexName:"") switch {"Male"=>("sex-male","info"),"Female"=>("sex-female","data-7"),_=>("sex-other","data-5")}; - return new(value.CharacterSexValueID.ToString(),value.SexName,icon,tone); + return new(value.CharacterSexValueID.ToString(),value.SexName,icon,tone,value.IsSystem?[value.SexName.Trim().ToLowerInvariant()]:null); } public static object Presentation(CharacterQuickValue value) { var icon=ApplicationRibbon.Icon(value.Icon); - return new{value.Value,value.Label,value.Tone,value.Icon,path=icon.IconPath,icon.Filled}; + return new{value.Value,value.Label,value.Tone,value.Icon,value.RecordedLabels,path=icon.IconPath,icon.Filled}; } public static object Snapshot(Character c)=>new {id=c.CharacterID,name=c.CharacterName,version=c.UpdatedDate.ToString("O"),values=new Dictionary{["type"]=c.CharacterTypeCode,["importance"]=c.CharacterImportance?.ToString()??"",["life"]=c.IsDeceased.HasValue?(c.IsDeceased.Value?"1":"0"):"",["sex"]=c.SexValueID?.ToString()??(string.IsNullOrWhiteSpace(c.Sex)?"":"legacy:"+c.Sex),["quickAdd"]=c.ShowInQuickAddBar?"1":"0"}}; } diff --git a/PlotLine/Views/Characters/Index.cshtml b/PlotLine/Views/Characters/Index.cshtml index 091bf216..023fb279 100644 --- a/PlotLine/Views/Characters/Index.cshtml +++ b/PlotLine/Views/Characters/Index.cshtml @@ -86,4 +86,6 @@ + + diff --git a/PlotLine/Views/Names/Index.cshtml b/PlotLine/Views/Names/Index.cshtml index 22f4d74f..7c8d2a01 100644 --- a/PlotLine/Views/Names/Index.cshtml +++ b/PlotLine/Views/Names/Index.cshtml @@ -4,4 +4,5 @@

Names

Explore catalogue names and recorded names and aliases across this series.

-@section Scripts {} + +@section Scripts {} diff --git a/PlotLine/Views/Shared/_ApplicationShell.cshtml b/PlotLine/Views/Shared/_ApplicationShell.cshtml index d8b089e3..b3d1503e 100644 --- a/PlotLine/Views/Shared/_ApplicationShell.cshtml +++ b/PlotLine/Views/Shared/_ApplicationShell.cshtml @@ -128,7 +128,6 @@ @foreach (var category in ApplicationRibbon.Categories) {