Skip to content

fix(cloud-agent): prevent repeated session-not-found toast and query loop#1185

Merged
eshurakov merged 1 commit intomainfrom
eshurakov/cloud-agent-repeated-session-not-found
Mar 17, 2026
Merged

fix(cloud-agent): prevent repeated session-not-found toast and query loop#1185
eshurakov merged 1 commit intomainfrom
eshurakov/cloud-agent-repeated-session-not-found

Conversation

@eshurakov
Copy link
Contributor

Summary

When navigating to a non-existent session URL, the cloud agent UI would repeatedly query the server and show "Session not found" / "Failed to load session" toasts. This happened because loadedDbSessionIdRef was only set on the success path of the loadFromDb effect — when the session wasn't found, the ref stayed unset, so any dependency change in the effect (12 dependencies in the next version) would re-trigger it, firing another query and another toast.

The fix moves loadedDbSessionIdRef.current = sessionIdFromParams into the finally block so it's set regardless of success or failure, ensuring the effect runs exactly once per session ID.

Applied to both cloud-agent-next and cloud-agent (legacy) implementations.

Verification

  • pnpm typecheck — passed (all workspace projects)
  • prettier --check — passed
  • eslint — passed (all workspace projects)
  • Manually tested locally — navigating to a non-existent session URL now shows a single toast and stops querying

Visual Changes

N/A

Reviewer Notes

The fix is intentionally minimal — a one-line move in each file. The finally block guarantees the ref is always set, which is the correct guard behavior: we've already attempted loading this session ID, so there's no reason to retry it on re-renders.

@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Mar 17, 2026

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0

Fix these issues in Kilo Cloud

Issue Details (click to expand)

WARNING

File Line Issue
src/components/cloud-agent-next/CloudChatContainer.tsx 528 Setting loadedDbSessionIdRef in finally suppresses retries after transient load failures.
src/components/cloud-agent/CloudChatContainer.tsx 420 Setting loadedDbSessionIdRef in finally suppresses retries after transient load failures.
Other Observations (not in diff)

None.

Files Reviewed (2 files)
  • src/components/cloud-agent-next/CloudChatContainer.tsx - 1 issue
  • src/components/cloud-agent/CloudChatContainer.tsx - 1 issue

Reviewed by gpt-5.4-20260305 · 237,777 tokens

@eshurakov eshurakov merged commit b7ce59f into main Mar 17, 2026
18 checks passed
@eshurakov eshurakov deleted the eshurakov/cloud-agent-repeated-session-not-found branch March 17, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants