这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Oct 17, 2025

What problem(s) was I solving?

  • Fixed an issue where the response input editor content was not properly clearing or updating when switching between different Claude Code sessions (ENG-2203)
  • The editor was retaining content from the previous session, causing confusion and potential data leakage between sessions
  • Users would see old text in the input field when switching to a different session, requiring manual clearing

What user-facing changes did I ship?

  • The response input editor now automatically clears when switching to a different session that has no saved draft
  • The editor properly loads any saved draft content for the newly selected session
  • The editor defensively saves the current content before switching sessions to prevent data loss
  • Both active sessions (using localStorage) and draft sessions (using database storage) now handle session switching correctly

How I implemented it

  • Added a useEffect hook in both ActiveSessionInput.tsx and DraftLauncherInput.tsx that tracks session ID changes
  • Implemented a reference (prevSessionIdRef) to track the previous session ID and detect when the user switches sessions
  • When a session change is detected:
    1. Defensive save: The current editor content is saved to the previous session's storage (localStorage for active sessions, database for drafts) - this is a safety measure as the content should already be saved via the onChange handler
    2. Load new content: The appropriate saved content for the new session is loaded from storage
    3. Clear or populate: If there's saved content for the new session, it's loaded into the editor; otherwise, the editor is cleared
  • Added comprehensive error handling and logging to track session switching behavior and debug any issues
  • Ensured the solution works for both session types with their different storage mechanisms

How to verify it

Manual Testing

  • Open CodeLayer with multiple Claude Code sessions
  • Type some text in the response input for Session A
  • Switch to Session B - verify the input clears (or shows Session B's saved draft)
  • Type different text in Session B's input
  • Switch back to Session A - verify Session A's text is restored
  • Test with both active/running sessions and draft sessions
  • Verify no console errors appear during session switching
  • Test rapid switching between sessions to ensure stability

Automated Testing

  • Tests pass: npm test
  • Build succeeds: npm run build

Description for the changelog

Fixed response input editor not clearing when switching between Claude Code sessions, preventing content from one session appearing in another

claude and others added 2 commits October 20, 2025 15:29
Add proper session change detection and editor content management to both ActiveSessionInput and DraftLauncherInput components. This ensures that:
- Content is defensively saved when switching away from a session
- Editor is properly cleared when switching to a new session
- Editor correctly loads saved content for the new session
- Proper logging is added for debugging session switches

The fix handles both active sessions (using localStorage) and draft sessions (using database editorState).
@balanceiskey balanceiskey force-pushed the linear-assistant/eng-2203-responseinput-state-not-cleared-when-switching-sessions branch from 96b9716 to 2e16681 Compare October 20, 2025 20:33
@balanceiskey balanceiskey merged commit 52dc943 into main Oct 20, 2025
6 checks passed
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.

3 participants