gui/pkg/display/mode.go
Claude 89fb765ef5
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
feat(display): add chat and mode helpers
- pkg/display/chat.go: chat display utilities
- pkg/display/mode.go: AppMode type
- pkg/display/display.go: small additions

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-14 14:27:36 +01:00

40 lines
738 B
Go

package display
import "strings"
type AppMode string
const (
ModeManager AppMode = "manager"
ModeWorker AppMode = "worker"
)
func DetectMode(args []string, getenv func(string) string) AppMode {
if getenv != nil {
if mode, ok := parseMode(getenv("CORE_GUI_MODE")); ok {
return mode
}
}
for _, arg := range args {
if !strings.HasPrefix(arg, "--mode=") {
continue
}
if mode, ok := parseMode(strings.TrimPrefix(arg, "--mode=")); ok {
return mode
}
}
return ModeManager
}
func parseMode(raw string) (AppMode, bool) {
switch strings.TrimSpace(strings.ToLower(raw)) {
case string(ModeManager):
return ModeManager, true
case string(ModeWorker):
return ModeWorker, true
default:
return "", false
}
}