Keep Writer focus and presence scoped to the selected book
This commit is contained in:
parent
735a7d86b1
commit
597915f7ae
@ -80,3 +80,14 @@ The exact reported whole-page PWA navigation lock has not been reproduced separa
|
|||||||
### Guard interaction check — in-page Help
|
### Guard interaction check — in-page Help
|
||||||
|
|
||||||
Before deployment, an added real PWA test reproduced an unnecessary save dialog when the ribbon Help link opened its in-page drawer. The opt-in guard now excludes declared Help/Bootstrap in-page actions; links leaving the page and browser unload remain protected. Extended chapter-goal suite passed in browser/PWA, including Help opening without a save prompt and unchanged draft text. This small static-script correction follows the passing 405-check broader gate; it is not deployed yet.
|
Before deployment, an added real PWA test reproduced an unnecessary save dialog when the ribbon Help link opened its in-page drawer. The opt-in guard now excludes declared Help/Bootstrap in-page actions; links leaving the page and browser unload remain protected. Extended chapter-goal suite passed in browser/PWA, including Help opening without a save prompt and unchanged draft text. This small static-script correction follows the passing 405-check broader gate; it is not deployed yet.
|
||||||
|
|
||||||
|
### Writer book-scope repair — reproduced and verified
|
||||||
|
|
||||||
|
The expanded real-Hub test reproduced two additional failures before repair:
|
||||||
|
|
||||||
|
- After selecting a second book, Open Context reused the first book's window: three total pages remained instead of opening the fourth, correctly scoped Context page. Client window references were keyed only by role. References now use the existing stable role/book window name.
|
||||||
|
- A real heartbeat from the first book changed the launcher's selected book from 13 back to 12. User-wide presence broadcasts were unconditionally adopted as local scope. Other-book/project updates now leave the selected scope and role state intact, while still updating user-level Word connectivity. Canonical story-position changes continue to select the intended scope explicitly.
|
||||||
|
|
||||||
|
Verification: build passed (0 warnings/errors); full-layout Writer browser/PWA test passed with real heartbeat injection, second-book window creation, first-book preservation, restoration to the first scope, reconnect, identity/reload/focus tests and repeated navigation/header commands. Chapter-goal suite, including Help and concurrent edits, passed again. Fixture book data now honours the requested scope; no production routing or database schema changes.
|
||||||
|
|
||||||
|
Urgent Writer release is still pending this final broader gate; an earlier publish was superseded before installation. Next: publish committed verified fixes, run the idle-work gate immediately before Development restart, smoke-check, then continue the rendered visual inventory.
|
||||||
|
|||||||
@ -46,6 +46,31 @@ const base = 'http://127.0.0.1:5238';
|
|||||||
await page.locator('[data-focus-writing-context]').click();
|
await page.locator('[data-focus-writing-context]').click();
|
||||||
await page.locator('[data-focus-writing-intent]').click();
|
await page.locator('[data-focus-writing-intent]').click();
|
||||||
assert.equal(context.pages().length,3,'Focus commands reuse the existing writing windows');
|
assert.equal(context.pages().length,3,'Focus commands reuse the existing writing windows');
|
||||||
|
const oldContext=windows[0];
|
||||||
|
const oldContextUrl=oldContext.url();
|
||||||
|
await page.evaluate(()=>document.dispatchEvent(new CustomEvent('plotdirector:story-position-changed',{detail:{projectId:7,bookId:13}})));
|
||||||
|
await page.waitForFunction(()=>document.querySelector('[data-writing-workspace-book]').textContent==='Book 13');
|
||||||
|
await page.evaluate(async()=>{
|
||||||
|
await window.PlotDirectorWritingWorkspace.watchWorkspace({projectID:7,bookID:13});
|
||||||
|
document.addEventListener('plotdirector:writing-workspace-status',event=>{
|
||||||
|
if((event.detail?.bookID||event.detail?.BookID)===12)window.__labelDuringOtherBookUpdate=document.querySelector('[data-writing-workspace-book]').textContent;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
await oldContext.evaluate(()=>window.__writerConnections.at(-1).invoke('WritingWindowHeartbeat',{
|
||||||
|
browserWindowID:window.PlotDirectorWritingWorkspace.getBrowserWindowId(),projectID:7,bookID:12,writingRole:'Context',currentRoute:location.pathname
|
||||||
|
}));
|
||||||
|
await page.waitForFunction(()=>window.__labelDuringOtherBookUpdate!==undefined);
|
||||||
|
assert.equal(await page.evaluate(()=>window.__labelDuringOtherBookUpdate),'Book 13','Another book heartbeat cannot change the selected workspace');
|
||||||
|
await page.locator('[data-open-writing-context]').click();
|
||||||
|
await page.waitForFunction(()=>!document.querySelector('[data-open-writing-context]').disabled);
|
||||||
|
assert.equal(context.pages().length,4,'Changing books opens a separately scoped Context window');
|
||||||
|
assert.equal(oldContext.url(),oldContextUrl,'The first book context is preserved');
|
||||||
|
const secondContext=context.pages().find(tab=>tab!==page&&!windows.includes(tab));
|
||||||
|
await secondContext.waitForLoadState();
|
||||||
|
assert.equal(new URL(secondContext.url()).searchParams.get('bookId'),'13');
|
||||||
|
await secondContext.close();
|
||||||
|
await page.evaluate(()=>document.dispatchEvent(new CustomEvent('plotdirector:story-position-changed',{detail:{projectId:7,bookId:12}})));
|
||||||
|
await page.waitForFunction(()=>document.querySelector('[data-writing-workspace-book]').textContent==='Book 12');
|
||||||
const beforeRestart=negotiations;
|
const beforeRestart=negotiations;
|
||||||
await page.evaluate(()=>window.__writerConnections.at(-1).stop());
|
await page.evaluate(()=>window.__writerConnections.at(-1).stop());
|
||||||
await start.click();
|
await start.click();
|
||||||
|
|||||||
@ -123,7 +123,7 @@ internal static class ToolbarBrowserHost
|
|||||||
FixtureProxy<IProjectRepository>((name, args) => name == "GetForUserAsync"
|
FixtureProxy<IProjectRepository>((name, args) => name == "GetForUserAsync"
|
||||||
? Task.FromResult<Project?>(new Project { ProjectID = 7, ProjectName = "The Glass Harbour", AccessRole = "Owner" }) : throw new NotSupportedException(name)),
|
? Task.FromResult<Project?>(new Project { ProjectID = 7, ProjectName = "The Glass Harbour", AccessRole = "Owner" }) : throw new NotSupportedException(name)),
|
||||||
FixtureProxy<IBookRepository>((name, args) => name == "ListByProjectAsync"
|
FixtureProxy<IBookRepository>((name, args) => name == "ListByProjectAsync"
|
||||||
? Task.FromResult<IReadOnlyList<Book>>([new() { BookID = 12, ProjectID = 7, BookTitle = "A Distant Shore" }]) : throw new NotSupportedException(name)),
|
? Task.FromResult<IReadOnlyList<Book>>([new() { BookID = 12, ProjectID = 7, BookTitle = "A Distant Shore" }, new() { BookID = 13, ProjectID = 7, BookTitle = "The Return" }]) : throw new NotSupportedException(name)),
|
||||||
services.GetRequiredService<ICurrentUserService>()));
|
services.GetRequiredService<ICurrentUserService>()));
|
||||||
builder.Services.AddScoped<IWriterWorkspaceService>(services => FixtureProxy<IWriterWorkspaceService>((name, args) => name switch {
|
builder.Services.AddScoped<IWriterWorkspaceService>(services => FixtureProxy<IWriterWorkspaceService>((name, args) => name switch {
|
||||||
"GetDashboardAsync" => Task.FromResult(WriterFixture()),
|
"GetDashboardAsync" => Task.FromResult(WriterFixture()),
|
||||||
@ -238,8 +238,8 @@ internal static class ToolbarBrowserHost
|
|||||||
context.Response.ContentType = "text/html; charset=utf-8";
|
context.Response.ContentType = "text/html; charset=utf-8";
|
||||||
await context.Response.WriteAsync(writer.ToString());
|
await context.Response.WriteAsync(writer.ToString());
|
||||||
});
|
});
|
||||||
app.MapGet("/Writing/Context", context => RenderFullAsync(context, "Writing", "Context", new WritingContextPageViewModel { ProjectID = 7, BookID = 12 })).WithOrder(-1);
|
app.MapGet("/Writing/Context", context => RenderFullAsync(context, "Writing", "Context", new WritingContextPageViewModel { ProjectID = 7, BookID = int.TryParse(context.Request.Query["bookId"].ToString(), out var bookId) ? bookId : 12 })).WithOrder(-1);
|
||||||
app.MapGet("/Writing/Intent", context => RenderFullAsync(context, "Writing", "Intent", new WritingIntentPageViewModel { ProjectID = 7, BookID = 12 })).WithOrder(-1);
|
app.MapGet("/Writing/Intent", context => RenderFullAsync(context, "Writing", "Intent", new WritingIntentPageViewModel { ProjectID = 7, BookID = int.TryParse(context.Request.Query["bookId"].ToString(), out var bookId) ? bookId : 12 })).WithOrder(-1);
|
||||||
app.MapGet("/fixture", async context =>
|
app.MapGet("/fixture", async context =>
|
||||||
{
|
{
|
||||||
if (context.Request.Query["page"] == "writer" && context.Request.Query["layout"] == "full")
|
if (context.Request.Query["page"] == "writer" && context.Request.Query["layout"] == "full")
|
||||||
|
|||||||
@ -95,6 +95,14 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const render = (status = latestStatus) => {
|
const render = (status = latestStatus) => {
|
||||||
|
const incomingScope = workspace.statusScope(status);
|
||||||
|
if (status && ((activeScope.projectID && incomingScope.projectID && activeScope.projectID !== incomingScope.projectID)
|
||||||
|
|| (activeScope.bookID && incomingScope.bookID && activeScope.bookID !== incomingScope.bookID))) {
|
||||||
|
// Presence broadcasts cover all this author's books. They must not change
|
||||||
|
// the workspace chosen here by a canonical position or explicit command.
|
||||||
|
text(statusNodes.word, status.wordCompanionConnected || status.WordCompanionConnected ? "Connected" : "Not connected");
|
||||||
|
return;
|
||||||
|
}
|
||||||
latestStatus = status;
|
latestStatus = status;
|
||||||
activeScope = workspace.statusScope(status, activeScope);
|
activeScope = workspace.statusScope(status, activeScope);
|
||||||
text(statusNodes.book, activeScope.bookID ? `Book ${activeScope.bookID}` : "Waiting for book");
|
text(statusNodes.book, activeScope.bookID ? `Book ${activeScope.bookID}` : "Waiting for book");
|
||||||
|
|||||||
@ -307,7 +307,7 @@
|
|||||||
const name = stableWindowName(role, scope);
|
const name = stableWindowName(role, scope);
|
||||||
const opened = window.open(url, name, popupFeatures(display));
|
const opened = window.open(url, name, popupFeatures(display));
|
||||||
if (opened) {
|
if (opened) {
|
||||||
windowRefs.set(role, opened);
|
windowRefs.set(stableWindowName(role, scope), opened);
|
||||||
try {
|
try {
|
||||||
opened.focus();
|
opened.focus();
|
||||||
} catch {
|
} catch {
|
||||||
@ -318,7 +318,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const focusRole = async (role, scope, display = null) => {
|
const focusRole = async (role, scope, display = null) => {
|
||||||
const ref = windowRefs.get(role);
|
const ref = windowRefs.get(stableWindowName(role, scope));
|
||||||
if (ref && !ref.closed) {
|
if (ref && !ref.closed) {
|
||||||
ref.focus();
|
ref.focus();
|
||||||
return true;
|
return true;
|
||||||
@ -326,7 +326,7 @@
|
|||||||
|
|
||||||
const opened = window.open(buildWritingUrl(role, scope), stableWindowName(role, scope), popupFeatures(display));
|
const opened = window.open(buildWritingUrl(role, scope), stableWindowName(role, scope), popupFeatures(display));
|
||||||
if (opened) {
|
if (opened) {
|
||||||
windowRefs.set(role, opened);
|
windowRefs.set(stableWindowName(role, scope), opened);
|
||||||
opened.focus();
|
opened.focus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user