refactor(daemon): group primary render capture inputs
- commit
- 31d36eae4b962823357f60f9115e91e73bd39024
- author
- brice · · 2026-07-14 19:48 UTC
- parent
- c4381db
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
4 files · +52 -5
M internal/usecase/daemon/render.go +8 -1
| @@ -325,7 +325,14 @@ func (d *Daemon) paint(sess *session, ac *attachedClient, reset bool, lease *att | |||
| 325 | 325 | copyFeedback: overlays.copyFeedback, | |
| 326 | 326 | } | |
| 327 | 327 | endCapture := marks.span(ports.RuntimeCaptureStart, ports.RuntimeCaptureEnd, 0) | |
| 328 | - | state, ok := capturePrimaryRenderState(sess, ac, bars, capturedOverlays, preview, floatingCfg, reset, lease) | |
| 328 | + | state, ok := capturePrimaryRenderState(sess, ac, primaryCaptureRequest{ | |
| 329 | + | bars: bars, | |
| 330 | + | overlays: capturedOverlays, | |
| 331 | + | preview: preview, | |
| 332 | + | floatingCfg: floatingCfg, | |
| 333 | + | reset: reset, | |
| 334 | + | lease: lease, | |
| 335 | + | }) | |
| 329 | 336 | endCapture(0, ok) | |
| 330 | 337 | if !ok { | |
| 331 | 338 | ac.sendMu.Unlock() | |
| @@ -325,7 +325,14 @@ func (d *Daemon) paint(sess *session, ac *attachedClient, reset bool, lease *att | |||||
| 325 | copyFeedback: overlays.copyFeedback, | 325 | copyFeedback: overlays.copyFeedback, | ||
| 326 | } | 326 | } | ||
| 327 | endCapture := marks.span(ports.RuntimeCaptureStart, ports.RuntimeCaptureEnd, 0) | 327 | endCapture := marks.span(ports.RuntimeCaptureStart, ports.RuntimeCaptureEnd, 0) | ||
| 328 | - | state, ok := capturePrimaryRenderState(sess, ac, bars, capturedOverlays, preview, floatingCfg, reset, lease) | 328 | + | state, ok := capturePrimaryRenderState(sess, ac, primaryCaptureRequest{ |
| 329 | + | bars: bars, | |||
| 330 | + | overlays: capturedOverlays, | |||
| 331 | + | preview: preview, | |||
| 332 | + | floatingCfg: floatingCfg, | |||
| 333 | + | reset: reset, | |||
| 334 | + | lease: lease, | |||
| 335 | + | }) | |||
| 329 | endCapture(0, ok) | 336 | endCapture(0, ok) | ||
| 330 | if !ok { | 337 | if !ok { | ||
| 331 | ac.sendMu.Unlock() | 338 | ac.sendMu.Unlock() | ||
M internal/usecase/daemon/render_capture.go +20 -1
| @@ -166,11 +166,30 @@ func uncertainDamage(damage []renderer.Damage, width, height int) bool { | |||
| 166 | 166 | return false | |
| 167 | 167 | } | |
| 168 | 168 | ||
| 169 | + | type primaryCaptureRequest struct { | |
| 170 | + | bars barState | |
| 171 | + | overlays capturedOverlayRenderState | |
| 172 | + | preview picker.Preview | |
| 173 | + | floatingCfg domain.FloatingConfig | |
| 174 | + | reset bool | |
| 175 | + | lease *attachmentLease | |
| 176 | + | } | |
| 177 | + | ||
| 169 | 178 | // capturePrimaryRenderState is the ownership boundary for a primary render | |
| 170 | 179 | // transaction. Callers hold attachment sendMu; this function then follows | |
| 171 | 180 | // session -> tab -> pane lock order. ACK-blocked capture returns before touching | |
| 172 | 181 | // VT damage, and every captured pane records a receipt for successful emission. | |
| 173 | - | func capturePrimaryRenderState(sess *session, ac *attachedClient, bars barState, overlays capturedOverlayRenderState, preview picker.Preview, floatingCfg domain.FloatingConfig, reset bool, lease *attachmentLease) (*capturedRenderState, bool) { | |
| 182 | + | func capturePrimaryRenderState( | |
| 183 | + | sess *session, | |
| 184 | + | ac *attachedClient, | |
| 185 | + | request primaryCaptureRequest, | |
| 186 | + | ) (*capturedRenderState, bool) { | |
| 187 | + | bars := request.bars | |
| 188 | + | overlays := request.overlays | |
| 189 | + | preview := request.preview | |
| 190 | + | floatingCfg := request.floatingCfg | |
| 191 | + | reset := request.reset | |
| 192 | + | lease := request.lease | |
| 174 | 193 | if sess == nil || ac == nil || (ac.output != nil && ac.output.atCapacity()) { | |
| 175 | 194 | return nil, false | |
| 176 | 195 | } | |
| @@ -166,11 +166,30 @@ func uncertainDamage(damage []renderer.Damage, width, height int) bool { | |||||
| 166 | return false | 166 | return false | ||
| 167 | } | 167 | } | ||
| 168 | 168 | ||||
| 169 | + | type primaryCaptureRequest struct { | |||
| 170 | + | bars barState | |||
| 171 | + | overlays capturedOverlayRenderState | |||
| 172 | + | preview picker.Preview | |||
| 173 | + | floatingCfg domain.FloatingConfig | |||
| 174 | + | reset bool | |||
| 175 | + | lease *attachmentLease | |||
| 176 | + | } | |||
| 177 | + | ||||
| 169 | // capturePrimaryRenderState is the ownership boundary for a primary render | 178 | // capturePrimaryRenderState is the ownership boundary for a primary render | ||
| 170 | // transaction. Callers hold attachment sendMu; this function then follows | 179 | // transaction. Callers hold attachment sendMu; this function then follows | ||
| 171 | // session -> tab -> pane lock order. ACK-blocked capture returns before touching | 180 | // session -> tab -> pane lock order. ACK-blocked capture returns before touching | ||
| 172 | // VT damage, and every captured pane records a receipt for successful emission. | 181 | // VT damage, and every captured pane records a receipt for successful emission. | ||
| 173 | - | func capturePrimaryRenderState(sess *session, ac *attachedClient, bars barState, overlays capturedOverlayRenderState, preview picker.Preview, floatingCfg domain.FloatingConfig, reset bool, lease *attachmentLease) (*capturedRenderState, bool) { | 182 | + | func capturePrimaryRenderState( |
| 183 | + | sess *session, | |||
| 184 | + | ac *attachedClient, | |||
| 185 | + | request primaryCaptureRequest, | |||
| 186 | + | ) (*capturedRenderState, bool) { | |||
| 187 | + | bars := request.bars | |||
| 188 | + | overlays := request.overlays | |||
| 189 | + | preview := request.preview | |||
| 190 | + | floatingCfg := request.floatingCfg | |||
| 191 | + | reset := request.reset | |||
| 192 | + | lease := request.lease | |||
| 174 | if sess == nil || ac == nil || (ac.output != nil && ac.output.atCapacity()) { | 193 | if sess == nil || ac == nil || (ac.output != nil && ac.output.atCapacity()) { | ||
| 175 | return nil, false | 194 | return nil, false | ||
| 176 | } | 195 | } | ||
M internal/usecase/daemon/render_damage_receipt_test.go +16 -2
| @@ -26,7 +26,14 @@ func TestPrimaryCaptureAloneRecordsDamageReceipts(t *testing.T) { | |||
| 26 | 26 | p.mu.Unlock() | |
| 27 | 27 | ||
| 28 | 28 | ac.sendMu.Lock() | |
| 29 | - | state, ok := capturePrimaryRenderState(sess, ac, barState{}, capturedOverlayRenderState{}, pickerPreviewEmpty(), domain.FloatingConfig{}, false, nil) | |
| 29 | + | state, ok := capturePrimaryRenderState(sess, ac, primaryCaptureRequest{ | |
| 30 | + | bars: barState{}, | |
| 31 | + | overlays: capturedOverlayRenderState{}, | |
| 32 | + | preview: pickerPreviewEmpty(), | |
| 33 | + | floatingCfg: domain.FloatingConfig{}, | |
| 34 | + | reset: false, | |
| 35 | + | lease: nil, | |
| 36 | + | }) | |
| 30 | 37 | ac.sendMu.Unlock() | |
| 31 | 38 | require.True(t, ok) | |
| 32 | 39 | require.Len(t, state.receipts, 1) | |
| @@ -120,7 +127,14 @@ func TestRenderDamageReceiptStaleGenerationForcesFullRedraw(t *testing.T) { | |||
| 120 | 127 | func captureComposeForReceiptTest(t *testing.T, sess *session, ac *attachedClient) (*capturedRenderState, composedRenderFrame) { | |
| 121 | 128 | t.Helper() | |
| 122 | 129 | ac.sendMu.Lock() // emitFrame releases the transaction lock. | |
| 123 | - | state, ok := capturePrimaryRenderState(sess, ac, barState{}, capturedOverlayRenderState{}, pickerPreviewEmpty(), domain.FloatingConfig{}, false, nil) | |
| 130 | + | state, ok := capturePrimaryRenderState(sess, ac, primaryCaptureRequest{ | |
| 131 | + | bars: barState{}, | |
| 132 | + | overlays: capturedOverlayRenderState{}, | |
| 133 | + | preview: pickerPreviewEmpty(), | |
| 134 | + | floatingCfg: domain.FloatingConfig{}, | |
| 135 | + | reset: false, | |
| 136 | + | lease: nil, | |
| 137 | + | }) | |
| 124 | 138 | require.True(t, ok) | |
| 125 | 139 | return state, composeFrame(*state, ac.pipelineCache, ac.pipelineScratch) | |
| 126 | 140 | } | |
| @@ -26,7 +26,14 @@ func TestPrimaryCaptureAloneRecordsDamageReceipts(t *testing.T) { | |||||
| 26 | p.mu.Unlock() | 26 | p.mu.Unlock() | ||
| 27 | 27 | ||||
| 28 | ac.sendMu.Lock() | 28 | ac.sendMu.Lock() | ||
| 29 | - | state, ok := capturePrimaryRenderState(sess, ac, barState{}, capturedOverlayRenderState{}, pickerPreviewEmpty(), domain.FloatingConfig{}, false, nil) | 29 | + | state, ok := capturePrimaryRenderState(sess, ac, primaryCaptureRequest{ |
| 30 | + | bars: barState{}, | |||
| 31 | + | overlays: capturedOverlayRenderState{}, | |||
| 32 | + | preview: pickerPreviewEmpty(), | |||
| 33 | + | floatingCfg: domain.FloatingConfig{}, | |||
| 34 | + | reset: false, | |||
| 35 | + | lease: nil, | |||
| 36 | + | }) | |||
| 30 | ac.sendMu.Unlock() | 37 | ac.sendMu.Unlock() | ||
| 31 | require.True(t, ok) | 38 | require.True(t, ok) | ||
| 32 | require.Len(t, state.receipts, 1) | 39 | require.Len(t, state.receipts, 1) | ||
| @@ -120,7 +127,14 @@ func TestRenderDamageReceiptStaleGenerationForcesFullRedraw(t *testing.T) { | |||||
| 120 | func captureComposeForReceiptTest(t *testing.T, sess *session, ac *attachedClient) (*capturedRenderState, composedRenderFrame) { | 127 | func captureComposeForReceiptTest(t *testing.T, sess *session, ac *attachedClient) (*capturedRenderState, composedRenderFrame) { | ||
| 121 | t.Helper() | 128 | t.Helper() | ||
| 122 | ac.sendMu.Lock() // emitFrame releases the transaction lock. | 129 | ac.sendMu.Lock() // emitFrame releases the transaction lock. | ||
| 123 | - | state, ok := capturePrimaryRenderState(sess, ac, barState{}, capturedOverlayRenderState{}, pickerPreviewEmpty(), domain.FloatingConfig{}, false, nil) | 130 | + | state, ok := capturePrimaryRenderState(sess, ac, primaryCaptureRequest{ |
| 131 | + | bars: barState{}, | |||
| 132 | + | overlays: capturedOverlayRenderState{}, | |||
| 133 | + | preview: pickerPreviewEmpty(), | |||
| 134 | + | floatingCfg: domain.FloatingConfig{}, | |||
| 135 | + | reset: false, | |||
| 136 | + | lease: nil, | |||
| 137 | + | }) | |||
| 124 | require.True(t, ok) | 138 | require.True(t, ok) | ||
| 125 | return state, composeFrame(*state, ac.pipelineCache, ac.pipelineScratch) | 139 | return state, composeFrame(*state, ac.pipelineCache, ac.pipelineScratch) | ||
| 126 | } | 140 | } | ||
M internal/usecase/daemon/status_test.go +8 -1
| @@ -1040,7 +1040,14 @@ func TestCapturePrimaryRenderStatePreservesContextualMRUModeThroughScratchReuse( | |||
| 1040 | 1040 | _, sess, ac, _ := newManualSessionWithPTYs(t, nil) | |
| 1041 | 1041 | capture := func(bars barState) capturedRenderState { | |
| 1042 | 1042 | t.Helper() | |
| 1043 | - | state, ok := capturePrimaryRenderState(sess, ac, bars, capturedOverlayRenderState{}, picker.Preview{}, domain.FloatingConfig{}, false, nil) | |
| 1043 | + | state, ok := capturePrimaryRenderState(sess, ac, primaryCaptureRequest{ | |
| 1044 | + | bars: bars, | |
| 1045 | + | overlays: capturedOverlayRenderState{}, | |
| 1046 | + | preview: picker.Preview{}, | |
| 1047 | + | floatingCfg: domain.FloatingConfig{}, | |
| 1048 | + | reset: false, | |
| 1049 | + | lease: nil, | |
| 1050 | + | }) | |
| 1044 | 1051 | require.True(t, ok) | |
| 1045 | 1052 | return *state | |
| 1046 | 1053 | } | |
| @@ -1040,7 +1040,14 @@ func TestCapturePrimaryRenderStatePreservesContextualMRUModeThroughScratchReuse( | |||||
| 1040 | _, sess, ac, _ := newManualSessionWithPTYs(t, nil) | 1040 | _, sess, ac, _ := newManualSessionWithPTYs(t, nil) | ||
| 1041 | capture := func(bars barState) capturedRenderState { | 1041 | capture := func(bars barState) capturedRenderState { | ||
| 1042 | t.Helper() | 1042 | t.Helper() | ||
| 1043 | - | state, ok := capturePrimaryRenderState(sess, ac, bars, capturedOverlayRenderState{}, picker.Preview{}, domain.FloatingConfig{}, false, nil) | 1043 | + | state, ok := capturePrimaryRenderState(sess, ac, primaryCaptureRequest{ |
| 1044 | + | bars: bars, | |||
| 1045 | + | overlays: capturedOverlayRenderState{}, | |||
| 1046 | + | preview: picker.Preview{}, | |||
| 1047 | + | floatingCfg: domain.FloatingConfig{}, | |||
| 1048 | + | reset: false, | |||
| 1049 | + | lease: nil, | |||
| 1050 | + | }) | |||
| 1044 | require.True(t, ok) | 1051 | require.True(t, ok) | ||
| 1045 | return *state | 1052 | return *state | ||
| 1046 | } | 1053 | } | ||