Skip to content

Assistant: restore shows an error on the benign 404, and drops the session id on 5xx #1524

Description

@dannon

The restore effect in app/hooks/useAssistantChat.ts:97-101 catches every failure the same way:

.catch(() => {
  if (cancelled) return;
  if (!initialSessionId) localStorage.removeItem(SESSION_KEY);
  setError("Failed to restore the previous conversation.");
})

Two problems, and they are inverses of each other:

  • 404 is benign. The session expired (2h TTL) or was flushed (Assistant: startup cache flush wipes all live sessions #1523). Nothing is broken -- the right behavior is to clear the stale localStorage pointer and silently start a fresh conversation. Instead the user gets an error banner on a page they just loaded.
  • 5xx / timeout is the real failure, and it is the one case where we should NOT clear localStorage. The session may still be alive server-side; dropping the pointer turns a transient blip into permanent loss of the conversation for that user.

So the fix is to branch on status: 404 -> remove the key, no error banner. Anything else -> keep the key, show a retryable error.

This came up in the beta-readiness review as the "session-restore data loss" item. The startup flush in #1523 makes it fire considerably more often than that review assumed.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status
No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions