@@ -11,6 +11,7 @@ import type {
1111 DesktopPreviewPointerEvent ,
1212 PreviewAnnotationPayload ,
1313 PreviewAnnotationRect ,
14+ PreviewAnnotationSubmissionResult ,
1415 DesktopPreviewRecordingArtifact ,
1516 DesktopPreviewRecordingFrame ,
1617 DesktopPreviewScreenshotArtifact ,
@@ -406,6 +407,13 @@ const APP_FORWARDED_SHORTCUTS: ReadonlyArray<{
406407 { key : "w" , meta : true , shift : false , control : false } ,
407408] ) ;
408409
410+ export const isPreviewRefreshShortcut = ( input : Electron . Input ) : boolean =>
411+ input . type === "keyDown" &&
412+ input . key . toLowerCase ( ) === "r" &&
413+ ( input . meta || input . control ) &&
414+ ! input . shift &&
415+ ! input . alt ;
416+
409417const isPreviewInputSignal = ( value : unknown ) : value is PreviewInputSignal => {
410418 if ( typeof value !== "object" || value === null || ! ( "kind" in value ) ) return false ;
411419 if ( value . kind === "pointer" ) {
@@ -1365,6 +1373,15 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
13651373 } ) ;
13661374 } ) ;
13671375 const beforeInput = ( event : Electron . Event , input : Electron . Input ) : void => {
1376+ if ( isPreviewRefreshShortcut ( input ) ) {
1377+ event . preventDefault ( ) ;
1378+ runFork (
1379+ attempt ( { operation : "shortcut.refresh" , tabId, webContentsId : wc . id } , ( ) =>
1380+ wc . reload ( ) ,
1381+ ) . pipe ( Effect . ignore ) ,
1382+ ) ;
1383+ return ;
1384+ }
13681385 runFork ( forwardShortcut ( event , input ) ) ;
13691386 } ;
13701387 yield * Scope . addFinalizer (
@@ -1792,7 +1809,7 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
17921809 const wc = yield * requireWebContents ( tabId ) ;
17931810 yield * cancelPickElement ( tabId ) ;
17941811 const annotationTheme = yield * Ref . get ( annotationThemeRef ) ;
1795- return yield * Effect . callback < PreviewAnnotationPayload | null , PreviewManagerError > (
1812+ return yield * Effect . callback < PreviewAnnotationSubmissionResult | null , PreviewManagerError > (
17961813 ( resume ) => {
17971814 const cleanup = Effect . fn ( "PreviewManager.cleanupPickElement" ) ( function * ( ) {
17981815 yield * attempt ( { operation : "pickElement.cleanup" , tabId, webContentsId : wc . id } , ( ) => {
@@ -1807,14 +1824,14 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
18071824 ) ;
18081825 } ) ;
18091826 const settlePick = Effect . fn ( "PreviewManager.settlePickElement" ) ( function * (
1810- payload : PreviewAnnotationPayload | null ,
1827+ payload : PreviewAnnotationSubmissionResult | null ,
18111828 ) {
18121829 const active = ( yield * Ref . get ( pickSessionsRef ) ) . get ( tabId ) ;
18131830 if ( ! active || active . cancel !== cancel ) return ;
18141831 yield * cleanup ( ) ;
18151832 resume ( Effect . succeed ( payload ) ) ;
18161833 } ) ;
1817- const settle = ( payload : PreviewAnnotationPayload | null ) => {
1834+ const settle = ( payload : PreviewAnnotationSubmissionResult | null ) => {
18181835 runFork ( settlePick ( payload ) ) ;
18191836 } ;
18201837 const cancelPickSession = Effect . fn ( "PreviewManager.cancelPickSession" ) ( function * ( ) {
@@ -1844,11 +1861,13 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
18441861 return ;
18451862 }
18461863 const cropRect = normalizeCaptureRect ( args [ 1 ] ) ;
1864+ const submission = args [ 2 ] === "send" ? "send" : "attach" ;
18471865 runFork (
18481866 captureAnnotationScreenshot ( tabId , wc , cropRect ) . pipe (
18491867 Effect . matchEffect ( {
1850- onFailure : ( ) => Effect . sync ( ( ) => settle ( payload ) ) ,
1851- onSuccess : ( screenshot ) => Effect . sync ( ( ) => settle ( { ...payload , screenshot } ) ) ,
1868+ onFailure : ( ) => Effect . sync ( ( ) => settle ( { annotation : payload , submission } ) ) ,
1869+ onSuccess : ( screenshot ) =>
1870+ Effect . sync ( ( ) => settle ( { annotation : { ...payload , screenshot } , submission } ) ) ,
18521871 } ) ,
18531872 Effect . ensuring (
18541873 attempt (
@@ -3586,7 +3605,7 @@ export class PreviewManager extends Context.Service<
35863605 ) => Effect . Effect < void , PreviewManagerError > ;
35873606 readonly pickElement : (
35883607 tabId : string ,
3589- ) => Effect . Effect < PreviewAnnotationPayload | null , PreviewManagerError > ;
3608+ ) => Effect . Effect < PreviewAnnotationSubmissionResult | null , PreviewManagerError > ;
35903609 readonly cancelPickElement : ( tabId : string ) => Effect . Effect < void , PreviewManagerError > ;
35913610 readonly captureScreenshot : (
35923611 tabId : string ,
0 commit comments