Commit 4a94ca1
fix(rs): sync soft-close to sidebar + double-click reopens last closed session
Two related session-lifecycle bugs surfaced after PR #221 made the
spawn-side properly persist session rows for paths that previously
fell into the free-floating branch:
1. **Closed sessions never appeared in the sidebar's history
disclosure.** `AppShell::soft_close_session` correctly stamped
`closed_at` on the in-memory `ProjectsConfig` and saved it to
disk, but never pushed the result to the `Sidebar` entity. The
sidebar keeps its own `projects` copy and builds the per-worktree
history bucket off it at render time, so the new `closed_at` row
stayed invisible until the next sidebar-side mutation (add /
remove project, rename) happened to refresh the snapshot. Mirror
the `replace_projects` + `cx.notify()` push `reopen_session`
already does for the reverse transition. Plumbs `cx` through
`soft_close_session` (sole caller is `close_tab`, which already
has a `Context<Self>`).
2. **Double-clicking a worktree always spawned a fresh session,
even when the user already had a closed one for it.** Expected
behaviour (matching C# `MainViewModel.OnTreeDoubleClick`):
double-click is the "pick up where I left off" gesture; explicit
"New session" / "New <agent> session" menu rows are the only way
to force a brand-new spawn. The `SidebarEvent::OpenSession`
handler now resolves in three tiers:
1. An open tab for this `wd` exists → focus it.
2. A soft-closed session for this `wd` exists → reopen the
most-recently-closed one. Path match uses `paths_match` so
a slash-convention mismatch between the event payload and
the persisted `worktree_path` doesn't drop the hit (same
rule PR #221 applied to `locate_project_for_path`).
Newest-first ordering matches the sidebar history
disclosure, so a double-click reopens exactly the row the
user sees at the top.
3. Otherwise → spawn a fresh session (same path `force_new`
takes unconditionally).
`force_new` still short-circuits straight to spawn — the
explicit-new gesture is unchanged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 7d2a033 commit 4a94ca1
1 file changed
Lines changed: 76 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
814 | 814 | | |
815 | 815 | | |
816 | 816 | | |
817 | | - | |
818 | | - | |
819 | | - | |
820 | | - | |
821 | | - | |
822 | | - | |
823 | | - | |
824 | | - | |
825 | | - | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
826 | 834 | | |
| 835 | + | |
827 | 836 | | |
828 | 837 | | |
829 | 838 | | |
| |||
840 | 849 | | |
841 | 850 | | |
842 | 851 | | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
843 | 888 | | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
844 | 894 | | |
845 | 895 | | |
846 | 896 | | |
| |||
2491 | 2541 | | |
2492 | 2542 | | |
2493 | 2543 | | |
2494 | | - | |
| 2544 | + | |
| 2545 | + | |
| 2546 | + | |
| 2547 | + | |
| 2548 | + | |
| 2549 | + | |
| 2550 | + | |
| 2551 | + | |
| 2552 | + | |
| 2553 | + | |
2495 | 2554 | | |
2496 | 2555 | | |
2497 | 2556 | | |
| |||
2504 | 2563 | | |
2505 | 2564 | | |
2506 | 2565 | | |
| 2566 | + | |
2507 | 2567 | | |
| 2568 | + | |
| 2569 | + | |
| 2570 | + | |
| 2571 | + | |
| 2572 | + | |
2508 | 2573 | | |
2509 | 2574 | | |
2510 | 2575 | | |
| |||
3215 | 3280 | | |
3216 | 3281 | | |
3217 | 3282 | | |
3218 | | - | |
| 3283 | + | |
3219 | 3284 | | |
3220 | 3285 | | |
3221 | 3286 | | |
| |||
0 commit comments