Title: fix(copilot): stop async chat auto-titling from clobbering an explicit rename by waleedlatif1 · Pull Request #7414 · simstudioai/sim · GitHub
Open Graph Title: fix(copilot): stop async chat auto-titling from clobbering an explicit rename by waleedlatif1 · Pull Request #7414 · simstudioai/sim
X Title: fix(copilot): stop async chat auto-titling from clobbering an explicit rename by waleedlatif1 · Pull Request #7414 · simstudioai/sim
Description: Summary Chat title generation is fired at turn start and resolves asynchronously, but its write was unconditional: await db.update(copilotChats).set({ title }).where(eq(copilotChats.id, chatId)) The guard that decides whether to generate a title (if (!chatId || currentChat?.title || !isNewChat) return) evaluates a snapshot taken at request start. The write then happens much later with no re-check — a classic check-then-write (TOCTOU) race. If a user renames the chat while the title is being generated, the generated title lands afterward and silently overwrites the rename. This is reachable in normal use: rename a chat shortly after sending the first message and the rename can disappear. Fix Make the write conditional on the title still being unset, so a generated title can only ever fill an empty slot: .where(and(eq(copilotChats.id, chatId), isNull(copilotChats.title))) copilotChats.title is nullable with no default, so isNull is exactly the "no title yet" state. The update is atomic, so the explicit rename deterministically wins. When the write loses the race (0 rows), the follow-up title notification is skipped as well — we should not announce a title the row no longer holds. Both auto-title call sites are fixed, since they had the identical unconditional write: lib/copilot/request/lifecycle/start.ts — the interactive turn path lib/mothership/inbox/executor.ts — the inbox task path Why not "eliminate the race" instead The concurrency is inherent — an async background title generator runs alongside user actions, and awaiting it would block the turn on a title LLM call. The race cannot be removed, only made well-defined; a conditional (compare-and-set) update is the standard way to do that, and it makes the outcome deterministic: an explicit title always wins, a generated one only fills a gap. Testing tsc --noEmit and biome clean. Existing unit tests for both changed paths pass (start.test.ts, executor.test.ts — 13 tests). This also removes the root cause of a flaky integration check that asserted a forked chat inherits its parent's renamed title. Type of change Bug fix (non-breaking)
Open Graph Description: Summary Chat title generation is fired at turn start and resolves asynchronously, but its write was unconditional: await db.update(copilotChats).set({ title }).where(eq(copilotChats.id, chatId)) Th...
X Description: Summary Chat title generation is fired at turn start and resolves asynchronously, but its write was unconditional: await db.update(copilotChats).set({ title }).where(eq(copilotChats.id, chatId)) Th...
Opengraph URL: https://github.com/simstudioai/sim/pull/7414
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:410e0e1b-5446-9f68-59aa-5f1a74971427 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | A92E:870C9:3A2E50:532114:6AFB3A1E |
| html-safe-nonce | 7cb265304316ebb2dac0c77b258baa6a90809a04cb8282aada03dd1fc4b0b3c3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOTJFOjg3MEM5OjNBMkU1MDo1MzIxMTQ6NkFGQjNBMUUiLCJ2aXNpdG9yX2lkIjoiODYwNzQ4NjU3NDY1MDQwNzQ1NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 35d9f8f955dc50695ff1e6db28cdfcdd17217e6918abff90f8b73ac185b85ef4 |
| hovercard-subject-tag | pull_request:4426512168 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/7414/files |
| twitter:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| og:image:alt | Summary Chat title generation is fired at turn start and resolves asynchronously, but its write was unconditional: await db.update(copilotChats).set({ title }).where(eq(copilotChats.id, chatId)) Th... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2169b0dfbef67ed6b128074a5ed45bb7d5d1859783b10178b09a7765ad5f3693 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3b4fc8df5ef1c6757e733a23e6b81b6725021823 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width