refactor(usecase/palette,picker): delete dead remote session result and preview size helpers
NewRemoteSessionResult has no production caller: the palette's remote rows (Phase E3) are not wired through it. Its three test call sites are removed, except TestReplaceResultsPreservesExactSelection in model_test.go, which is rewritten against NewActiveSessionResultWithDisplayOrigin (a live constructor) to keep ReplaceResults' exact-selection-preservation-across- reorder behavior covered, since it was the only test of that behavior. picker.PreviewSize has no caller anywhere, production or test: both the client and the daemon compute their own preview viewport locally now (pickerPreviewSize, remotePickerPreviewSize).
- commit
- e3742276a5118e3634b697f59df8d32c1795305b
- author
- brice · · 2026-09-23 01:55 UTC
- parent
- 5e1cc30
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
5 files · +7 -45
M internal/usecase/palette/fuzzy_test.go +0 -10
| @@ -4,7 +4,6 @@ import ( | |||
| 4 | 4 | "testing" | |
| 5 | 5 | "time" | |
| 6 | 6 | ||
| 7 | - | "github.com/bnema/vev/internal/domain" | |
| 8 | 7 | "github.com/bnema/vev/internal/protocol" | |
| 9 | 8 | "github.com/bnema/vev/internal/usecase/command" | |
| 10 | 9 | "github.com/stretchr/testify/require" | |
| @@ -104,15 +103,6 @@ func TestFuzzyRanksExactSessionNameAheadOfPrefix(t *testing.T) { | |||
| 104 | 103 | wantFirst: "Resume session vev@arch", | |
| 105 | 104 | offset: 15, | |
| 106 | 105 | }, | |
| 107 | - | { | |
| 108 | - | name: "remote catalog session", | |
| 109 | - | results: []Result{ | |
| 110 | - | NewRemoteSessionResult(domain.RemoteSessionKey{Host: "arch", Name: "vev-vt", DisplayOrigin: "arch"}, domain.RemoteSessionTarget{}, ""), | |
| 111 | - | NewRemoteSessionResult(domain.RemoteSessionKey{Host: "arch", Name: "vev", DisplayOrigin: "arch"}, domain.RemoteSessionTarget{}, ""), | |
| 112 | - | }, | |
| 113 | - | wantFirst: "Switch to session vev@arch", | |
| 114 | - | offset: 18, | |
| 115 | - | }, | |
| 116 | 106 | { | |
| 117 | 107 | name: "recent route", | |
| 118 | 108 | results: []Result{ | |
| @@ -4,7 +4,6 @@ import ( | |||||
| 4 | "testing" | 4 | "testing" | ||
| 5 | "time" | 5 | "time" | ||
| 6 | 6 | ||||
| 7 | - | "github.com/bnema/vev/internal/domain" | |||
| 8 | "github.com/bnema/vev/internal/protocol" | 7 | "github.com/bnema/vev/internal/protocol" | ||
| 9 | "github.com/bnema/vev/internal/usecase/command" | 8 | "github.com/bnema/vev/internal/usecase/command" | ||
| 10 | "github.com/stretchr/testify/require" | 9 | "github.com/stretchr/testify/require" | ||
| @@ -104,15 +103,6 @@ func TestFuzzyRanksExactSessionNameAheadOfPrefix(t *testing.T) { | |||||
| 104 | wantFirst: "Resume session vev@arch", | 103 | wantFirst: "Resume session vev@arch", | ||
| 105 | offset: 15, | 104 | offset: 15, | ||
| 106 | }, | 105 | }, | ||
| 107 | - | { | |||
| 108 | - | name: "remote catalog session", | |||
| 109 | - | results: []Result{ | |||
| 110 | - | NewRemoteSessionResult(domain.RemoteSessionKey{Host: "arch", Name: "vev-vt", DisplayOrigin: "arch"}, domain.RemoteSessionTarget{}, ""), | |||
| 111 | - | NewRemoteSessionResult(domain.RemoteSessionKey{Host: "arch", Name: "vev", DisplayOrigin: "arch"}, domain.RemoteSessionTarget{}, ""), | |||
| 112 | - | }, | |||
| 113 | - | wantFirst: "Switch to session vev@arch", | |||
| 114 | - | offset: 18, | |||
| 115 | - | }, | |||
| 116 | { | 106 | { | ||
| 117 | name: "recent route", | 107 | name: "recent route", | ||
| 118 | results: []Result{ | 108 | results: []Result{ | ||
M internal/usecase/palette/model_test.go +7 -15
| @@ -140,19 +140,11 @@ func TestCNSDestinationRefreshDoesNotPromoteCommandSelection(t *testing.T) { | |||
| 140 | 140 | require.False(t, ok, "entering multi-destination mode requires fresh navigation") | |
| 141 | 141 | } | |
| 142 | 142 | ||
| 143 | - | func TestReplaceResultsPreservesExactRemoteSelection(t *testing.T) { | |
| 144 | - | result := func(endpoint string, lifecycle byte) Result { | |
| 145 | - | key := domain.RemoteSessionKey{ | |
| 146 | - | Host: endpoint, Name: "vev", LifecycleID: domain.SessionLifecycleID{lifecycle}, DisplayOrigin: "arch", | |
| 147 | - | } | |
| 148 | - | target := domain.RemoteSessionTarget{ | |
| 149 | - | Endpoint: endpoint, DisplayOrigin: "arch", LifecycleID: key.LifecycleID, | |
| 150 | - | SessionName: "vev", LiveTabID: "tab-vev", | |
| 151 | - | } | |
| 152 | - | return NewRemoteSessionResult(key, target, "") | |
| 153 | - | } | |
| 154 | - | first := result("user@arch", 1) | |
| 155 | - | selected := result("admin@arch", 2) | |
| 143 | + | // TestReplaceResultsPreservesExactSelection proves ReplaceResults tracks the | |
| 144 | + | // selected result by its exact target through a reorder, not by its position. | |
| 145 | + | func TestReplaceResultsPreservesExactSelection(t *testing.T) { | |
| 146 | + | first := NewActiveSessionResultWithDisplayOrigin(testExactTarget("vev", 1), time.Time{}, "user@arch") | |
| 147 | + | selected := NewActiveSessionResultWithDisplayOrigin(testExactTarget("vev", 2), time.Time{}, "admin@arch") | |
| 156 | 148 | m := New([]Result{first, selected}) | |
| 157 | 149 | m.Down() | |
| 158 | 150 | ||
| @@ -160,9 +152,9 @@ func TestReplaceResultsPreservesExactRemoteSelection(t *testing.T) { | |||
| 160 | 152 | ||
| 161 | 153 | got, ok := m.Selected() | |
| 162 | 154 | require.True(t, ok) | |
| 163 | - | target, ok := got.RemoteSessionTarget() | |
| 155 | + | target, ok := got.SessionTarget() | |
| 164 | 156 | require.True(t, ok) | |
| 165 | - | require.Equal(t, "admin@arch", target.Endpoint) | |
| 157 | + | require.Equal(t, domain.SessionLifecycleID{2}, target.LifecycleID) | |
| 166 | 158 | } | |
| 167 | 159 | ||
| 168 | 160 | func TestModelInsertBackspaceAndSelectionClamp(t *testing.T) { | |
| @@ -140,19 +140,11 @@ func TestCNSDestinationRefreshDoesNotPromoteCommandSelection(t *testing.T) { | |||||
| 140 | require.False(t, ok, "entering multi-destination mode requires fresh navigation") | 140 | require.False(t, ok, "entering multi-destination mode requires fresh navigation") | ||
| 141 | } | 141 | } | ||
| 142 | 142 | ||||
| 143 | - | func TestReplaceResultsPreservesExactRemoteSelection(t *testing.T) { | 143 | + | // TestReplaceResultsPreservesExactSelection proves ReplaceResults tracks the |
| 144 | - | result := func(endpoint string, lifecycle byte) Result { | 144 | + | // selected result by its exact target through a reorder, not by its position. |
| 145 | - | key := domain.RemoteSessionKey{ | 145 | + | func TestReplaceResultsPreservesExactSelection(t *testing.T) { |
| 146 | - | Host: endpoint, Name: "vev", LifecycleID: domain.SessionLifecycleID{lifecycle}, DisplayOrigin: "arch", | 146 | + | first := NewActiveSessionResultWithDisplayOrigin(testExactTarget("vev", 1), time.Time{}, "user@arch") |
| 147 | - | } | 147 | + | selected := NewActiveSessionResultWithDisplayOrigin(testExactTarget("vev", 2), time.Time{}, "admin@arch") |
| 148 | - | target := domain.RemoteSessionTarget{ | |||
| 149 | - | Endpoint: endpoint, DisplayOrigin: "arch", LifecycleID: key.LifecycleID, | |||
| 150 | - | SessionName: "vev", LiveTabID: "tab-vev", | |||
| 151 | - | } | |||
| 152 | - | return NewRemoteSessionResult(key, target, "") | |||
| 153 | - | } | |||
| 154 | - | first := result("user@arch", 1) | |||
| 155 | - | selected := result("admin@arch", 2) | |||
| 156 | m := New([]Result{first, selected}) | 148 | m := New([]Result{first, selected}) | ||
| 157 | m.Down() | 149 | m.Down() | ||
| 158 | 150 | ||||
| @@ -160,9 +152,9 @@ func TestReplaceResultsPreservesExactRemoteSelection(t *testing.T) { | |||||
| 160 | 152 | ||||
| 161 | got, ok := m.Selected() | 153 | got, ok := m.Selected() | ||
| 162 | require.True(t, ok) | 154 | require.True(t, ok) | ||
| 163 | - | target, ok := got.RemoteSessionTarget() | 155 | + | target, ok := got.SessionTarget() |
| 164 | require.True(t, ok) | 156 | require.True(t, ok) | ||
| 165 | - | require.Equal(t, "admin@arch", target.Endpoint) | 157 | + | require.Equal(t, domain.SessionLifecycleID{2}, target.LifecycleID) |
| 166 | } | 158 | } | ||
| 167 | 159 | ||||
| 168 | func TestModelInsertBackspaceAndSelectionClamp(t *testing.T) { | 160 | func TestModelInsertBackspaceAndSelectionClamp(t *testing.T) { | ||
M internal/usecase/palette/result.go +0 -10
| @@ -138,16 +138,6 @@ func newSessionPayload(target protocol.ExactSessionTarget, createdAt time.Time, | |||
| 138 | 138 | return sessionPayload{display: SessionDisplay(target.SessionName, displayOrigin), createdAt: createdAt, target: target} | |
| 139 | 139 | } | |
| 140 | 140 | ||
| 141 | - | // NewRemoteSessionResult creates an immutable catalog-backed remote target. | |
| 142 | - | func NewRemoteSessionResult(key domain.RemoteSessionKey, target domain.RemoteSessionTarget, unavailableReason string) Result { | |
| 143 | - | return Result{ | |
| 144 | - | kind: ResultKindRemoteSession, | |
| 145 | - | remoteSession: remoteSessionPayload{ | |
| 146 | - | key: key, target: target, unavailableReason: unavailableReason, | |
| 147 | - | }, | |
| 148 | - | } | |
| 149 | - | } | |
| 150 | - | ||
| 151 | 141 | // NewImportedSessionResult creates an immutable inventory-relayed row. | |
| 152 | 142 | // Labels are never parsed back into selection authority: Enter resolves | |
| 153 | 143 | // through the opaque source/entry keys. | |
| @@ -138,16 +138,6 @@ func newSessionPayload(target protocol.ExactSessionTarget, createdAt time.Time, | |||||
| 138 | return sessionPayload{display: SessionDisplay(target.SessionName, displayOrigin), createdAt: createdAt, target: target} | 138 | return sessionPayload{display: SessionDisplay(target.SessionName, displayOrigin), createdAt: createdAt, target: target} | ||
| 139 | } | 139 | } | ||
| 140 | 140 | ||||
| 141 | - | // NewRemoteSessionResult creates an immutable catalog-backed remote target. | |||
| 142 | - | func NewRemoteSessionResult(key domain.RemoteSessionKey, target domain.RemoteSessionTarget, unavailableReason string) Result { | |||
| 143 | - | return Result{ | |||
| 144 | - | kind: ResultKindRemoteSession, | |||
| 145 | - | remoteSession: remoteSessionPayload{ | |||
| 146 | - | key: key, target: target, unavailableReason: unavailableReason, | |||
| 147 | - | }, | |||
| 148 | - | } | |||
| 149 | - | } | |||
| 150 | - | ||||
| 151 | // NewImportedSessionResult creates an immutable inventory-relayed row. | 141 | // NewImportedSessionResult creates an immutable inventory-relayed row. | ||
| 152 | // Labels are never parsed back into selection authority: Enter resolves | 142 | // Labels are never parsed back into selection authority: Enter resolves | ||
| 153 | // through the opaque source/entry keys. | 143 | // through the opaque source/entry keys. | ||
M internal/usecase/palette/result_origin_test.go +0 -2
| @@ -4,7 +4,6 @@ import ( | |||
| 4 | 4 | "testing" | |
| 5 | 5 | "time" | |
| 6 | 6 | ||
| 7 | - | "github.com/bnema/vev/internal/domain" | |
| 8 | 7 | "github.com/stretchr/testify/require" | |
| 9 | 8 | ) | |
| 10 | 9 | ||
| @@ -18,7 +17,6 @@ func TestSessionResultsAlwaysQualifyClientOrigin(t *testing.T) { | |||
| 18 | 17 | {"hybrid local", NewActiveSessionResultWithDisplayOrigin(testExactTarget("sample", 1), time.Time{}, "local"), "Switch to session sample@local"}, | |
| 19 | 18 | {"serving remote", NewActiveSessionResultWithDisplayOrigin(testExactTarget("sample", 1), time.Time{}, "host-a"), "Switch to session sample@host-a"}, | |
| 20 | 19 | {"imported local", NewImportedSessionResult("local", "key", "sample", "local", "up", ""), "Switch to session sample@local"}, | |
| 21 | - | {"discovered remote", NewRemoteSessionResult(domain.RemoteSessionKey{Name: "sample", Host: "user@host-a", DisplayOrigin: "host-a"}, domain.RemoteSessionTarget{}, ""), "Switch to session sample@host-a"}, | |
| 22 | 20 | } { | |
| 23 | 21 | t.Run(tc.name, func(t *testing.T) { require.Equal(t, tc.want, tc.result.DisplayText()) }) | |
| 24 | 22 | } | |
| @@ -4,7 +4,6 @@ import ( | |||||
| 4 | "testing" | 4 | "testing" | ||
| 5 | "time" | 5 | "time" | ||
| 6 | 6 | ||||
| 7 | - | "github.com/bnema/vev/internal/domain" | |||
| 8 | "github.com/stretchr/testify/require" | 7 | "github.com/stretchr/testify/require" | ||
| 9 | ) | 8 | ) | ||
| 10 | 9 | ||||
| @@ -18,7 +17,6 @@ func TestSessionResultsAlwaysQualifyClientOrigin(t *testing.T) { | |||||
| 18 | {"hybrid local", NewActiveSessionResultWithDisplayOrigin(testExactTarget("sample", 1), time.Time{}, "local"), "Switch to session sample@local"}, | 17 | {"hybrid local", NewActiveSessionResultWithDisplayOrigin(testExactTarget("sample", 1), time.Time{}, "local"), "Switch to session sample@local"}, | ||
| 19 | {"serving remote", NewActiveSessionResultWithDisplayOrigin(testExactTarget("sample", 1), time.Time{}, "host-a"), "Switch to session sample@host-a"}, | 18 | {"serving remote", NewActiveSessionResultWithDisplayOrigin(testExactTarget("sample", 1), time.Time{}, "host-a"), "Switch to session sample@host-a"}, | ||
| 20 | {"imported local", NewImportedSessionResult("local", "key", "sample", "local", "up", ""), "Switch to session sample@local"}, | 19 | {"imported local", NewImportedSessionResult("local", "key", "sample", "local", "up", ""), "Switch to session sample@local"}, | ||
| 21 | - | {"discovered remote", NewRemoteSessionResult(domain.RemoteSessionKey{Name: "sample", Host: "user@host-a", DisplayOrigin: "host-a"}, domain.RemoteSessionTarget{}, ""), "Switch to session sample@host-a"}, | |||
| 22 | } { | 20 | } { | ||
| 23 | t.Run(tc.name, func(t *testing.T) { require.Equal(t, tc.want, tc.result.DisplayText()) }) | 21 | t.Run(tc.name, func(t *testing.T) { require.Equal(t, tc.want, tc.result.DisplayText()) }) | ||
| 24 | } | 22 | } | ||
M internal/usecase/picker/modal.go +0 -8
| @@ -28,11 +28,3 @@ func PreviewRect(terminal domain.Size) domain.Rect { | |||
| 28 | 28 | func Size(rect domain.Rect) domain.Size { | |
| 29 | 29 | return domain.Size{Cols: rect.Width, Rows: rect.Height} | |
| 30 | 30 | } | |
| 31 | - | ||
| 32 | - | // PreviewSize returns the preview viewport for one terminal size: the preview | |
| 33 | - | // pane inside the shared modal geometry. A zero size means this terminal has | |
| 34 | - | // no room for a preview. The serving daemon and the presenting client both | |
| 35 | - | // derive it from PreviewRect, so the captured viewport always fits its pane. | |
| 36 | - | func PreviewSize(terminal domain.Size) domain.Size { | |
| 37 | - | return Size(PreviewRect(terminal)) | |
| 38 | - | } | |
| @@ -28,11 +28,3 @@ func PreviewRect(terminal domain.Size) domain.Rect { | |||||
| 28 | func Size(rect domain.Rect) domain.Size { | 28 | func Size(rect domain.Rect) domain.Size { | ||
| 29 | return domain.Size{Cols: rect.Width, Rows: rect.Height} | 29 | return domain.Size{Cols: rect.Width, Rows: rect.Height} | ||
| 30 | } | 30 | } | ||
| 31 | - | ||||
| 32 | - | // PreviewSize returns the preview viewport for one terminal size: the preview | |||
| 33 | - | // pane inside the shared modal geometry. A zero size means this terminal has | |||
| 34 | - | // no room for a preview. The serving daemon and the presenting client both | |||
| 35 | - | // derive it from PreviewRect, so the captured viewport always fits its pane. | |||
| 36 | - | func PreviewSize(terminal domain.Size) domain.Size { | |||
| 37 | - | return Size(PreviewRect(terminal)) | |||
| 38 | - | } | |||