fix(daemon): preserve pane rearrangement warnings
- commit
- d7ce2f4cb2f331be72806213d55fd28651856478
- author
- brice · · 2026-07-27 16:48 UTC
- parent
- 950366c
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +37 -1
M internal/usecase/daemon/input.go +5 -1
| @@ -302,7 +302,11 @@ func (h daemonKeyHandler) Action(action keys.Action) { | |||
| 302 | 302 | if errors.Is(err, errDaemonActionNoChange) { | |
| 303 | 303 | return | |
| 304 | 304 | } | |
| 305 | - | h.d.reportError(sess, resizeUserError(err)) | |
| 305 | + | var userErr *domain.UserError | |
| 306 | + | if !errors.As(err, &userErr) { | |
| 307 | + | err = resizeUserError(err) | |
| 308 | + | } | |
| 309 | + | h.d.reportError(sess, err) | |
| 306 | 310 | return | |
| 307 | 311 | } | |
| 308 | 312 | if h.actions == nil { | |
| @@ -302,7 +302,11 @@ func (h daemonKeyHandler) Action(action keys.Action) { | |||||
| 302 | if errors.Is(err, errDaemonActionNoChange) { | 302 | if errors.Is(err, errDaemonActionNoChange) { | ||
| 303 | return | 303 | return | ||
| 304 | } | 304 | } | ||
| 305 | - | h.d.reportError(sess, resizeUserError(err)) | 305 | + | var userErr *domain.UserError |
| 306 | + | if !errors.As(err, &userErr) { | |||
| 307 | + | err = resizeUserError(err) | |||
| 308 | + | } | |||
| 309 | + | h.d.reportError(sess, err) | |||
| 306 | return | 310 | return | ||
| 307 | } | 311 | } | ||
| 308 | if h.actions == nil { | 312 | if h.actions == nil { | ||
M internal/usecase/daemon/input_test.go +32 -0
| @@ -96,6 +96,38 @@ func TestConfiguredConsumeOrExpelEdgeActionIsSilent(t *testing.T) { | |||
| 96 | 96 | requireNoInvalidation(t, invalidations) | |
| 97 | 97 | } | |
| 98 | 98 | ||
| 99 | + | func TestConsumeOrExpelKeyActionPreservesRearrangementWarning(t *testing.T) { | |
| 100 | + | tests := []struct { | |
| 101 | + | name string | |
| 102 | + | action keys.Action | |
| 103 | + | }{ | |
| 104 | + | {name: "left", action: keys.ActionConsumeOrExpelPaneLeft}, | |
| 105 | + | {name: "right", action: keys.ActionConsumeOrExpelPaneRight}, | |
| 106 | + | } | |
| 107 | + | ||
| 108 | + | for _, tt := range tests { | |
| 109 | + | t.Run(tt.name, func(t *testing.T) { | |
| 110 | + | d := newTestDaemon(t, nil, stubClock{}) | |
| 111 | + | sess := addControlSession(d, "work", "t_work", "p_work") | |
| 112 | + | ac := &attachedClient{} | |
| 113 | + | ac.setSession(sess) | |
| 114 | + | runner := &actionRunnerSpy{err: domain.UserWarn( | |
| 115 | + | domain.NoticeLayoutTooSmall, | |
| 116 | + | "not enough space to rearrange pane", | |
| 117 | + | layout.ErrTooSmall, | |
| 118 | + | )} | |
| 119 | + | ||
| 120 | + | daemonKeyHandler{d: d, ac: ac, actions: runner}.Action(tt.action) | |
| 121 | + | ||
| 122 | + | history := d.notices.history() | |
| 123 | + | require.Len(t, history, 1) | |
| 124 | + | require.Equal(t, domain.NoticeLayoutTooSmall, history[0].Code) | |
| 125 | + | require.Equal(t, domain.NoticeWarn, history[0].Severity) | |
| 126 | + | require.Equal(t, "not enough space to rearrange pane", history[0].Message) | |
| 127 | + | }) | |
| 128 | + | } | |
| 129 | + | } | |
| 130 | + | ||
| 99 | 131 | func TestResizeActionAdaptersSubmitEquivalentRequests(t *testing.T) { | |
| 100 | 132 | tests := []struct { | |
| 101 | 133 | name string | |
| @@ -96,6 +96,38 @@ func TestConfiguredConsumeOrExpelEdgeActionIsSilent(t *testing.T) { | |||||
| 96 | requireNoInvalidation(t, invalidations) | 96 | requireNoInvalidation(t, invalidations) | ||
| 97 | } | 97 | } | ||
| 98 | 98 | ||||
| 99 | + | func TestConsumeOrExpelKeyActionPreservesRearrangementWarning(t *testing.T) { | |||
| 100 | + | tests := []struct { | |||
| 101 | + | name string | |||
| 102 | + | action keys.Action | |||
| 103 | + | }{ | |||
| 104 | + | {name: "left", action: keys.ActionConsumeOrExpelPaneLeft}, | |||
| 105 | + | {name: "right", action: keys.ActionConsumeOrExpelPaneRight}, | |||
| 106 | + | } | |||
| 107 | + | ||||
| 108 | + | for _, tt := range tests { | |||
| 109 | + | t.Run(tt.name, func(t *testing.T) { | |||
| 110 | + | d := newTestDaemon(t, nil, stubClock{}) | |||
| 111 | + | sess := addControlSession(d, "work", "t_work", "p_work") | |||
| 112 | + | ac := &attachedClient{} | |||
| 113 | + | ac.setSession(sess) | |||
| 114 | + | runner := &actionRunnerSpy{err: domain.UserWarn( | |||
| 115 | + | domain.NoticeLayoutTooSmall, | |||
| 116 | + | "not enough space to rearrange pane", | |||
| 117 | + | layout.ErrTooSmall, | |||
| 118 | + | )} | |||
| 119 | + | ||||
| 120 | + | daemonKeyHandler{d: d, ac: ac, actions: runner}.Action(tt.action) | |||
| 121 | + | ||||
| 122 | + | history := d.notices.history() | |||
| 123 | + | require.Len(t, history, 1) | |||
| 124 | + | require.Equal(t, domain.NoticeLayoutTooSmall, history[0].Code) | |||
| 125 | + | require.Equal(t, domain.NoticeWarn, history[0].Severity) | |||
| 126 | + | require.Equal(t, "not enough space to rearrange pane", history[0].Message) | |||
| 127 | + | }) | |||
| 128 | + | } | |||
| 129 | + | } | |||
| 130 | + | ||||
| 99 | func TestResizeActionAdaptersSubmitEquivalentRequests(t *testing.T) { | 131 | func TestResizeActionAdaptersSubmitEquivalentRequests(t *testing.T) { | ||
| 100 | tests := []struct { | 132 | tests := []struct { | ||
| 101 | name string | 133 | name string | ||