René's URL Explorer Experiment


Title: fix(chat): stop losing sends aborted during mount-settling by j15z · Pull Request #6525 · simstudioai/sim · GitHub

Open Graph Title: fix(chat): stop losing sends aborted during mount-settling by j15z · Pull Request #6525 · simstudioai/sim

X Title: fix(chat): stop losing sends aborted during mount-settling by j15z · Pull Request #6525 · simstudioai/sim

Description: Summary Sends started on a fresh chat surface were silently dropped when the hook's unmount cleanup ran mid-flight and aborted the in-flight POST. The AbortError read as a user stop, the optimistic pair rolled back, and — because MothershipHandoffStorage.consume() clears atomically — the replacement mount found nothing left to retry. This is what made cross-route auto-send handoffs (cmd+k Ask Sim, logs "Troubleshoot in Chat") lose messages. Root cause (corrected). An earlier revision of this PR attributed the remount to "a Suspense hide/reveal cycling every effect." That is not what happens: React 19 disappears layout effects only when a mounted Suspense boundary re-suspends, and the cleanup in question (use-chat.ts, the abort('unmount:client_cleanup') teardown) is a passive effect, so a Suspense hide/reveal never runs it. Verified directly against react-dom@19.2.4: mount → layout:setup, passive:setup re-suspend → layout:cleanup ← passive:cleanup never fires reveal → layout:setup What does run it mid-flight is a genuine remount: StrictMode's dev double-mount (deterministic — it fires on every cross-route handoff in dev) and a real client-side navigation away while the send is still in flight. The cleanup's deps are all stable useCallbacks, so nothing else triggers it. Changes Idle-path sends go through the durable message queue instead of calling startSendMessage directly, so every send has a backing entry the dispatch loop can recover Aborts are detected by signal state, not error identity. Every abort() here passes a string reason, and fetch rejects with the raw reason — so err.name === 'AbortError' was false for all of them, and aborts (including user "stop") were falling through to the generic handler and surfacing Failed to send message. Fixing this is an independent correctness win A cleanup abort that strikes before the response headers arrive rolls back the optimistic pair and hands the message to recovery: the live replacement surface via the mothership-send-message event, or a one-shot stored handoff, or the restored queue entry for a chat-bound send. Attachments ride all three lanes Recovery probes the orphaned stream before re-sending. sendReachedServer only rules out a send whose response landed; the request itself may well have been accepted. app/api/mothership/chat/route.ts → lib/copilot/chat/post.ts never reads request.signal, so an accepted request still runs resolveOrCreateChat, persistUserMessage, and the billed turn to completion even though the client socket is gone. Re-sending blind would leave the user with two chats and two billed runs for one message. Recovery therefore carries the withdrawn send's userMessageId as a stream id and polls it (2.5s ceiling): resolving to a chat means the server already has the message, so that chat is adopted instead of sending again. Only a stream the server has no record of (404 — genuinely never accepted) re-sends; a timeout also re-sends, which is the safe direction Type of Change Bug fix Testing use-chat.mount-send mounts the real hook and runs the real cleanup mid-flight. Each of these fails on the unfixed hook: a cross-route handoff stays recoverable across a StrictMode double-mount (the production-shaped repro, driven by the thing that actually causes it rather than a hand-rolled unmount) an aborted chatless send is delivered to a live replacement surface, with attachments an aborted chatless send is re-persisted as a handoff when nothing claims the event a send the server already received is not re-queued recovery adopts the chat the server already created instead of sending twice (postCalls stays 1) recovery does re-send when the probe 404s Full home/hooks + stores/mothership-queue + lib/core/utils suites (364 tests), type-check, biome, and check:api-validation all pass. Known residual The probe narrows the duplicate window but does not close it: a server slower than the 2.5s ceiling still gets a second send. Closing it completely needs server-side idempotency on userMessageId in resolveOrCreateChat, which is a separate change with its own blast radius. 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)

Open Graph Description: Summary Sends started on a fresh chat surface were silently dropped when the hook's unmount cleanup ran mid-flight and aborted the in-flight POST. The AbortError read as a user stop, the optimi...

X Description: Summary Sends started on a fresh chat surface were silently dropped when the hook's unmount cleanup ran mid-flight and aborted the in-flight POST. The AbortError read as a user stop, the op...

