@@ -61,7 +61,12 @@ export function register(on: On) {
6161 const isError = base . kind === 'error'
6262 const outcome : Record . MarkOutcome = isError
6363 ? { kind : 'sad' , reason : base . reason }
64- : { kind : 'ok' }
64+ : {
65+ kind : 'ok' ,
66+ props : {
67+ outcome : { value : base . kind , of : Record . BASE_OUTCOMES } ,
68+ } ,
69+ }
6570
6671 if ( ! loggedBaseKinds . has ( outcome . kind ) ) {
6772 loggedBaseKinds . add ( outcome . kind )
@@ -148,21 +153,21 @@ export function register(on: On) {
148153 model . selectedPath ,
149154 )
150155
151- async function loadBody ( engine : Host ) : Promise < void > {
156+ async function loadBody ( engine : Host ) : Promise < boolean > {
152157 const { data } = model
153158 const selected = selectedOf ( )
154159
155160 if ( ! data || ! selected || ! backend ) {
156161 bodyKey = null
157162 model = { ...model , body : null , bodyState : 'idle' }
158163
159- return
164+ return false
160165 }
161166
162167 const key = `${ generation } |${ data . baseRef } |${ selected . path } `
163168
164169 if ( key === bodyKey ) {
165- return
170+ return false
166171 }
167172
168173 bodyKey = key
@@ -171,11 +176,13 @@ export function register(on: On) {
171176 const body = await backend . fetchFileHunks ( data , selected )
172177
173178 if ( bodyKey !== key ) {
174- return
179+ return body === null
175180 }
176181
177182 model = { ...model , body, bodyState : body ? 'ready' : 'failed' }
178183 redraw ( engine )
184+
185+ return body === null
179186 }
180187
181188 function startPoll ( engine : Host , pinned : Backend . Backend ) {
@@ -240,7 +247,6 @@ export function register(on: On) {
240247 } )
241248 break
242249 case 'data' :
243- record . mark ( Record . FEATURES . read , { kind : 'ok' } )
244250 generation += 1
245251
246252 if ( pinned ) {
@@ -250,7 +256,23 @@ export function register(on: On) {
250256 break
251257 }
252258
253- await loadBody ( engine )
259+ const hasHunksFailed = await loadBody ( engine )
260+
261+ if ( outcome . kind === 'data' ) {
262+ record . mark (
263+ Record . FEATURES . read ,
264+ hasHunksFailed
265+ ? { kind : 'sad' , reason : 'git_hunks_failed' }
266+ : { kind : 'ok' } ,
267+ )
268+ }
269+ } catch ( error ) {
270+ record . mark ( Record . FEATURES . read , {
271+ kind : 'sad' ,
272+ reason : 'git_diff_threw' ,
273+ } )
274+
275+ throw error
254276 } finally {
255277 isRefreshing = false
256278 redraw ( engine )
@@ -281,13 +303,11 @@ export function register(on: On) {
281303 const isManual = trigger === 'manual'
282304 await engine . openPane ( isManual ? { ...pane , ...Names . FOCUSED_PANE } : pane )
283305 isPaneOpen = true
284- const record = Record . recorderOf ( engine )
285- record . mark ( Record . FEATURES . tabSwitch , { kind : 'ok' } )
286306 const sessionId = await engine . sessionId ( ) . catch ( ( ) => null )
287307
288308 if ( sessionId !== null && sessionId !== shownSessionId ) {
289309 shownSessionId = sessionId
290- record . shown ( trigger , Record . widthBucketOf ( columns ) )
310+ Record . recorderOf ( engine ) . shown ( trigger , Record . widthBucketOf ( columns ) )
291311 }
292312
293313 void refresh ( engine )
@@ -296,7 +316,13 @@ export function register(on: On) {
296316 async function closePane ( engine : Host ) : Promise < void > {
297317 await engine . closePane ( { id : Names . PANE_ID } )
298318 isPaneOpen = false
299- Record . recorderOf ( engine ) . mark ( Record . FEATURES . tabSwitch , { kind : 'ok' } )
319+ }
320+
321+ function markTabSwitch ( engine : Host , tab : ( typeof Record . TABS ) [ number ] ) {
322+ Record . recorderOf ( engine ) . mark ( Record . FEATURES . tabSwitch , {
323+ kind : 'ok' ,
324+ props : { tab : { value : tab , of : Record . TABS } } ,
325+ } )
300326 }
301327
302328 async function wasDrawnWhenProbed ( engine : Host ) : Promise < boolean > {
@@ -367,6 +393,7 @@ export function register(on: On) {
367393 model = { ...model , requestedMode : mode , body : null , bodyState : 'idle' }
368394 Record . recorderOf ( engine ) . mark ( Record . FEATURES . baseSwitch , {
369395 kind : 'ok' ,
396+ props : { mode : { value : mode , of : model . baseModes } } ,
370397 } )
371398 const toplevel = model . data ?. repository . toplevel
372399
@@ -401,6 +428,7 @@ export function register(on: On) {
401428 } ,
402429 close : ( ) => {
403430 void closePane ( engine )
431+ . then ( ( ) => markTabSwitch ( engine , 'convo' ) )
404432 . then ( ( ) => engine . storeSet ( Names . STORE_OPEN_KEY , false ) )
405433 . catch ( ( ) => undefined )
406434 } ,
@@ -525,6 +553,7 @@ export function register(on: On) {
525553
526554 const isOpening = toggle === 'open'
527555 await ( isOpening ? openPane ( host , 'manual' ) : closePane ( host ) )
556+ markTabSwitch ( host , isOpening ? 'diff' : 'convo' )
528557 await host . storeSet ( Names . STORE_OPEN_KEY , isOpening ) . catch ( ( ) => undefined )
529558
530559 return { }
0 commit comments