[GH-ISSUE #1667] Echo Chamber reload crashes entire app (blank/frozen window) — wrong deserialization shape + no root error boundary #832

Closed
opened 2026-10-21 05:21:37 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @aeriondyseti on GitHub (May 30, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1667

Originally assigned to: @cha1latte on GitHub.

Summary

Reopening a chat that has persisted Echo Chamber results crashes the entire app
with an uncaught TypeError. Because there is no root-level error boundary, the
crash unmounts the whole React tree, leaving an empty #root — which on the
frameless (decorations: false) Tauri window presents as a solid-colour,
frozen, un-draggable window with no visible error
.

This is a deterministic data-contract bug, not environment- or state-specific.
Any user who has run the echo-chamber agent and then reloads/reopens that chat
will hit it.

The error

TypeError: undefined is not an object (evaluating 'msg.characterName.length')
  at EchoChamberPanel.tsx  (nameColorMap useMemo)

Root cause

There are two independent defects that compound:

Bug A — reload path deserializes the wrong shape (the crash)

Echo runs are persisted as agent-runs rows whose payload is nested:

{
  "resultType": "echo_message",
  "resultData": {
    "reactions": [
      { "characterName": "…", "reaction": "…" }
    ]
  }
}

(Confirmed against real on-disk data: 26/26 echo rows use this nested shape.)

  • The live SSE path reads it correctly — use-generate.ts:680-686 flattens
    data.reactions[] and calls addEchoMessage(characterName, text).

  • The reload path does NOT. EchoChamberPanel.tsx:122 asserts a flat shape:

    storageApi.list<{ characterName: string; reaction: string; timestamp: number }>("agent-runs", …)
    

    The row has no top-level characterName (it's two levels down in
    resultData.reactions[]), so every msg.characterName is undefined, and
    nameColorMap's msg.characterName.length throws.

The list<T>() generic is an unchecked cast, so tsc validated a shape that
never exists on disk. The crash only surfaces with real persisted data, which is
why it passes typecheck and a clean profile but dies on any profile with echo
history.

Bug B — no root error boundary (severity multiplier)

The only error boundary in src/ is inside EncounterModal. A single component
throw therefore takes down the whole app silently. Turning a localized data bug
into "the entire window is dead and shows nothing" is the actual reason this was
so hard to diagnose.

Proposed fix

  1. Bug A: make the reload path flatten resultData.reactions[] exactly like
    use-generate.ts does, ideally extracting a single shared parser
    (parseMaybeRecord/readString already exist) so the two readers can't drift
    again. Correct the list<T>() type to the real stored shape.
  2. Bug B: add a root-level error boundary above App that renders the error
    instead of unmounting to a blank screen.
  3. Consider parsing/validating (e.g. Zod) at the storage I/O boundary rather than
    asserting shapes via generics, to kill this defect class.

Repro

  1. Use a profile that has run the Echo Chamber agent (has echo_message rows in
    agent-runs).
  2. Reopen that chat (or reload the app).
  3. App renders briefly, then goes blank/frozen.

Environment

Surfaced under pnpm tauri dev (WebKitGTK). Not WebKitGTK-specific — it also
throws in a plain browser when echo rows are present; the blank-window
presentation is specific to the frameless Tauri window.

Originally created by @aeriondyseti on GitHub (May 30, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1667 Originally assigned to: @cha1latte on GitHub. ## Summary Reopening a chat that has persisted Echo Chamber results crashes the **entire** app with an uncaught `TypeError`. Because there is no root-level error boundary, the crash unmounts the whole React tree, leaving an empty `#root` — which on the frameless (`decorations: false`) Tauri window presents as a **solid-colour, frozen, un-draggable window with no visible error**. This is a deterministic data-contract bug, not environment- or state-specific. Any user who has run the `echo-chamber` agent and then reloads/reopens that chat will hit it. ## The error ``` TypeError: undefined is not an object (evaluating 'msg.characterName.length') at EchoChamberPanel.tsx (nameColorMap useMemo) ``` ## Root cause There are **two independent defects** that compound: ### Bug A — reload path deserializes the wrong shape (the crash) Echo runs are persisted as `agent-runs` rows whose payload is nested: ```jsonc { "resultType": "echo_message", "resultData": { "reactions": [ { "characterName": "…", "reaction": "…" } ] } } ``` (Confirmed against real on-disk data: 26/26 echo rows use this nested shape.) - The **live SSE path** reads it correctly — `use-generate.ts:680-686` flattens `data.reactions[]` and calls `addEchoMessage(characterName, text)`. - The **reload path** does NOT. `EchoChamberPanel.tsx:122` asserts a flat shape: ```ts storageApi.list<{ characterName: string; reaction: string; timestamp: number }>("agent-runs", …) ``` The row has no top-level `characterName` (it's two levels down in `resultData.reactions[]`), so every `msg.characterName` is `undefined`, and `nameColorMap`'s `msg.characterName.length` throws. The `list<T>()` generic is an **unchecked cast**, so `tsc` validated a shape that never exists on disk. The crash only surfaces with real persisted data, which is why it passes typecheck and a clean profile but dies on any profile with echo history. ### Bug B — no root error boundary (severity multiplier) The only error boundary in `src/` is inside `EncounterModal`. A single component throw therefore takes down the whole app *silently*. Turning a localized data bug into "the entire window is dead and shows nothing" is the actual reason this was so hard to diagnose. ## Proposed fix 1. **Bug A:** make the reload path flatten `resultData.reactions[]` exactly like `use-generate.ts` does, ideally extracting a single shared parser (`parseMaybeRecord`/`readString` already exist) so the two readers can't drift again. Correct the `list<T>()` type to the real stored shape. 2. **Bug B:** add a root-level error boundary above `App` that renders the error instead of unmounting to a blank screen. 3. Consider parsing/validating (e.g. Zod) at the storage I/O boundary rather than asserting shapes via generics, to kill this defect class. ## Repro 1. Use a profile that has run the Echo Chamber agent (has `echo_message` rows in `agent-runs`). 2. Reopen that chat (or reload the app). 3. App renders briefly, then goes blank/frozen. ## Environment Surfaced under `pnpm tauri dev` (WebKitGTK). Not WebKitGTK-specific — it also throws in a plain browser when echo rows are present; the blank-window *presentation* is specific to the frameless Tauri window.
bsakaguchi 2026-10-21 05:21:37 +07:00
Author
Owner

@cha1latte commented on GitHub (May 30, 2026):

fixed in #1678

<!-- gh-comment-id:4584851378 --> @cha1latte commented on GitHub (May 30, 2026): fixed in #1678
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#832
No description provided.