Commit 2799994
fix(desktop): reopen a chat on the browser tab the user left it on (#7793)
* fix(desktop): reopen a chat on the browser tab the user left it on
The resource strip pushed its own last-tab fallback onto the desktop app
whenever a chat opened without an explicit selection, overriding the tab
the desktop remembers the user was on. The shared desktop-tab hook now
switches the native tab only for an explicit selection, adopts the
desktop's active tab when the strip is on its fallback, and defers a
selected tab that has not landed yet until it does. Chat hydration no
longer writes a browser or terminal tab into the URL as a fallback.
* fix(desktop): adopt the remembered tab without claiming the user's selection
Review round on the reopen fix.
A late first report of the desktop app's active tab carries the tab it
remembers, not a switch the user made, so it is adopted rather than
claimed and agent activity can still take the view on chat open. A move
away from a tab the desktop was already showing stays the user's own.
Adoption now waits for the chat history to be applied, so the arrival
order of the tab list and the history no longer decides which resource a
chat opens on, and it skips a tab the strip has already dropped, so
closing the shown tab cannot write the closed id back. Closing the shown
tab selects its neighbour the way the desktop app picks the next native
tab, instead of flashing through the strip's last tab.
The two wrapper hooks now share one options type with the strip, and the
adopt rule lives in a single helper.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139YonWmiZUnPMTHoH4PtAJ
* fix(desktop): show a selected tab that arrives after the tab list
The effect that shows an explicitly selected tab was keyed on the
selection alone, so a selection made before the desktop app published
its tab list was dropped rather than applied when the tab arrived. It is
now keyed on that tab being live as well, which covers the late arrival
without a retry ref to arm and disarm.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139YonWmiZUnPMTHoH4PtAJ
* refactor(desktop): align the two tab-adoption paths and drop dead plumbing
Quality pass on the reopen fix.
The late-arrival adoption now carries the same guards as the hydrated
one, so a first report of the desktop app's active tab can no longer
override a selection the user made before the tab list arrived. Both
guards are pinned by tests that fail when either is removed.
The predicate the adopt and claim paths share moved into one helper, so
the single difference between them — adoption needs the tab to still be
in the strip, following the user does not — is stated once. Removes a
ref nothing read and an options interface with no second consumer.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139YonWmiZUnPMTHoH4PtAJ
* test(desktop): give the tab-resource hosts the shared options interface
The test hosts took their props through a type alias derived from the
hook signature. The repo asks for an interface, and the hook already
exports one that is exactly this shape, so the hosts use it directly
instead of restating it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139YonWmiZUnPMTHoH4PtAJ
* fix(desktop): resolve the shown tab instead of writing it back
Reopening a chat could show the wrong page for as long as the chat
history took to load. The strip wrote the desktop app's remembered tab
into the selection from an effect, and that write had to wait for the
history or the arrival order would decide what the chat opened on. With
the history held back 2.5s, an instrumented run showed the wrong page
for 2164ms before it corrected.
The rule is now a pure function: an explicit selection wins, otherwise
the last resource, except that a desktop-backed last resource defers to
the tab the desktop app is showing. Nothing is written back, so the
gate, the passive setter and the effect behind them are gone, and the
same run now shows the remembered page immediately.
A native switch is claimed as the user's against the tab the desktop app
was showing rather than the one the strip shows, since with no explicit
selection those are now the same tab. Closing the shown tab prefers a
neighbour of its own kind, so the strip and the desktop app agree on
what comes next.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139YonWmiZUnPMTHoH4PtAJ
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 1a7c827 commit 2799994
10 files changed
Lines changed: 358 additions & 162 deletions
File tree
- apps/sim/app/workspace/[workspaceId]/home
- components/mothership-view/components/resource-tabs
- hooks
Lines changed: 21 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
408 | 408 | | |
409 | 409 | | |
410 | 410 | | |
411 | | - | |
| 411 | + | |
| 412 | + | |
412 | 413 | | |
413 | 414 | | |
414 | 415 | | |
415 | 416 | | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
416 | 426 | | |
417 | 427 | | |
418 | 428 | | |
| |||
451 | 461 | | |
452 | 462 | | |
453 | 463 | | |
454 | | - | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
455 | 474 | | |
456 | 475 | | |
457 | 476 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
227 | | - | |
| 227 | + | |
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
| |||
317 | 317 | | |
318 | 318 | | |
319 | 319 | | |
320 | | - | |
| 320 | + | |
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
| |||
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
337 | | - | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
338 | 342 | | |
339 | 343 | | |
340 | 344 | | |
341 | 345 | | |
342 | 346 | | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
| 347 | + | |
| 348 | + | |
355 | 349 | | |
356 | 350 | | |
357 | 351 | | |
| |||
Lines changed: 65 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
| 41 | + | |
51 | 42 | | |
52 | 43 | | |
53 | 44 | | |
| |||
60 | 51 | | |
61 | 52 | | |
62 | 53 | | |
63 | | - | |
64 | | - | |
| 54 | + | |
| 55 | + | |
65 | 56 | | |
66 | 57 | | |
67 | 58 | | |
| 59 | + | |
68 | 60 | | |
69 | 61 | | |
70 | 62 | | |
71 | 63 | | |
72 | 64 | | |
73 | 65 | | |
74 | 66 | | |
75 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
76 | 73 | | |
77 | 74 | | |
78 | 75 | | |
| |||
153 | 150 | | |
154 | 151 | | |
155 | 152 | | |
156 | | - | |
| 153 | + | |
157 | 154 | | |
158 | 155 | | |
159 | 156 | | |
160 | | - | |
| 157 | + | |
161 | 158 | | |
162 | 159 | | |
163 | 160 | | |
| |||
169 | 166 | | |
170 | 167 | | |
171 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
172 | 218 | | |
173 | 219 | | |
174 | 220 | | |
175 | 221 | | |
176 | 222 | | |
177 | 223 | | |
178 | | - | |
| 224 | + | |
179 | 225 | | |
180 | 226 | | |
181 | 227 | | |
182 | 228 | | |
183 | 229 | | |
184 | 230 | | |
185 | 231 | | |
186 | | - | |
| 232 | + | |
187 | 233 | | |
188 | 234 | | |
189 | 235 | | |
| |||
192 | 238 | | |
193 | 239 | | |
194 | 240 | | |
| 241 | + | |
195 | 242 | | |
196 | 243 | | |
197 | 244 | | |
| |||
Lines changed: 4 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
10 | | - | |
| 9 | + | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | 18 | | |
27 | 19 | | |
28 | 20 | | |
| |||
31 | 23 | | |
32 | 24 | | |
33 | 25 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
| 26 | + | |
| 27 | + | |
43 | 28 | | |
44 | 29 | | |
45 | 30 | | |
| |||
64 | 49 | | |
65 | 50 | | |
66 | 51 | | |
| 52 | + | |
67 | 53 | | |
68 | | - | |
69 | 54 | | |
70 | 55 | | |
71 | 56 | | |
72 | 57 | | |
73 | 58 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | 59 | | |
81 | 60 | | |
82 | 61 | | |
| |||
0 commit comments