GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(copilot): fix new task error by TheodoreSpeaks · Pull Request #4341 · simstudioai/sim

Conversation

@TheodoreSpeaks

@TheodoreSpeaks TheodoreSpeaks commented Apr 29, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Summary

Our recent fixes to copilot chat unintentionally broke the new copilot chat creation logic. Fixed the chat id selection logic so chat id is only set when its loaded.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

  • Tested locally, validated that copilot chats can be sent, switching works as intended, and new chats don't break anything. Validated refreshes work.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Screenshots/Videos

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

greptile-apps[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
TheodoreSpeaks added 2 commits April 29, 2026 11:27
@TheodoreSpeaks
fix(copilot): fix new task error
81f221b
@TheodoreSpeaks
Keep recent copilot chat open on refresh
07ee8e5
@vercel

vercel Bot commented Apr 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 29, 2026 6:30pm

Request Review

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TheodoreSpeaks

TheodoreSpeaks commented Apr 29, 2026

Copy link
Copy Markdown
Contributor Author

@BugBot review

cursor[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cursor

cursor Bot commented Apr 29, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

PR Summary

Low Risk
Low risk UI/state fix limited to Copilot chat selection and React Query caching; main risk is subtle regressions in chat auto-selection across workflow switches.

Overview
Fixes Copilot chat auto-selection so it only selects when the chat list has loaded (skipping selection when the list is empty).

When creating a new Copilot chat, it now seeds the new chat into the React Query list cache before selecting it, preventing the auto-select effect from immediately clearing the selected chatId due to a stale chat list.

Reviewed by Cursor Bugbot for commit 07ee8e5. Bugbot is set up for automated code reviews on this repo. Configure here.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TheodoreSpeaks
TheodoreSpeaks marked this pull request as ready for review April 29, 2026 18:32
cursor[bot]
cursor Bot reviewed Apr 29, 2026
View reviewed changes

@cursor cursor Bot left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 07ee8e5. Configure here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@greptile-apps

greptile-apps Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes two related regressions in the copilot chat panel. First, autoSelectAttemptedForRef was being marked before the empty-list guard, so a still-loading list would permanently suppress auto-selection. Second, creating a new chat would immediately be deselected because the auto-select effect saw an ID not yet present in the (stale) React Query list; the fix optimistically seeds the new item into the cache before calling setCopilotChatId, closing the race window.

Confidence Score: 5/5

Safe to merge — targeted, well-reasoned fix with no new logic risks introduced.

Both changes are minimal and directly address the described regressions. The optimistic cache seed correctly matches the CopilotChatListItem shape and is replaced by the server response after loadCopilotChats invalidates. The auto-select tracking order change is a simple guard reordering with no side-effects. No P1 or P0 issues found.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/panel.tsx Two-part bug fix: (1) defers auto-select tracking until the chat list is non-empty so stale-load doesn't permanently skip auto-selection; (2) optimistically seeds the new chat into the React Query cache before selecting it to prevent the auto-select effect from immediately deselecting the freshly created ID.

Sequence Diagram

sequenceDiagram
    participant U as User
    participant C as handleCopilotNewChat
    participant QC as QueryClient cache
    participant S as setCopilotChatId
    participant E as autoSelect useEffect
    participant API as /api/copilot/chats

    U->>C: Click "New Chat"
    C->>API: POST /api/copilot/chats
    API-->>C: { id: "new-id" }
    C->>QC: setQueryData — prepend new chat to list
    C->>S: setCopilotChatId("new-id")
    C->>QC: invalidateQueries (loadCopilotChats)
    Note over E: Effect fires with updated list + copilotChatId set
    E->>E: copilotChatId found in list → no deselect
    QC-->>E: server refetch arrives, list still contains new chat
    E->>E: copilotChatId still set → return early ✓
Loading

Reviews (1): Last reviewed commit: "Keep recent copilot chat open on refresh" | Re-trigger Greptile

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TheodoreSpeaks
TheodoreSpeaks merged commit 8d042f7 into staging Apr 29, 2026
14 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@TheodoreSpeaks
TheodoreSpeaks deleted the fix/new-copilot-chat branch April 29, 2026 18:39
@TheodoreSpeaks TheodoreSpeaks mentioned this pull request Apr 29, 2026
v0.6.62: fix new copilot chat creation and selection on refresh #4342
Merged

This branch was previously deployed

1 inactive deployment
Preview — 07ee8e50 Deployed Apr 29, 2026 by vercel[bot]
View deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@cursor cursor[bot] cursor[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@TheodoreSpeaks
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.