Find a file
Ivan Kolos 6ef35f9f30
Some checks are pending
Rust Lint / Format (push) Waiting to run
Rust Lint / Clippy (push) Waiting to run
Report automatic chapter creation in a card in the story (#619)
## Summary

When a turn pushes a story past its chapter threshold, the app analyses
the span, writes a chapter summary and runs lore management. None of
that was visible from the story. It started after the turn's activity
record had closed, and the analysis and summary had no indicator at all.
Lore management showed only on the Lorebook tab. Their failures went to
the log and nowhere else, and a failed lore management run was never
retried for that span.

This PR reports that work in the story. A chapter creation card appears
after the turn that cut the chapter and carries its own activity record.

## Changes

**The turn's record covers its post-narration work**
- Style review and chapter check now record under **After the turn**.
The record stays open until they settle, but the input is freed as soon
as the narration is in, as before. Neither step is recorded when it
isn't due.
- Until a card appears, the spinner under the latest entry says what's
still running: "Checking for a new chapter...", "Reviewing the prose
style...", or both.

**Chapter creation card** (`ChapterCreationCard.svelte`,
`services/chapterCreation/`, `stores/chapterCards.svelte.ts`)
- **What it is:** virtual, never a story entry, held for the session
only, and shown only on its own story and branch. It sits right after
the narration of the turn whose check cut the chapter. It starts as soon
as the check decides, without waiting for the style review.
- **Status line:** left-aligned, with the record's total time beside it:
"Writing a summary", "Updating the lorebook", then "Finished".
- **Record:** the chapter summary, then lore management.
- Each model call is named, from the moment it starts, for why the loop
makes it: "Review the lorebook against Chapter 7", "Continue after
reading Chapter 5", "Resolve 2 open duplicate groups", "Sum up: step
limit reached".
- Each tool call is a step beside the model calls. Chapter reads are LLM
steps with their retry attempts beneath them.
- **Saving changes** has one step per lorebook write. The agent only
approves changes; they're written after it finishes, in a loop now moved
into `saveLoreSession`.
- **When it finishes:** with banners on, **Go to Chapter N** (lands on
the banner) and **Dismiss**. With banners off, "Chapter creation is
finished" and **Dismiss**.
- **On failure:** the status reads "Writing a summary — failed" or
"Updating the lorebook — failed", with only "failed" in red.
- A failed summary offers **Retry** and **Dismiss**. Retry is offered
only while the span is still the first one no chapter covers.
- Failed lore management, or a run refused because another lore run
(such as Tidy) holds the branch, offers **Restart lore management** and
**Delete incomplete chapter**. Delete confirms first and says how many
lore changes stay.
- Both kinds of failure also raise a warning toast, since the reader may
already be on the next turn or another branch.

**Activity recorder** (`services/activity/`)
- Holds several records open at once. A step goes to the record of its
parent, to the record named by the new `recordId` option, or else to the
newest open turn, which is where parentless generation steps already
went.
- Records come in two kinds: `turn`, bounded by `RETAINED_TURNS`, and
`chapter`, which lives as long as its card. `reopenRecord` lets a retry
or restart record into the same card, and returns a new object so views
showing it re-read it.
- The streaming entry now finds its record by its own entry id, not
"newest open turn".

**When a report opens**
- A step that finished with an error it worked around, such as a
salvaged classification, now opens the report like a failed step.
- A failure that arrives after the reader expanded or collapsed a report
opens it again. Each record counts its failures, and a stored choice
applies only while that count is unchanged.

**Branch safety and overlap**
- The chapter number now comes from the chapters captured at the turn,
not from whichever branch is open. `story.addChapter` takes the
chapter's scope: it always writes the row, but adds the chapter to the
loaded list only while that branch is open.
- Lore management's input thunk refuses to start once the turn's branch
is no longer open, instead of reasoning over another branch's lorebook.
- A turn skips its chapter check while a card on that branch is still
summarizing or running lore management, or while any lore management run
holds the branch. Previously, two automatic checks could cut overlapping
chapters.

**Errors recorded instead of only logged**
- The style review, chapter check, summary and lore management now
record their failures with reasons.
- The style reviewer now reports the failure it absorbs on its result.
- `aiService.queryChapter` returns a chapter answer together with the
failure it absorbed. The retrieval path is unchanged.

**Docs:** `docs/architecture/overview.md` (activity reporting, chapter
creation cards, background tasks) and
`docs/architecture/lore-management.md` (when writes happen, the lock's
skipped report, how a run reads in the record).

## Known gaps, left for later

- **A failure is forgotten on restart.** The card is held in memory
only, so after the app restarts, a chapter whose lore management failed
has nothing pointing at it.
- **No rollback for a partial save.** A lore run that fails while saving
can't be rolled back: the writes before the failure stay.
- **No retry attempts under agent model calls.** Agent model calls
(retrieval and lore management) record no attempt rows, because the
agent factory doesn't use the activity middleware.

## Testing

- `npm run check`: 0 errors, 0 warnings.
- `npm test`: 2524 passed, 9 skipped. New or extended tests cover:
  - the recorder's routing, retention, reopening and failure count
  - `ChapterService` check and create
- the background coordinator's two stages, retry, and the card starting
before the style review settles
  - the card state transitions and warnings
  - the lore coordinator's recorded step
  - `saveLoreSession`
  - the lore service's model-call and tool steps, and the step labels
  - the style review scheduler
  - activity parents reaching each model call
- `npm run lint`: no errors (existing warnings only); rustfmt and clippy
are clean.
- **Not yet verified in the running app:**
- the card's forms with banners on and off, and the three reporting
settings
- the failure flows (summary, lore, Tidy skip) with Retry, Restart and
Delete
  - a branch switch mid-run
  - the toasts and the post-turn spinner
  - the report re-opening on a later failure

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added chapter-creation cards showing progress and failures, with
options to retry summaries, restart lore management, or dismiss
incomplete work. Completed cards can link to the chapter’s starting
point.
* Chapter creation can proceed while a style review is still running,
with progress and outcomes shown in activity records.
* Activity records now show progress and outcomes for chapter checks,
summaries, style reviews, and lore management, including concurrent
chapter work.
* **Bug Fixes**
* Prevented chapter work from applying to a story or branch that has
changed, and avoided chapter checks or manual creation while related
work is underway.
* Limited chapter deletion to the last chapter and improved failure
visibility in activity records.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 18:30:59 -04:00
.cargo Add Incognito Keyboard option for Android (#467) 2026-08-26 20:45:30 -04:00
.github Upgrade to SvelteKit 3, TypeScript 6 and vitest 5, and bump dependencies (#615) 2026-10-12 12:29:54 -04:00
docs Report automatic chapter creation in a card in the story (#619) 2026-10-17 18:30:59 -04:00
scripts Key Rust caches on the dependency set and stop caching Gradle (#612) 2026-10-11 21:31:21 -04:00
src Report automatic chapter creation in a card in the story (#619) 2026-10-17 18:30:59 -04:00
src-tauri Keep GPU rendering on NVIDIA Wayland outside the AppImage (#627) 2026-10-17 15:27:12 -04:00
static switched font for logo 2026-01-19 14:48:22 -06:00
third-party-licenses Added harper 2026-01-02 05:08:39 -07:00
.gitattributes Fix CRLF Migrations (#162) 2026-02-22 15:46:59 -05:00
.gitignore Cache Gradle again and share one npm cache entry on Linux (#613) 2026-10-12 00:49:33 -04:00
.nvmrc Overhaul CI/CD: Node 24, shared release workflows, faster cached builds (#518) 2026-09-16 22:38:32 -04:00
.prettierrc fix: prettier, eslint, pipeline (#71) 2026-02-06 00:49:36 +01:00
CLAUDE.md WIP, Part 1 of 2 - State Tracking: record every world-state write, and create checkpoints at past entries (#618) 2026-10-16 21:14:03 -04:00
compileApk.sh Android build hygiene: minSdk 26, lint in CI, resource cleanup (#468) 2026-08-29 21:52:01 -04:00
eslint.config.js Upgrade to SvelteKit 3, TypeScript 6 and vitest 5, and bump dependencies (#615) 2026-10-12 12:29:54 -04:00
lefthook.yml Run Clippy on push and in CI, and split lint into lint:ts and lint:rust (#608) 2026-10-11 14:50:50 -04:00
LICENSE.md Db rework (#140) (#141) 2026-02-13 17:37:27 +05:30
logo.png switched font for logo 2026-01-19 14:48:22 -06:00
package-lock.json Upgrade to SvelteKit 3, TypeScript 6 and vitest 5, and bump dependencies (#615) 2026-10-12 12:29:54 -04:00
package.json Upgrade to SvelteKit 3, TypeScript 6 and vitest 5, and bump dependencies (#615) 2026-10-12 12:29:54 -04:00
README.md Upgrade to SvelteKit 3, TypeScript 6 and vitest 5, and bump dependencies (#615) 2026-10-12 12:29:54 -04:00
sun4.jpg Use custom icon for android 2026-01-03 07:08:45 -07:00
sun17.jpg Use custom icon for android 2026-01-03 07:08:45 -07:00
sun2022.png Use custom icon for android 2026-01-03 07:08:45 -07:00
tsconfig.json Type-check vitest.config.ts and note TypeScript 6's strict default (#616) 2026-10-12 13:27:22 -04:00
vite.config.js Upgrade to SvelteKit 3, TypeScript 6 and vitest 5, and bump dependencies (#615) 2026-10-12 12:29:54 -04:00
vitest.config.ts Upgrade to SvelteKit 3, TypeScript 6 and vitest 5, and bump dependencies (#615) 2026-10-12 12:29:54 -04:00

Aventuras

Interactive fiction with an AI that remembers. Play a text adventure or write collaboratively, on desktop and Android, with any LLM provider you like — cloud or running on your own machine.

Aventuras keeps the story straight: chapters are summarized as you play, a lorebook feeds the right entries into the right scene, an agent tidies that lorebook behind you, and the world state — who is present, where you are, what you carry — is tracked turn by turn.

Highlights

  • Two modes — Adventure, with multiple-choice actions and world tracking; Creative Writing, freeform with AI suggestions. First/second/third person, past or present tense.
  • Any provider — OpenRouter, OpenAI, Anthropic, Google, xAI, Groq, DeepSeek, Mistral, Z.AI, NanoGPT, Chutes, Pollinations, NVIDIA NIM, plus local llama.cpp, LM Studio and Ollama. Streaming, extended thinking, and per-subsystem Agent Profiles so retrieval, classification and narration can each use a different model.
  • Memory that scales — automatic chapter summarization, and a retrieval step that goes and finds what the current scene needs from everything that came before.
  • Lorebook — characters, locations, items, factions, concepts and events, with aliases, secrets, keyword and relevance-based injection, SillyTavern import, and an autonomous agent that consolidates duplicates and fills gaps.
  • The Vault — a cross-story library of reusable characters, lorebooks and scenarios, with a tool-calling assistant that edits them and shows you a diff before anything lands.
  • Every prompt is editable — they are Liquid templates, all of them, in an in-app editor.
  • Images — inline <pic> illustrations, scene backgrounds and character portraits, across nine backends including local ComfyUI and A1111.
  • Writing tools — local grammar checking (Harper/WASM), style analysis for repetition, suggestions that match how you write.
  • Yours to keep — SQLite on your machine, full backup/restore, .avt story export, LAN sync between devices over QR pairing, and an optional translation layer over the whole app.
  • 26 themes, adjustable text size, dialogue highlighting.

Install

Pre-built binaries are on the Releases page:

Platform Download Minimum
Windows Aventuras_vX.Y.Z_x64-setup.exe Windows 10
macOS Aventuras_vX.Y.Z_x64.dmg / _aarch64.dmg macOS 13.3
Linux Aventuras_vX.Y.Z_amd64.deb / .AppImage, or _x86_64.rpm WebKitGTK 2.40 for the .deb / .rpm; the AppImage carries its own, needs glibc 2.35
Android Aventuras_vX.Y.Z.apk Android 8, with System WebView 111 or later
iOS Aventuras_vX.Y.Z_ios-arm64-unsigned.ipa (sideload; unsigned) iOS 16.4

The minimums come from each platform's web engine, OS and runtime requirements. They are derived from documentation and have not been tested on devices at those versions; see docs/development/platform-support.md.

No API keys in config files — providers are set up in the app, under Settings → API Settings.

Build from source

Requires the Node.js version in .nvmrc, the latest stable Rust, (for Android) the Android SDK, NDK r27d and JDK 21–24, and (for iOS) a Mac with Xcode.

git clone https://github.com/AventurasTeam/Aventuras.git
cd Aventuras
npm install
npx tauri dev
Script Does
npm run dev Vite dev server (frontend only)
npx tauri dev full app, with hot reload
npm run build production build
npm run check type checking (svelte-check)
npm test test suite (Vitest)
npm run lint lint:ts (ESLint) and lint:rust (rustfmt, Clippy); :fix fixes
npm run format Prettier
npm run release version bump, tag and push

Desktop builds are npx tauri build; Android and iOS are documented in docs/development/release.md. iOS produces an unsigned device .ipa (no Apple certificates or signing secrets — see docs/development/ios-build-target.md for the full account of how the target was added and how the unsigned CI pipeline works).

Tech stack

TypeScript (strict) · SvelteKit 3 · Svelte 5 runes · Tauri 2 (Rust) · Tailwind + bits-ui · SQLite (tauri-plugin-sql / sqlx) · Vercel AI SDK · LiquidJS · CodeMirror 6 · Zod · Harper.js (WASM) · Vitest

Contributing

Start with docs/ — the architecture is documented per area, and CLAUDE.md has the conventions. CI runs lint, type-check, tests and a build on every PR against master, develop or dev.

Acknowledgments

Tauri · SvelteKit · OpenRouter · Harper · Lucide

License

AGPL-3.0