Rex (com.superlogical.rex) claims no .command file, so Launch Services never listed it and `open -a` can't hand it a script (StringKe). Sessions' terminal list now offers Rex when its CLI is found: a native `rex` on PATH, or one inside a Rex*.app in /Applications or ~/Applications (Rex puts rex on PATH only in its own terminals). Perl's Rex installs a script named rex too, so only a Mach-O or ELF program counts. Resume, carry and an agent's Open then run `rex run --label <title> -- /bin/sh -c '<command>; exec login shell'`: no shell parses the label or the command on the way. With no session to add a tab to (exit 3) it runs `rex new`; with Rex's server not running (exit 4) the error says to open Rex. Rex is then brought forward with `open -b`. The GUI already lists s.terminalApps, so no JS changed. reference.md's Session terminal says it. Parts 2 to 4 of #4565 (accounts run per account, OSC 7501 status, folder mapping) build on #992, which isn't merged; not done here. Ran, at this tree on origin/maine90a635a9, through mote-run: - go test ./internal/gui -run 'TestFindRex|TestOpenInRex| TestDiscoverTerminals|TestTerminalOpenArgs|TestAgentOpen': ok. TestOpenInRex runs the real sh script with SHELL=/usr/bin/true and checks the command ran in its folder, and a label holding $(...) and quotes stays one argument. - go vet ./...; GOOS=linux (-tags nogui) and GOOS=windows go vet and go build: ok (at the pre-rebase head; go vet ./... again rebased). - Full suite, go test -tags nogui -timeout 45m ./..., at the pre-rebase head: every package ok but internal/gui, red on TestSettingsSaveKeepsWhatItDoesNotSend (#4514, red the same on origin/maine90a635a9) and TestColdTurnsTaken (#4510). Rebased, internal/gui and internal/provider whole again: red on #4514 only. Broke by hand, each red, then restored: withRex taken out of discovery (TestDiscoverTerminalsOffersRex); the exit-3 fallback to rex new turned off (TestOpenInRex: "rex: Error: no session"); the native-program check dropped for PATH (TestFindRex took the Perl script). Not tried: the real Rex app or rex binary. Its installer needs a Discord sign-in, so the CLI was driven from Rex's docs only; whether `rex run` with no -s from outside Rex targets the shown session or exits 3 is not confirmed. Not run on Linux or Windows (Rex's Linux build, and the tests skip on Windows). No GUI Playwright run, as no JS changed.
32 lines
751 B
Go
32 lines
751 B
Go
//go:build darwin && cgo
|
|
|
|
package gui
|
|
|
|
/*
|
|
#cgo LDFLAGS: -framework AppKit -framework UniformTypeIdentifiers
|
|
#include <stdlib.h>
|
|
char *magpieTerminalAppsJSON(void);
|
|
*/
|
|
import "C"
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"unsafe"
|
|
)
|
|
|
|
// discoverTerminals asks Launch Services for apps that claim .command files,
|
|
// and adds Rex when its CLI is found (withRex).
|
|
func discoverTerminals() (terminalDiscovery, error) {
|
|
raw := C.magpieTerminalAppsJSON()
|
|
if raw == nil {
|
|
return terminalDiscovery{}, errors.New("could not find apps for .command files")
|
|
}
|
|
defer C.free(unsafe.Pointer(raw))
|
|
var found terminalDiscovery
|
|
if err := json.Unmarshal([]byte(C.GoString(raw)), &found); err != nil {
|
|
return terminalDiscovery{}, err
|
|
}
|
|
return withRex(found), nil
|
|
}
|