@@ -86,6 +86,7 @@ type BrowserComputerService interface {
8686 MoveMouse (ctx context.Context , id string , body kernel.BrowserComputerMoveMouseParams , opts ... option.RequestOption ) (err error )
8787 PressKey (ctx context.Context , id string , body kernel.BrowserComputerPressKeyParams , opts ... option.RequestOption ) (err error )
8888 Scroll (ctx context.Context , id string , body kernel.BrowserComputerScrollParams , opts ... option.RequestOption ) (err error )
89+ SetCursorVisibility (ctx context.Context , id string , body kernel.BrowserComputerSetCursorVisibilityParams , opts ... option.RequestOption ) (res * kernel.BrowserComputerSetCursorVisibilityResponse , err error )
8990 TypeText (ctx context.Context , id string , body kernel.BrowserComputerTypeTextParams , opts ... option.RequestOption ) (err error )
9091}
9192
@@ -567,6 +568,11 @@ type BrowsersComputerDragMouseInput struct {
567568 HoldKeys []string
568569}
569570
571+ type BrowsersComputerSetCursorInput struct {
572+ Identifier string
573+ Hidden bool
574+ }
575+
570576func (b BrowsersCmd ) ComputerClickMouse (ctx context.Context , in BrowsersComputerClickMouseInput ) error {
571577 if b .computer == nil {
572578 pterm .Error .Println ("computer service not available" )
@@ -789,6 +795,32 @@ func (b BrowsersCmd) ComputerDragMouse(ctx context.Context, in BrowsersComputerD
789795 return nil
790796}
791797
798+ func (b BrowsersCmd ) ComputerSetCursor (ctx context.Context , in BrowsersComputerSetCursorInput ) error {
799+ if b .computer == nil {
800+ pterm .Error .Println ("computer service not available" )
801+ return nil
802+ }
803+ br , err := b .resolveBrowserByIdentifier (ctx , in .Identifier )
804+ if err != nil {
805+ return util.CleanedUpSdkError {Err : err }
806+ }
807+ if br == nil {
808+ pterm .Error .Printf ("Browser '%s' not found\n " , in .Identifier )
809+ return nil
810+ }
811+ body := kernel.BrowserComputerSetCursorVisibilityParams {Hidden : in .Hidden }
812+ _ , err = b .computer .SetCursorVisibility (ctx , br .SessionID , body )
813+ if err != nil {
814+ return util.CleanedUpSdkError {Err : err }
815+ }
816+ if in .Hidden {
817+ pterm .Success .Println ("Cursor hidden" )
818+ } else {
819+ pterm .Success .Println ("Cursor shown" )
820+ }
821+ return nil
822+ }
823+
792824// Replays
793825type BrowsersReplaysListInput struct {
794826 Identifier string
@@ -1955,7 +1987,12 @@ func init() {
19551987 computerDrag .Flags ().String ("button" , "left" , "Mouse button: left,middle,right" )
19561988 computerDrag .Flags ().StringSlice ("hold-key" , []string {}, "Modifier keys to hold (repeatable)" )
19571989
1958- computerRoot .AddCommand (computerClick , computerMove , computerScreenshot , computerType , computerPressKey , computerScroll , computerDrag )
1990+ // computer set-cursor
1991+ computerSetCursor := & cobra.Command {Use : "set-cursor <id|persistent-id>" , Short : "Hide or show the cursor" , Args : cobra .ExactArgs (1 ), RunE : runBrowsersComputerSetCursor }
1992+ computerSetCursor .Flags ().Bool ("hidden" , false , "Whether to hide the cursor (true) or show it (false)" )
1993+ _ = computerSetCursor .MarkFlagRequired ("hidden" )
1994+
1995+ computerRoot .AddCommand (computerClick , computerMove , computerScreenshot , computerType , computerPressKey , computerScroll , computerDrag , computerSetCursor )
19591996 browsersCmd .AddCommand (computerRoot )
19601997
19611998 // playwright
@@ -2462,6 +2499,14 @@ func runBrowsersComputerDragMouse(cmd *cobra.Command, args []string) error {
24622499 return b .ComputerDragMouse (cmd .Context (), BrowsersComputerDragMouseInput {Identifier : args [0 ], Path : path , Delay : delay , StepDelayMs : stepDelayMs , StepsPerSegment : stepsPerSegment , Button : button , HoldKeys : holdKeys })
24632500}
24642501
2502+ func runBrowsersComputerSetCursor (cmd * cobra.Command , args []string ) error {
2503+ client := getKernelClient (cmd )
2504+ svc := client .Browsers
2505+ hidden , _ := cmd .Flags ().GetBool ("hidden" )
2506+ b := BrowsersCmd {browsers : & svc , computer : & svc .Computer }
2507+ return b .ComputerSetCursor (cmd .Context (), BrowsersComputerSetCursorInput {Identifier : args [0 ], Hidden : hidden })
2508+ }
2509+
24652510func truncateURL (url string , maxLen int ) string {
24662511 if len (url ) <= maxLen {
24672512 return url
0 commit comments