MCPcopy Create free account
hub / github.com/Facets-cloud/flow / FocusSession

Function FocusSession

internal/kitty/kitty.go:124–143  ·  view source on GitHub ↗

FocusSession tries to focus the kitty window currently running `binary` with the given session UUID. The `binary` arg is the harness's executable name (e.g. "claude", "codex", "gemini") used to filter windows. Returns (true, nil) on focus, (false, nil) if no window across any kitty OS window matches

(sessionID, binary string)

Source from the content-addressed store, hash-verified

122// If remote control is disabled, `kitty @ ls` exits non-zero and the
123// error is surfaced wrapped.
124func FocusSession(sessionID, binary string) (bool, error) {
125 if sessionID == "" {
126 return false, nil
127 }
128 out, err := RunnerOutput([]string{"@", "ls"})
129 if err != nil {
130 return false, fmt.Errorf("kitty @ ls: %w", err)
131 }
132 winID, ok, err := windowIDForHarnessSession(out, sessionID, binary)
133 if err != nil {
134 return false, err
135 }
136 if !ok {
137 return false, nil
138 }
139 if err := Runner([]string{"@", "focus-window", fmt.Sprintf("--match=id:%d", winID)}); err != nil {
140 return false, fmt.Errorf("kitty @ focus-window: %w", err)
141 }
142 return true, nil
143}
144
145// kittyOSWindow / kittyTab / kittyWindow / kittyFGProc are the minimal
146// subset of the `kitty @ ls` JSON schema we care about. The full schema

Calls 1