Skip to content

[codex] Fix web chat refresh active thread - #2330

Merged
ilblackdragon merged 1 commit into
stagingfrom
codex/issue-2285-chat-refresh
Apr 12, 2026
Merged

ilblackdragon merged 1 commit into
stagingfrom
codex/issue-2285-chat-refresh

Conversation

@serrrfirat

Copy link
Copy Markdown
Collaborator

Summary

  • Reopen the server-reported active chat thread on first web UI load instead of always falling back to the assistant thread.
  • Keep assistant fallback behavior when there is no active thread.
  • Add an E2E regression for refresh without a thread hash restoring the active non-assistant thread history.

Root Cause

On page refresh, the frontend loaded /api/chat/threads but ignored the active_thread field when currentThreadId was empty. It selected the pinned assistant thread by default, so an in-flight non-assistant thread disappeared from the browser while the backend continued processing it.

Fixes #2285.

Validation

  • node --check crates/ironclaw_gateway/static/app.js
  • CARGO_TARGET_DIR=/Volumes/NVME/ironclaw-upstream/target /Volumes/NVME/ironclaw-upstream/tests/e2e/.venv/bin/pytest scenarios/test_sse_reconnect.py::test_refresh_without_hash_reopens_active_thread_history -q --timeout=300

@github-actions github-actions Bot added size: M 50-199 changed lines risk: low Changes to docs, tests, or low-risk modules contributor: core 20+ merged PRs labels Apr 11, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the frontend to automatically reopen the server's active thread upon initial load if no thread is specified in the URL hash. It also refines the logic for retrieving thread metadata to correctly handle the assistant thread's read-only status. Additionally, an end-to-end test has been added to verify that the active thread is preserved after a page refresh without a URL hash. I have no feedback to provide.

@ilblackdragon ilblackdragon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

Overview

Fixes #2285 where browser refresh always fell back to the assistant thread instead of restoring the server's active thread. loadThreads() now consults data.active_thread before falling back. Includes an E2E regression test.

Analysis

The fix is correct. Priority ordering: URL hash > server active_thread > assistant fallback. The _pendingThreadRestore path still runs first, so explicit URL hashes win.

Minor Issue

The three new return; statements skip the read-only channel detection block below. If the active thread is a read-only channel (e.g., Telegram), chat input won't be disabled on first load. It self-corrects after the next loadThreads() cycle, so it's a transient bug. Pre-existing (the _pendingThreadRestore path had the same issue), but this PR widens it to more code paths. Consider whether switchThread() / switchToAssistant() should internally handle the read-only state, or remove the early returns and fall through to the existing read-only check.

E2E Test

Well-structured: creates thread, sends message, strips URL hash, reloads, verifies active thread restoration and message history visibility.

Verdict: Approve — Clean, focused fix with good regression test. The read-only transient issue is pre-existing and minor.

@ilblackdragon
ilblackdragon marked this pull request as ready for review April 12, 2026 13:43
Copilot AI review requested due to automatic review settings April 12, 2026 13:43
@ilblackdragon
ilblackdragon merged commit ed2d6dc into staging Apr 12, 2026
16 checks passed
@ilblackdragon
ilblackdragon deleted the codex/issue-2285-chat-refresh branch April 12, 2026 13:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the web gateway chat’s refresh behavior by restoring the server-reported active thread (when the URL lacks a thread hash) instead of always falling back to the pinned assistant thread, and adds an E2E regression test to prevent the issue from returning.

Changes:

  • Update loadThreads() to prefer data.active_thread when currentThreadId is unset, with assistant-thread fallback preserved.
  • Adjust channel/read-only detection to correctly resolve the assistant thread object when it’s the selected thread.
  • Add an E2E test covering refresh-without-hash restoring a non-assistant active thread’s history.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
crates/ironclaw_gateway/static/app.js Uses /api/chat/threads’ active_thread to restore the correct visible thread after refresh; keeps assistant fallback.
tests/e2e/scenarios/test_sse_reconnect.py Adds a regression test ensuring refresh without a hash reopens the active non-assistant thread and preserves its messages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

This was referenced Apr 13, 2026
This was referenced Apr 17, 2026
@henrypark133 henrypark133 mentioned this pull request Apr 21, 2026
theredspoon pushed a commit to theredspoon/ironclaw that referenced this pull request Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor: core 20+ merged PRs risk: low Changes to docs, tests, or low-risk modules size: M 50-199 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[QA] Web UI: refresh without thread hash restores assistant thread instead of active non-assistant thread

3 participants