15 KiB
Writing Context workspace — 8 November 2026
Implementation
Baseline: shared branch codex/word-companion-native-phase1-20261104, fast-forwarded to Windows commit b7fe1e4 (Companion developer version 1.0.0.21). No branch/worktree, native packaging, installation or Production changes.
The old native Context route rendered a connection/document card and a second Writing Context document in an iframe. Its presence handler changed the iframe URL on scene changes, destroying the inner window's active state. Links within that document could navigate the frame to a complete application page. The inner pinned view also depended on parent-frame theme inheritance.
Context and Intent now open the existing /Writing/Context and /Writing/Intent workspaces directly. Legacy /native-companion/workspace?view=context|intent entry points redirect to them, retaining book and explicit document-session selection. The native management page retains diagnostics and saved review/import entry points, with no iframe. There is no replacement embedded-document mechanism.
Scene navigation and state
- The existing
writing-follow.jsfetch/abort/generation mechanism updates the expected scene partial only. Redirected responses, complete HTML documents and responses without the expected sole root fragment are rejected; current content survives failure. - Jump and Previous/Next use the existing authorised Word Companion book structure in manuscript order, including chapter boundaries. They do not use the former selected-first alphabetical scene list.
- The workspace root survives scene changes. Active tab remains local to that window, with the existing preference retained for initial opening. It is read immediately before replacing a fragment, so changing tabs during an outstanding request is respected.
- Plot Lines and Metrics retain their loaded DOM, filter/metric selections, scrub position and viewport rather than refetching the whole book on cursor movement. Maps retain their host and per-map viewport; scene data updates without reloading a document. Existing view-state restoration handles controls, floor zoom, scroll and map SVG view boxes. Keyboard focus is restored only within a focused browser window, never by focusing the window during Word following.
- People retains the existing scene-specific presentation. Relationships, Overview, Story and Intent continue using their existing partials and services.
Word connection and two-way navigation
The existing top-right Word indicator opens a compact connection dialog: current authorised document sessions, active-document following or exact document selection, heartbeat explanation and troubleshooting/display-settings access. Dedicated windows have the same indicator in their compact application bar. Website connectivity remains separate. The former large native connection panel and follow checkbox are absent from the writing workspace.
Native presence updates use the existing indicator's authenticated refresh and native SignalR notifications. Context follows scene identity changes, not every heartbeat; reconnect restores Word's actual location. Office.js following remains supported. Writing views reuse the existing workspace follow connection instead of creating another when it is available.
Only explicit scene navigation posts /Writing/Context/Navigate, with antiforgery protection. The server checks:
- Current user access to the book and requested scene's actual chapter.
- A uniquely selected live Word document, or the sole/active document when no exact selection was made.
- Saved Word state and matching manuscript, session and revision in the persisted paragraph snapshot.
- The first scene prose paragraph's verified assignment, and an independent authoritative position resolution to that same scene/chapter.
- The lease still being current and no capture/synchronisation/cancellation command being displaced.
It queues the existing revision-bound navigate command. Rapid navigation coalesces to the latest navigation command; capture work is protected. Success means requested, not that Word has executed the command. Expired, missing or ambiguous mappings produce an explanation while saved scene browsing continues. Superseded browser requests are cancelled and the server checks request cancellation before queueing.
Word-to-Context updates and exploratory charts/maps never send commands back to Word. The existing VSTO adapter implements navigation through a positional Range.Select() on its Word thread; this change adds no prose writes, marker insertion or document save operation. No new Windows command, IPC contract or installer is required. Actual execution and document dirty-state behaviour still require Windows qualification.
Plot Lines, recorded metrics, Maps and Floor Plans
- Plot Lines: existing
IPlotLineWorkspaceService, Focus/Weave membership/contribution projection and canonical manuscript order. Read-only lanes display saved developments, line filters, a current-scene marker, horizontal scrolling and an exploration scrubber. Only “Go to scene” initiates navigation. - Metrics: existing canonical scene ordering, graph view models and scene repository. Both Timeline's SQL projection and graph builder fill missing values with defaults, while Analytics limits the metric names reported. Migration 244 adds one authorised read-only stored procedure to return all active recorded
SceneMetricValuesfor the book; missing entries are gaps, genuine zeroes remain values, and the metric's actual configured range is displayed. No new AI assessment, confidence percentages or invented emotional scores. The existing Development constraint only permits stored values 1–10; it was not weakened or reinterpreted. The pure renderer can preserve zero if supplied, while the live SQL regression uses the permitted minimum and proves that missing values stay absent. - Maps: existing
MapRepository,IMapStoryService/location resolver andmaps-engine.jsgeometry. Saved map features, reference images and location relationships are shown in a read-only component. Scene, participant, plot-location and all-place lenses use saved projections. Pan, zoom, place inspection and map switching do not navigate Word or edit maps. A missing reliable location association is stated explicitly; it is not inferred from feature names or canvas proximity. - Floor Plans: existing scene/floor/room/occupancy partial. The saved floor grid gains bounded exploration, zoom and a highlight only for an exact saved scene-location room mapping. Unmapped floors remain an empty state. This is a reference preview, not every editing control from the full Floor Plans workspace.
New read endpoints check project access and relevant book/project/scene boundaries before exposing data. No database identity mappings, import lifecycle, paragraph reconciliation, evidence, manuscript prose, AI jobs or author decisions are modified.
Window management and appearance
The existing named Context and Intent windows, Left/Right display preferences, Detect Screen permission flow and local preference storage are reused. Changing display selections now saves to that existing preference store. Reopening a window for the same book focuses it without reloading its current scene/tab. Switching books changes the destination deliberately. Popup size is bounded by the available display, including narrower screens. Browser permission/pop-up restrictions still apply; no native always-on-top subsystem was added.
Dedicated windows now share the main application's server-saved appearance bootstrap and the existing non-sensitive cross-window theme setting. They no longer require an iframe parent to inherit a theme. Dark, light and warm variants use existing CSS variables and theme definitions.
Verification
Final portable verification:
dotnet build PlotLine.slnx --no-restore --disable-build-servers -m:1 /p:UseSharedCompilation=false: passed, zero warnings/errors.dotnet run --project PlotLine.Tests --no-build: 455 passing regression assertions.dotnet run --project PlotLine.Tests --no-build -- --writing-context-navigation: 24 passing assertions covering ownership, canonical order, stale/malformed/exact sessions, revision and saved-state races, and capture-command protection.- Existing
--native-tray,--paragraph-manuscriptsand--native-capture-lifetimefocused regressions passed. No extraction, reconciliation, capture or AI pipeline implementation changed. - Browser scripts
writing-context-shell.cjs,writing-context-navigation.cjs,writing-context-components.cjs,writing-context-scale.cjs,writing-desks.cjs,word-companion-regressions.cjs,native-companion-workspace.cjs: passed. Coverage includes real Razor, direct normal/dedicated/PWA layouts, four light/dark/warm themes, 400/760/1600 widths, tab/scroll/focus preservation, document selection, return-to-Word, cross-chapter navigation, no feedback loops, disconnect/reconnect, full-page Timeline-response rejection, recorded metric gaps, map exploration and floor zoom. - The 400-scene/10-line Chromium fixture loaded its chart in 297 ms and completed four scene changes in 422 ms with one chart read and retained DOM. These are fixture measurements, not Windows/Word performance guarantees.
PlotLine.Tests/Sql/WritingContextMetrics.sql: guarded transactional Development test passed, including custom metric coverage, exact saved values, absent-value gaps and cross-user denial. All fixture mutations rolled back. Application database principal can execute migration 244's procedure.
Browser fixtures render the actual compiled Razor partials/full pages and run the actual scripts; they do not start application background workers or access author data. Fixture browser success is distinguished from verification against deployed Development and from actual Word execution.
Deployment and remaining qualification
Deployed application commit e0525f4 (foundation/migration commit 9568e7e) to Development at 2026-11-09 00:12 UTC:
- Release:
/srv/apps/plotdirector-dev/releases/e0525f4-20261109T001229Z; prior physical installation preserved atcurrent-before-e0525f4-20261109T001229Z. - Published and running
PlotLine.dllSHA-256:3a944e70231d82f3d80ccc2c2017b58928766032b14f5818b9019786854dba3c. - Service active; public TLS-validated HTTPS GET and local GET both returned 200. No startup warnings/errors.
- Existing analysis genuinely progressed to completion before deployment. The normal guard checked queued/running Story Intelligence, synthesis, enrichment, imports and marker work immediately before stopping the service and passed. No author job was interrupted, restarted, reset or invalidated.
- Migration 244 applied after a verified copy-only Development backup:
/var/opt/mssql/backup/pwa-desktop-20261108T231952-79895d73262c466e8e65f4cbfe851003.bak(RESTORE VERIFYONLY WITH CHECKSUMpassed). One authorised read-only procedure; no table/data/identity migration. Production untouched. - Initial publishing exhausted the user's temporary-file quota; the incomplete generated output was moved out of
/tmpand publishing succeeded on the normal/srvfilesystem before any service change. No source/build defect was hidden by this retry.
Actual deployed workflow verification
node PlotLine.Tests/Browser/writing-context-development.cjs <private-identity-file> <synthetic-scope-file> passed against https://dev.plotdirector.com, through normal login and browser-approved persistent installation authorisation. A disposable synthetic account/book with two chapters/scenes and an existing six-paragraph snapshot was used; no author project, manuscript, import or AI job was used as a fixture.
Verified: native bearer registration and exact cursor-to-scene resolution; legacy URL redirects to the direct dedicated Context document without iframe/ribbon; explicit cross-chapter scene selection queues one existing revision-bound navigate command at the exact saved paragraph position; simulated cursor acknowledgement follows without issuing another command; workspace root and People tab retained; stale Word revision refused with HTTP 409; actual recorded metrics and empty plot-line state; disconnected manual browsing; reconnect restores Word's actual cursor scene; anonymous/antiforgery rejection; installation revocation invalidates the bearer credential.
The paragraph snapshot's SHA-256, revision and all six position rows were exactly unchanged before/after. The synthetic installation was revoked and fixture account/project/book/snapshot removed. The existing normal account-delete workflow has a UserOnboardingState foreign-key cleanup omission: normal project deletion succeeded, then a guarded deletion of only the orphaned synthetic user's onboarding state allowed normal account deletion to finish. No unrelated account cleanup code was changed.
This test is a real deployed protocol-client/browser test, not Word COM execution. It neither uploads prose nor claims physical monitor/native visual qualification.
Browser reference images
Actual compiled Razor with synthetic story data, captured in Chromium (not Windows desktop screenshots):
Where to use it
Open Context/Intent from the existing Writer/workspace actions; existing native workspace bookmarks redirect automatically. Click the top-right Word connected/disconnected indicator for document selection and diagnostics. In Context, use Jump to scene or Previous/Next beside the scene title. Plot Lines, Metrics, Maps and Floor Plans are tabs in that same workspace; scrubbing is exploratory, and only Go to scene requests navigation. Display positioning remains in the existing Writer display preferences/Detect Screen controls.
After rollout, refresh/reopen Context so a previously loaded legacy document uses the new direct workspace. Windows acceptance should check explicit Jump/Previous/Next into Word, cross-chapter positioning, ordinary cursor following without focus theft or loops, stale-map refusal, document selection, Word's unchanged saved/dirty state, and independent Context/Intent windows. Existing Companion 1.0.0.21 remains installed and untouched.
Remaining limitations: reference Maps/Floor Plans deliberately reuse read-only projections rather than reproduce full editing workspaces. The original historical Timeline embedding request was not available as a network capture; the confirmed iframe/navigation/state-loss path was removed, and regression tests explicitly reject complete Timeline/application pages. Browser popup/screen-placement permissions and physical monitor positioning still require the user's Windows environment. No native source, IPC contract, installer, manuscript extraction or author decision changes were needed.