Skip to content

Feature scenes#250

Open
StableLlama wants to merge 89 commits into
StableLlamaAI:developfrom
StableLlama:feature_scenes
Open

Feature scenes#250
StableLlama wants to merge 89 commits into
StableLlamaAI:developfrom
StableLlama:feature_scenes

Conversation

@StableLlama

Copy link
Copy Markdown
Collaborator

Description

Add functionality to handle single scenes that make up the whole plot.
Closes #212

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

  • Backend tests (pytest)
  • Frontend tests (npm run test)
  • Manual verification

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

StableLlama and others added 30 commits May 6, 2026 17:06
Co-authored-by: Copilot <copilot@github.com>
- simplify data/time requirements for LLM creating or updating scenes
…across reloads

Implements per-project view state persistence so the application remembers
the last open chapter, workspace mode (Page/Scenes/Split), scenes view type
(defaulting to Narrative), and scroll position across application reloads.

Backend (Python):
- New view_state_ops service: load/save view_state.json per project dir
  with safe defaults for missing/corrupt files
- New ViewStatePayload/ViewStateResponse Pydantic models
- New API routes: GET/PUT /projects/{name}/view-state
- Tests: 8 backend tests covering missing file, corrupt JSON, roundtrip, etc.

Frontend (TypeScript/React):
- New viewState.ts API client
- Extended api.ts facade with viewState in ProjectApiClients
- Updated uiStore: scenesViewType field + setScenesViewType action;
  persists workspaceMode and scenesViewType via Zustand partialize
- New useViewStatePersistence hook for restore and auto-save
- App.tsx integrates restoration and auto-persistence
- ScenesPanelContainer reads scenesViewType from store; default narrative
- Tests: 6 uiStore tests + 9 view state persistence tests

Fixes concurrent-rendering infinite loop: stabilized lane-state callbacks
with useCallback and decoupled external store sync from useState updaters
into dedicated useEffect in useSceneLanes. Includes regression test.
Updates the following packages to patch high-severity CVEs:
- dompurify: 3.4.0 → 3.4.11
- protobufjs: 7.5.8 → 7.6.4
- undici: 7.25.0 → 7.28.0
- vite: 8.0.10 → 8.1.0
- ws: 8.18.3 → 8.21.0
- brace-expansion: 5.0.5 → 5.0.6
- js-yaml: 4.1.1 → 4.2.0

Fixes the failing frontend-checks CI job (npm audit --audit-level=high).
@StableLlama

Copy link
Copy Markdown
Collaborator Author

closes #173 #174 #212

… scene DnD/selection sync

- Add expand/focus icons to Story, Chapters, Sourcebook section headings
  so each section can be maximised to fill the sidebar exclusively, with
  a collapse button to restore the normal view.

- Add a scenes-mode toggle in the Chapters header.  When active, the
  chapter list switches from summary cards to a compact tree view showing
  scenes in narrative order — one compact line per scene with the start
  of its summary.  Supports novel (chapter→scenes) and series (book→
  chapter→scenes) layouts.

- Scene rows in the left-pane tree are draggable.  They use the same
  custom MIME types as NarrativeView and dispatch `aq-scene-reorder-prose`
  / `aq-scene-drop-chapter` events so both panes stay in sync via
  optimistic order broadcasts.

- Synchronise scene selection across panes: add `sceneSelectionPrimaryId`
  to `uiStore`.  The main view (NarrativeView / PinboardView) writes it
  on every cursor-driven or click-driven selection change.  The left-pane
  SceneTreeView reads it and highlights the matching row.  Left-pane
  single-clicks dispatch `aq-scene-select` for the reverse direction.

- Add double-click handler on left-pane scene rows to open the
  SceneEditorDialog, mirroring the behaviour of the main scene views.

- Reuse existing `useSceneSelection`, `useSceneProseSync`, and drag-util
  infrastructure; no selection logic was duplicated.
…rging

Replace the global shouldUseBlockMode check (similarity + fragmentation
over the entire document) with a local zone-merging approach in the
CodeMirror diff plugin.  Adjacent changed segments separated by only
tiny equal gaps (≤20 chars) are merged into "rewrite zones".  Zones
with ≥80 changed chars render as block replacements (old deleted +
new inserted); everything else stays as word-level inline diff.

This fixes the fundamental issue where replacing one scene inside a
long chapter never triggered block mode, because the 4000 unchanged
chars dominated the global similarity metric.  The decision is now
truly local — a single-scene rewrite produces one block zone while
the rest of the chapter renders normally.

- codeMirrorDiffPlugin.ts: add mergeDiffZones(), remove global check
- MarkdownView.tsx, ChapterList.tsx: keep global shouldUseBlockMode
  (appropriate for short summary text)
- codeMirrorDiffBlockMode.test.ts: rewrite for zone-based logic
- Closes noisy inline diffs for partial scene rewrites in Page view
…e, and undo history grouping

- FloatingDiffToolbar: Replace Tailwind dark: classes with conditional
  isLight-based classes using bg-brand-gray-900 (standard UI surface) in
  dark mode instead of the paper-colored bg-brand-gray-850.
- Scene summary baseline: After user saves a scene via handleSaveScene,
  explicitly advance the baseline with the computed nextScenes to prevent
  user-initiated edits from appearing as diffs on re-open.
- CodeMirror history: Add Transaction.addToHistory.of(false) to all 11
  compartment reconfigure dispatches so extension reconfigurations don't
  break CodeMirror's input event grouping (per-letter undo checkpoints).
- SceneEditorDialog: Add FloatingDiffToolbar integration, AcceptedBaseline
  local overrides, and data-diff markers for section-level diff highlighting.
- TDD: Add baseline-advance test in ScenesPanelContainer (verifies
  setBaselineState called with updated scene), dark-theme tests in
  FloatingDiffToolbar, and diff-rule spec tests in SceneEditorDialog.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add story scenes for plot arc

1 participant