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 — v0.6.62: fix new copilot chat creation and selection on refresh by TheodoreSpeaks · Pull Request #4342 · simstudioai/sim

Conversation

@TheodoreSpeaks

@TheodoreSpeaks TheodoreSpeaks commented Apr 29, 2026

Copy link
Copy Markdown
Contributor
  • fix(copilot): fix new task error (fix(copilot): fix new task error #4341)

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
fix(copilot): fix new task error (#4341)
8d042f7
* fix(copilot): fix new task error

* Keep recent copilot chat open on refresh
@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:46pm

Request Review

All reactions

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
Scoped UI state/cache changes to Copilot chat selection; minimal blast radius, with main risk being incorrect list ordering or stale cache behavior.

Overview
Fixes a race in the Copilot panel where creating a new chat could immediately be de-selected because the selected chatId wasn’t yet present in the cached chat list.

The auto-select effect now waits for a non-empty list before selecting a default chat, and handleCopilotNewChat now seeds the new chat into the React Query cache (copilotChatsKeys.list(workflowId)) before setting copilotChatId, then triggers a refetch to reconcile.

Reviewed by Cursor Bugbot for commit 8d042f7. 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.

@greptile-apps

greptile-apps Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR correctly addresses two interlinked bugs in the copilot panel. Bug 1: autoSelectAttemptedForRef was marked before the empty-list check, so a workflow with an initially empty list would never auto-select once chats loaded. The fix moves the length === 0 guard before the ref mutation. Bug 2: newly created chats were immediately deselected because the auto-select effect saw a stale list and cleared copilotChatId. The fix optimistically seeds the new chat into the React Query cache via queryClient.setQueryData before calling setCopilotChatId, so the effect finds the chat in the list and leaves it selected.

Confidence Score: 5/5

Safe to merge — targeted, well-reasoned fixes with no regressions introduced.

Both changes are minimal and correct: the auto-select guard reordering is straightforwardly sound, and the optimistic cache seed matches the exact CopilotChatListItem shape. No new state is introduced and the subsequent invalidateQueries reconciles the cache with the server. No P0 or P1 findings.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/panel.tsx Fixes two related copilot chat bugs: auto-select skipping on empty list at first render, and newly created chat being immediately deselected — resolved by reordering the guard and optimistically seeding the React Query cache before selecting

Sequence Diagram

sequenceDiagram
    participant U as User
    participant C as handleCopilotNewChat
    participant QC as QueryClient Cache
    participant S as setCopilotChatId
    participant E as Auto-select Effect
    participant API as /api/copilot/chats

    U->>C: clicks "New Chat"
    C->>API: POST /api/copilot/chats
    API-->>C: { id: "new-chat-id" }
    Note over C: Before fix: setCopilotChatId then loadCopilotChats
    C->>QC: setQueryData — seed new chat into list cache
    C->>S: setCopilotChatId("new-chat-id")
    S-->>E: triggers auto-select effect
    E->>QC: reads copilotChatList (contains seeded chat)
    Note over E: copilotChatId set AND found in list → no deselect
    C->>QC: invalidateQueries (loadCopilotChats)
    QC->>API: GET /api/copilot/chats
    API-->>QC: updated list (includes new chat)
Loading

Reviews (1): Last reviewed commit: "fix(copilot): fix new task error (#4341)" | 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 ecbf5e5 into main Apr 29, 2026
31 checks passed

Uh oh!

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

This branch was previously deployed

1 inactive deployment
Preview — 8d042f7d 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

No reviews

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 01402503 — 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.