Opengraph URL: https://github.com/simstudioai/sim/pull/6525

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,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-controllerpull_requests
route-actionfiles
fetch-noncev2:70ebae65-1781-2007-d7f1-2519c46af71e
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idBF20:143691:B5EC9:100A8D:6AFB45E7
html-safe-nonce609c1c2f1f84815e50bad1a9241be9c99973d220ba365a12b77170756ec7bebe
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRjIwOjE0MzY5MTpCNUVDOToxMDBBOEQ6NkFGQjQ1RTciLCJ2aXNpdG9yX2lkIjoiODcwNjM3OTQ1MDc3MTI2MDkwMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac4e938affd0c7a844d7233389c26230c60b7b74b6306440af5fb4977c31206b93
hovercard-subject-tagpull_request:4249898439
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/6525/files
twitter:imagehttps://avatars.githubusercontent.com/u/96924014?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/96924014?s=400&v=4
og:image:altSummary Sends started on a fresh chat surface were silently dropped when the hook's unmount cleanup ran mid-flight and aborted the in-flight POST. The AbortError read as a user stop, the optimi...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noned849b928f455c800985398e7f1b659425adb312a5fa14fba5d9a14e62e9fe5dd
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/simstudioai/sim git https://github.com/simstudioai/sim.git
octolytics-dimension-user_id199344406
octolytics-dimension-user_loginsimstudioai
octolytics-dimension-repository_id912559512
octolytics-dimension-repository_nwosimstudioai/sim
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id912559512
octolytics-dimension-repository_network_root_nwosimstudioai/sim
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasea6c2f87cbcb6414452377b4967858ed6a66f1109
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/simstudioai/sim/pull/6525/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F6525%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F6525%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=simstudioai%2Fsim
Reloadhttps://github.com/simstudioai/sim/pull/6525/files
Reloadhttps://github.com/simstudioai/sim/pull/6525/files
Reloadhttps://github.com/simstudioai/sim/pull/6525/files
simstudioaihttps://github.com/simstudioai
simhttps://github.com/simstudioai/sim
Codehttps://github.com/simstudioai/sim
Issues129 (129)https://github.com/simstudioai/sim/issues
Pull requests199 (199)https://github.com/simstudioai/sim/pulls
Actionshttps://github.com/simstudioai/sim/actions
Projectshttps://github.com/simstudioai/sim/projects
Security and qualityhttps://github.com/simstudioai/sim/security
Insightshttps://github.com/simstudioai/sim/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
j15zhttps://github.com/j15z
staginghttps://github.com/simstudioai/sim/tree/staging
fix/mship-mount-send-losshttps://github.com/simstudioai/sim/tree/fix/mship-mount-send-loss
Conversation 48 https://github.com/simstudioai/sim/pull/6525
Commits 12 https://github.com/simstudioai/sim/pull/6525/commits
Checks 30 https://github.com/simstudioai/sim/pull/6525/checks
Files changed https://github.com/simstudioai/sim/pull/6525/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6525/files
fix(chat): stop losing sends aborted during mount-settling https://github.com/simstudioai/sim/pull/6525/files#top
Show all changes 12 commits https://github.com/simstudioai/sim/pull/6525/files
04147f7 fix(chat): stop losing sends aborted during mount-settling j15z Aug 11, 2026 https://github.com/simstudioai/sim/pull/6525/commits/04147f7401a513033fce82258b7ee8a947acd70e
b840a3a fix(chat): detect aborts by signal state, not error identity j15z Aug 11, 2026 https://github.com/simstudioai/sim/pull/6525/commits/b840a3a15335b877c4cb4d8a36d4095baec9eb65
cd23af8 fix(chat): hand an aborted chatless send to the next mount j15z Aug 11, 2026 https://github.com/simstudioai/sim/pull/6525/commits/cd23af8b994b284a0b10484c8393d9502fc85a0a
ed4ea7c fix(chat): deliver an aborted chatless send to the live replacement s… j15z Aug 11, 2026 https://github.com/simstudioai/sim/pull/6525/commits/ed4ea7cc3dbb726f64440c536b8e2b426b1338bb
d078e82 refactor(chat): thread the recoverable-abort outcome through the send… j15z Aug 11, 2026 https://github.com/simstudioai/sim/pull/6525/commits/d078e823dacb3f1eb423099539e9f6513097c8a8
81716ff fix(chat): carry attachments through the cross-mount send handoff j15z Aug 11, 2026 https://github.com/simstudioai/sim/pull/6525/commits/81716ffd131e50de4686c09b338bf4d9b28ccda1
45357cb fix(panel): forward event attachments to the copilot send j15z Aug 11, 2026 https://github.com/simstudioai/sim/pull/6525/commits/45357cb851f5cef133d79b71cc2516758ac72c60
3e67769 fix(chat): carry attachments through the stored handoff lane too j15z Aug 11, 2026 https://github.com/simstudioai/sim/pull/6525/commits/3e677696cda920e000ef7c404fcbaf32660b8a52
b84001d fix(chat): probe the orphaned stream before re-sending a withdrawn send waleedlatif1 Aug 11, 2026 https://github.com/simstudioai/sim/pull/6525/commits/b84001dd2b5cb343469add1c84a6132b58f1c0c2
d6a5238 fix(chat): never re-send on an unresolved probe, and reconnect after … waleedlatif1 Aug 11, 2026 https://github.com/simstudioai/sim/pull/6525/commits/d6a5238d620d7152f80fb62dea931449ff255f09
39e2a84 test(chat): cover the departing surface's own recovery-event claim waleedlatif1 Aug 11, 2026 https://github.com/simstudioai/sim/pull/6525/commits/39e2a845450c11d42bcf1e2a63563d5c08bae9db
45013a4 fix(chat): hand off a chatless send when the probe is superseded waleedlatif1 Aug 11, 2026 https://github.com/simstudioai/sim/pull/6525/commits/45013a4edb72842fa06bc3b5dd31ea0f88338b68
Clear filters https://github.com/simstudioai/sim/pull/6525/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6525/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6525/files
home.tsx https://github.com/simstudioai/sim/pull/6525/files#diff-eb66b9102ddc0010fd22549f03941b3c32eecdcef27b7ee4efc52a84e1c3ba83
use-chat.mount-send.test.tsx https://github.com/simstudioai/sim/pull/6525/files#diff-9f2c022a72a0c3ca7686691ebd743065a87c326e151587fb518ce594c4c9338a
use-chat.ts https://github.com/simstudioai/sim/pull/6525/files#diff-1a0584ccf9cc4bacd55ce19aeeea8d807c39f36c365fa5b6638587aad38c700d
panel.tsx https://github.com/simstudioai/sim/pull/6525/files#diff-a5104cb2e061f06aafd1ed7e52c94682826ac914de7755b827cfde111661b54b
browser-storage.ts https://github.com/simstudioai/sim/pull/6525/files#diff-32aeb777aa84abec058370c350ef61e17af04b4ad37244ce193e02cf076e0e6a
events.ts https://github.com/simstudioai/sim/pull/6525/files#diff-f7e608162b8307f9c529fbf1e388eb601f07dd6ab95beeca71933fd3fcc7670d
store.ts https://github.com/simstudioai/sim/pull/6525/files#diff-f9609bb09028d5fea616b8fbeca370d62c6a6d20f6dc460fed34a8a0594dce70
types.ts https://github.com/simstudioai/sim/pull/6525/files#diff-66995a79415f1ef4665bc2e86e1d1a9d3b0d0babf5f62114dc92f09880c1d1ae
apps/sim/app/workspace/[workspaceId]/home/home.tsxhttps://github.com/simstudioai/sim/pull/6525/files#diff-eb66b9102ddc0010fd22549f03941b3c32eecdcef27b7ee4efc52a84e1c3ba83
View file https://github.com/simstudioai/sim/blob/45013a4edb72842fa06bc3b5dd31ea0f88338b68/apps/sim/app/workspace/%5BworkspaceId%5D/home/home.tsx
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6525/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/6525/files#diff-eb66b9102ddc0010fd22549f03941b3c32eecdcef27b7ee4efc52a84e1c3ba83
https://github.com/simstudioai/sim/pull/6525/files#diff-eb66b9102ddc0010fd22549f03941b3c32eecdcef27b7ee4efc52a84e1c3ba83
https://github.com/simstudioai/sim/pull/6525/files#diff-eb66b9102ddc0010fd22549f03941b3c32eecdcef27b7ee4efc52a84e1c3ba83
https://github.com/simstudioai/sim/pull/6525/files#diff-eb66b9102ddc0010fd22549f03941b3c32eecdcef27b7ee4efc52a84e1c3ba83
Please reload this pagehttps://github.com/simstudioai/sim/pull/6525/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6525/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.