Skip to content

Recover cleanly from stale thread routes and eliminate root-route preload errors #127

Description

@redxzeta

Parent: #125
Priority: P1

Problem

Forkara can restore a persisted thread UUID that no longer has a valid thread-detail snapshot, leaving the URL/thread model inconsistent with the visible workspace.

Hands-on testing reproduced a persisted route like:

/45c1f864-ab00-45fa-a34e-32ad59321dba

while the backend repeatedly reported:

Thread detail snapshot not found for thread 45c1f864-ab00-45fa-a34e-32ad59321dba

The shell could still render a mostly usable new-thread/project surface, so the app looked recovered while the route continued to reference a nonexistent thread.

The same root/restore path also reproducibly emitted a TanStack Router preload exception:

TypeError: Cannot read properties of undefined (reading '_nonReactive')
  at loadRouteMatch(...@tanstack_react-router...)
  at loadMatches(...)
  at RouterCore.preloadRoute(...)

Opening a known-valid thread directly rendered normally, which suggests the primary defect is stale persisted-route recovery rather than general thread rendering.

Goal

Treat a missing/restored thread as a normal recoverable state: clear the stale persisted target, navigate to a clean home/new-thread route, and stop retrying backend detail reads for a thread that does not exist.

Desired behavior

restore persisted thread
        ↓
thread exists? ── yes → render normally
        │
        no
        ↓
clear stale persisted target
        ↓
navigate/replace to clean new-thread or home state
        ↓
no repeated missing-thread RPC stream

Required work

  • Trace startup/root-route restoration and persisted latest-thread selection.
  • Identify why a missing thread can remain authoritative after backend reconciliation says it does not exist.
  • Ensure client-side deleted/missing-thread reconciliation happens before or atomically with route restoration.
  • Do not leave a missing UUID in the address bar while rendering an unrelated new-thread surface.
  • Investigate the _nonReactive preload failure and determine whether Forkara is asking TanStack Router to preload an invalid/transient route match.
  • Fail closed on invalid route targets rather than repeatedly retrying the same missing thread detail snapshot.
  • Preserve valid existing-thread deep links and normal resume behavior.

Acceptance criteria

  • Starting Forkara with a persisted nonexistent thread id lands on a clean valid route without manual intervention.
  • The missing id is removed/replaced from the URL and persisted navigation state.
  • Thread detail snapshot not found is not repeatedly streamed for the same stale thread after recovery.
  • The root-route recovery path does not emit the TanStack Router _nonReactive preload exception.
  • Direct navigation to a valid thread UUID still renders that thread normally.
  • Browser/integration coverage includes:
    • valid persisted thread
    • missing persisted thread
    • deleted thread that was previously active
    • root / restore behavior
  • Recovery uses route replacement where appropriate so Back does not immediately return to the stale route.

Non-goals

  • Do not hide the exception with a broad console filter.
  • Do not disable route preloading globally unless proven necessary.
  • Do not discard valid thread-resume behavior.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementRequested improvement or new capability.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions