Skip to content

feat: rewrite Improv tool — scenario-first tavern flows, cross-entity context, LLM-backed generation with fallback#2

Closed
jmwashi wants to merge 2 commits intomainfrom
codex/implement-full-rewrite-in-cohesive-pr
Closed

feat: rewrite Improv tool — scenario-first tavern flows, cross-entity context, LLM-backed generation with fallback#2
jmwashi wants to merge 2 commits intomainfrom
codex/implement-full-rewrite-in-cohesive-pr

Conversation

@jmwashi
Copy link
Copy Markdown
Owner

@jmwashi jmwashi commented Mar 12, 2026

Motivation

  • Replace a generic, mode-based improv prompt with a scenario-first flow (tavern, bartender, suspicious patron, rumor, complication) so DMs get immediate, table-ready seeds.
  • Allow the improv tool to pull facts from across the world model (not just items) and default to session/scene references for quick reuse.
  • Centralize context assembly and generation logic so multiple UIs can reuse the same synthesis and LLM/fallback behavior.
  • Provide structured LLM output (schema-first) while guaranteeing usable fallback beats when no provider/config is available.

Description

  • Replaced the session improv UI with a scenario-first tavern flow in src/renderer/src/pages/Sessions/ImprovToolTab.tsx including input fields and DM-ready output cards for dialogueOpener, motive, secret, escalationBeat, and fallbackBeat.
  • Added a cross-entity context selector (Characters, Locations, Factions, Items, Lore, Notes, Scenes) that is campaign-filtered and defaults to session referenced entities + active scene via getDefaultImprovEntityRefs in src/renderer/src/lib/improv/context.ts.
  • Introduced shared improv utilities under src/renderer/src/lib/improv/: types.ts (contracts), context.ts (context synthesis and formatting), and generate.ts (LLM integration with JSON-schema expectations and fallbackGenerate for robust fallback outputs).
  • Integrated generation wiring into the session UX by adding an Improv tab to the session sidebar and rendering ImprovToolTab from SessionDetail, and added lightweight defensive typing/formatting tweaks to the new files.

Testing

  • Ran npm run lint (executed repository lint) and it failed due to pre-existing, repository-wide lint/type style issues outside the scope of this PR; failures are unrelated to the improv feature.
  • Ran npm run typecheck and both node and web type checks passed successfully.
  • Verified the renderer dev server with npx vite and captured a Playwright screenshot of the improv tab UI; Electron runtime failed to launch in this environment due to a missing system library (libatk-1.0.so.0), so full Electron smoke-test was not possible.
  • Validation notes: the LLM-available path was inspected to confirm the request uses configured VITE_LLM_* or local improvTool.llmConfig, requests a json_schema response, and only accepts outputs that satisfy required keys (returns usedFallback: false and diagnostics on success); the fallback path was validated by code paths for missing config, non-OK HTTP responses, missing/malformed content, schema mismatch, and request exceptions, and always produces complete, DM-usable beats via fallbackGenerate.

Codex Task

@jmwashi jmwashi closed this Mar 29, 2026
@jmwashi jmwashi deleted the codex/implement-full-rewrite-in-cohesive-pr branch March 29, 2026 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant