mirror of
https://github.com/Twigpine/zero.git
synced 2026-11-08 17:56:14 -10:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df2cd633f9 | ||
|
|
f8c902c087 | ||
|
|
4fa0e5b0ba |
No files matched your search
@@ -195,7 +195,7 @@ Useful controls:
|
||||
| `Ctrl+P` / `Ctrl+N` | previous / next item in menus (arrows still work) |
|
||||
| `Shift+Tab` | cycle permission mode |
|
||||
| `Ctrl+B` | show/hide the sidebar |
|
||||
| `Ctrl+C` | cancel, exit, or return from a `/btw` conversation |
|
||||
| `Ctrl+C` | cancel or exit |
|
||||
|
||||
Common slash commands:
|
||||
|
||||
@@ -205,7 +205,6 @@ Common slash commands:
|
||||
| `/spec`, `/plan` | draft and review a plan before building |
|
||||
| `/image` | attach an image for vision-capable models |
|
||||
| `/resume`, `/rewind` | continue or roll back local sessions |
|
||||
| `/btw [question]` | ask in an isolated fork without adding the side conversation to the main session |
|
||||
| `/loop` | repeat a prompt or custom `/command` on an interval (`/loop 5m /babysit-prs`) or self-paced |
|
||||
| `/compact`, `/context` | manage context usage |
|
||||
| `/permissions`, `/tools` | inspect available tools and policy |
|
||||
|
||||
@@ -72,11 +72,8 @@ func preflightExecSession(options execOptions) error {
|
||||
if session == nil {
|
||||
return execUsageError{"Zero session not found: " + options.resume}
|
||||
}
|
||||
if !sessions.IsResumableKind(session.SessionKind) {
|
||||
return execUsageError{"Zero session is not resumable: " + options.resume}
|
||||
}
|
||||
case options.resumeLatest:
|
||||
latest, err := store.LatestResumable()
|
||||
latest, err := store.Latest()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Gitlawb/zero/internal/sessions"
|
||||
)
|
||||
|
||||
func TestPreflightRejectsSideSessions(t *testing.T) {
|
||||
t.Setenv("XDG_DATA_HOME", t.TempDir())
|
||||
store := sessions.NewStore(sessions.StoreOptions{})
|
||||
if _, err := store.Create(sessions.CreateInput{SessionID: "side", SessionKind: sessions.SessionKindSide}); err != nil {
|
||||
t.Fatalf("create side session: %v", err)
|
||||
}
|
||||
|
||||
err := preflightExecSession(execOptions{resumeLatest: true})
|
||||
if err == nil || !strings.Contains(err.Error(), "No Zero sessions available to resume") {
|
||||
t.Fatalf("preflightExecSession error = %v, want no resumable sessions", err)
|
||||
}
|
||||
|
||||
err = preflightExecSession(execOptions{resume: "side"})
|
||||
if err == nil || !strings.Contains(err.Error(), "Zero session is not resumable: side") {
|
||||
t.Fatalf("explicit side-session preflight error = %v, want non-resumable rejection", err)
|
||||
}
|
||||
}
|
||||
@@ -216,10 +216,10 @@ func parseNonEmptySessionsFlag(flag string, value string) (string, error) {
|
||||
func parseSessionKindFlag(value string) (sessions.SessionKind, error) {
|
||||
kind := sessions.SessionKind(strings.ToLower(strings.TrimSpace(value)))
|
||||
switch kind {
|
||||
case sessions.SessionKindFork, sessions.SessionKindChild, sessions.SessionKindSide, sessions.SessionKindSpecDraft, sessions.SessionKindSpecImpl:
|
||||
case sessions.SessionKindFork, sessions.SessionKindChild, sessions.SessionKindSpecDraft, sessions.SessionKindSpecImpl:
|
||||
return kind, nil
|
||||
default:
|
||||
return "", execUsageError{fmt.Sprintf("invalid --kind %q. Expected fork, child, side, spec-draft, or spec-impl.", value)}
|
||||
return "", execUsageError{fmt.Sprintf("invalid --kind %q. Expected fork, child, spec-draft, or spec-impl.", value)}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -535,7 +535,7 @@ Commands:
|
||||
|
||||
Flags:
|
||||
--json Print JSON output
|
||||
--kind <kind> Filter list by fork, child, side, spec-draft, or spec-impl
|
||||
--kind <kind> Filter list by fork, child, spec-draft, or spec-impl
|
||||
--sequence <n> Rewind target sequence (rewind-plan, rewind)
|
||||
--event <id> Rewind target event id (rewind-plan, rewind)
|
||||
--exclude-target Drop the target event (rewind-plan, rewind)
|
||||
|
||||
@@ -233,9 +233,6 @@ func TestRunSessionsListFiltersByKind(t *testing.T) {
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := store.Create(sessions.CreateInput{SessionID: "side", SessionKind: sessions.SessionKindSide, Title: "BTW side"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
var stdout bytes.Buffer
|
||||
var stderr bytes.Buffer
|
||||
@@ -252,17 +249,6 @@ func TestRunSessionsListFiltersByKind(t *testing.T) {
|
||||
t.Fatalf("filtered sessions output = %q", output)
|
||||
}
|
||||
|
||||
stdout.Reset()
|
||||
stderr.Reset()
|
||||
exitCode = runWithDeps([]string{"sessions", "list", "--kind", "side"}, &stdout, &stderr, appDeps{
|
||||
newSessionStore: func() *sessions.Store {
|
||||
return store
|
||||
},
|
||||
})
|
||||
if exitCode != exitSuccess || !strings.Contains(stdout.String(), "side") || strings.Contains(stdout.String(), "regular") {
|
||||
t.Fatalf("sessions list --kind side exit=%d stdout=%q stderr=%q", exitCode, stdout.String(), stderr.String())
|
||||
}
|
||||
|
||||
stdout.Reset()
|
||||
stderr.Reset()
|
||||
exitCode = runWithDeps([]string{"sessions", "tree", "draft", "--kind", "spec-draft"}, &stdout, &stderr, appDeps{
|
||||
|
||||
@@ -65,6 +65,76 @@ func AnalyzeCommand(script string) AnalysisResult {
|
||||
return result
|
||||
}
|
||||
|
||||
// astCommandFields parses command with the shell parser and returns each simple
|
||||
// command as its literal field slice (program + args as text), resolving the
|
||||
// real command positions across quoting, command substitution, subshells, and
|
||||
// newline separators — the constructs the hand-written splitter in
|
||||
// safe_command.go mis-handles (issue #473). It returns nil when the command
|
||||
// cannot be parsed (e.g. a Windows cmd.exe string), so callers fall through to
|
||||
// the regex path rather than hard-blocking.
|
||||
func astCommandFields(command string) [][]string {
|
||||
file, err := syntax.NewParser().Parse(strings.NewReader(command), "")
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
var commands [][]string
|
||||
syntax.Walk(file, func(node syntax.Node) bool {
|
||||
call, ok := node.(*syntax.CallExpr)
|
||||
if !ok || len(call.Args) == 0 {
|
||||
return true
|
||||
}
|
||||
// EVERY word must be a static literal, not just the program name.
|
||||
// wordText keeps only the literal/quoted parts of a word and silently
|
||||
// drops expansions, so a dynamic word anywhere in the call reconstructs
|
||||
// to something the shell will never run: `$(printf foo)vim` (runs as
|
||||
// `foovim`) collapses to "vim", and `git $(printf foo)rebase -i` (runs
|
||||
// as `git foorebase -i`, non-interactive) collapses to `git rebase -i`
|
||||
// and fabricates an interactive match. Since the runtime value of an
|
||||
// expansion is unknowable here, skip the whole call rather than classify
|
||||
// a lossy reconstruction. Skipping is the safe direction: the
|
||||
// hand-written passes above already ran, and a missed detection falls
|
||||
// through to the normal permission prompt instead of hard-blocking a
|
||||
// command the user never wrote.
|
||||
for _, word := range call.Args {
|
||||
if !isLiteralWord(word) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
fields := make([]string, 0, len(call.Args))
|
||||
for _, word := range call.Args {
|
||||
fields = append(fields, wordText(word))
|
||||
}
|
||||
commands = append(commands, fields)
|
||||
return true
|
||||
})
|
||||
return commands
|
||||
}
|
||||
|
||||
// isLiteralWord reports whether every part of word is a static literal (bare or
|
||||
// quoted). A word containing a command substitution, parameter/arithmetic
|
||||
// expansion, process substitution, etc. is dynamic — its runtime value is
|
||||
// unknown, so its wordText (a partial literal) must not be trusted as a program
|
||||
// name.
|
||||
func isLiteralWord(word *syntax.Word) bool {
|
||||
if word == nil {
|
||||
return false
|
||||
}
|
||||
for _, part := range word.Parts {
|
||||
switch typed := part.(type) {
|
||||
case *syntax.Lit, *syntax.SglQuoted:
|
||||
case *syntax.DblQuoted:
|
||||
for _, inner := range typed.Parts {
|
||||
if _, ok := inner.(*syntax.Lit); !ok {
|
||||
return false
|
||||
}
|
||||
}
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// analyzeInto parses script and folds its interactive/destructive/network usage
|
||||
// into result, sharing seen so program names are de-duplicated across recursion.
|
||||
func analyzeInto(script string, result *AnalysisResult, seen map[string]bool, depth int) {
|
||||
|
||||
@@ -219,9 +219,65 @@ func DetectInteractiveCommand(command string, goos string) InteractiveCommandRes
|
||||
}
|
||||
}
|
||||
|
||||
// AST second opinion (issue #473): the hand-written segment split above
|
||||
// mis-handles interactive programs hidden by unusual quoting, command
|
||||
// substitution, subshells, or newline separators. Re-extract the real simple
|
||||
// commands from the parsed shell tree and apply the SAME full pipeline
|
||||
// (interactive segments, sh -c payload recursion, per-program lookup), so a
|
||||
// bypass is caught while every program stays classified exactly as before
|
||||
// (ssh with a trailing command, python -c, etc. remain allowed). A command
|
||||
// the parser cannot handle (Windows cmd.exe, obfuscation) yields no commands
|
||||
// and falls through unchanged — the guard never hard-blocks on a parse error.
|
||||
for _, fields := range astCommandFields(command) {
|
||||
if result, ok := inspectCommandFields(fields, goos); ok {
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
return InteractiveCommandResult{}
|
||||
}
|
||||
|
||||
// inspectCommandFields applies the full interactive-detection pipeline to one
|
||||
// already-split command's fields: the multi-word interactive segments, then the
|
||||
// `sh -c <payload>` recursion, then the per-program lookup with its
|
||||
// non-interactive suppressions (hasNonInteractiveFlag covers REPL flags and
|
||||
// trailing-command clients like ssh). It mirrors the hand-written passes above
|
||||
// so an AST-extracted command is classified identically to a plainly-split one.
|
||||
func inspectCommandFields(fields []string, goos string) (InteractiveCommandResult, bool) {
|
||||
body := strings.ToLower(commandBody(fields))
|
||||
for _, seg := range interactiveSegments {
|
||||
if body == seg.match || strings.HasPrefix(body, seg.match+" ") {
|
||||
suggestion := seg.suggestion
|
||||
if goos == "windows" && seg.windowsSuggestion != "" {
|
||||
suggestion = seg.windowsSuggestion
|
||||
}
|
||||
return InteractiveCommandResult{Interactive: true, Command: seg.command, Reason: seg.reason, Suggestion: suggestion}, true
|
||||
}
|
||||
}
|
||||
first := firstProgram(fields)
|
||||
if first == "" {
|
||||
return InteractiveCommandResult{}, false
|
||||
}
|
||||
if payload := shellDashCPayload(first, fields); payload != "" {
|
||||
if inner := DetectInteractiveCommand(payload, goos); inner.Interactive {
|
||||
return inner, true
|
||||
}
|
||||
return InteractiveCommandResult{}, false
|
||||
}
|
||||
program, ok := interactivePrograms[first]
|
||||
if !ok || (program.windowsOnly && goos != "windows") {
|
||||
return InteractiveCommandResult{}, false
|
||||
}
|
||||
if hasNonInteractiveFlag(first, fields) {
|
||||
return InteractiveCommandResult{}, false
|
||||
}
|
||||
suggestion := program.suggestion
|
||||
if goos == "windows" && program.windowsSuggestion != "" {
|
||||
suggestion = program.windowsSuggestion
|
||||
}
|
||||
return InteractiveCommandResult{Interactive: true, Command: first, Reason: program.reason, Suggestion: suggestion}, true
|
||||
}
|
||||
|
||||
// wrapperPrograms are launcher prefixes that precede the real program. After
|
||||
// one of these we keep scanning for the actual executable.
|
||||
var wrapperPrograms = map[string]bool{
|
||||
|
||||
@@ -406,3 +406,87 @@ func TestDetectInteractiveMongoEvalAndFullPaths(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The hand-written segment splitter misses interactive programs hidden by
|
||||
// constructs only a real shell parser resolves (a newline separator collapsed
|
||||
// to a space; a brace group that shifts the real command position). The AST
|
||||
// second opinion must catch them (issue #473).
|
||||
func TestDetectInteractiveCommandCatchesParserBypasses(t *testing.T) {
|
||||
for _, cmd := range []string{
|
||||
"echo hi\nvim file.txt", // newline separator collapsed to a space by the regex path
|
||||
"{ vim file.txt; }", // brace group hides the real program position
|
||||
} {
|
||||
got := DetectInteractiveCommand(cmd, "linux")
|
||||
if !got.Interactive {
|
||||
t.Errorf("DetectInteractiveCommand(%q) = not interactive, want caught (parser bypass)", cmd)
|
||||
continue
|
||||
}
|
||||
if got.Command != "vim" {
|
||||
t.Errorf("DetectInteractiveCommand(%q).Command = %q, want vim", cmd, got.Command)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The AST second opinion must not flag an interactive program NAME that appears
|
||||
// only inside a quoted argument (not a real command position) — the parser
|
||||
// distinguishes program from argument, so this must stay non-interactive.
|
||||
func TestDetectInteractiveCommandNoFalsePositiveOnQuotedArgument(t *testing.T) {
|
||||
got := DetectInteractiveCommand(`echo "please run vim later"`, "linux")
|
||||
if got.Interactive {
|
||||
t.Fatalf("interactive name inside a quoted argument must not be flagged, got %#v", got)
|
||||
}
|
||||
}
|
||||
|
||||
// The AST second opinion must run the FULL pipeline — multi-word interactive
|
||||
// segments and sh -c payload recursion, not just the per-program lookup — so a
|
||||
// grouped/nested bypass is caught; and it must not fabricate a program name from
|
||||
// a command substitution concatenated with a literal (issue #473, review).
|
||||
func TestDetectInteractiveCommandASTPipelineBoundaries(t *testing.T) {
|
||||
interactive := []struct{ cmd, wantCmd string }{
|
||||
{"{ git rebase -i HEAD~1; }", "git rebase -i"}, // multi-word segment in a brace group
|
||||
{"{ sh -c 'vim file.txt'; }", "vim"}, // sh -c payload in a brace group
|
||||
}
|
||||
for _, tc := range interactive {
|
||||
got := DetectInteractiveCommand(tc.cmd, "linux")
|
||||
if !got.Interactive || got.Command != tc.wantCmd {
|
||||
t.Errorf("DetectInteractiveCommand(%q) = %+v, want interactive Command=%q", tc.cmd, got, tc.wantCmd)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The AST pass must not fabricate a program name from a dynamic (non-literal)
|
||||
// program word: `$(printf '%s' foo)vim` runs as `foovim`, not vim. Tested at the
|
||||
// extractor so the hand-written pass (which pre-empts DetectInteractiveCommand
|
||||
// with its own, separate handling of that construct) does not mask the guard.
|
||||
func TestAstCommandFieldsSkipsDynamicProgram(t *testing.T) {
|
||||
for _, fields := range astCommandFields("$(printf '%s' foo)vim file.txt") {
|
||||
if firstProgram(fields) == "vim" {
|
||||
t.Fatalf("astCommandFields fabricated a vim command from a substitution: %v", fields)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The literalness guard covers every word, not just the program name. A dynamic
|
||||
// ARGUMENT is dropped by wordText the same way a dynamic program word is, so
|
||||
// `git $(printf foo)rebase -i HEAD~1` (which runs as `git foorebase -i`, a
|
||||
// non-existent and non-interactive subcommand) would otherwise be reconstructed
|
||||
// as `git rebase -i` and blocked — a false positive on a command the user never
|
||||
// wrote. Asserted through DetectInteractiveCommand as well as the extractor,
|
||||
// because the whole point is what the caller ends up blocking.
|
||||
func TestAstCommandFieldsSkipsDynamicArgument(t *testing.T) {
|
||||
const dynamic = "{ git $(printf foo)rebase -i HEAD~1 ; }"
|
||||
for _, fields := range astCommandFields(dynamic) {
|
||||
if firstProgram(fields) == "git" {
|
||||
t.Fatalf("astCommandFields reconstructed a git command from a dynamic argument: %v", fields)
|
||||
}
|
||||
}
|
||||
if got := DetectInteractiveCommand(dynamic, "linux"); got.Interactive {
|
||||
t.Errorf("DetectInteractiveCommand(%q) = %+v, want not interactive", dynamic, got)
|
||||
}
|
||||
// The genuine form must still be detected — the guard skips lossy
|
||||
// reconstructions, it does not weaken real detection.
|
||||
const genuine = "{ git rebase -i HEAD~1 ; }"
|
||||
if got := DetectInteractiveCommand(genuine, "linux"); !got.Interactive || got.Command != "git rebase -i" {
|
||||
t.Errorf("DetectInteractiveCommand(%q) = %+v, want interactive Command=%q", genuine, got, "git rebase -i")
|
||||
}
|
||||
}
|
||||
@@ -89,7 +89,7 @@ func PrepareExec(options PrepareExecOptions) (PreparedExec, error) {
|
||||
if resumeID != "" || options.ResumeLatest {
|
||||
sessionID := resumeID
|
||||
if sessionID == "" && options.ResumeLatest {
|
||||
latest, err := store.LatestResumable()
|
||||
latest, err := store.Latest()
|
||||
if err != nil {
|
||||
return PreparedExec{}, err
|
||||
}
|
||||
@@ -105,9 +105,6 @@ func PrepareExec(options PrepareExecOptions) (PreparedExec, error) {
|
||||
if session == nil {
|
||||
return PreparedExec{}, ExecError{"Zero session not found: " + sessionID}
|
||||
}
|
||||
if !IsResumableKind(session.SessionKind) {
|
||||
return PreparedExec{}, ExecError{"Zero session is not resumable: " + sessionID}
|
||||
}
|
||||
contextEvents, err := readExecContextEvents(store, session.SessionID)
|
||||
if err != nil {
|
||||
return PreparedExec{}, err
|
||||
|
||||
+10
-20
@@ -52,7 +52,6 @@ type SessionKind string
|
||||
const (
|
||||
SessionKindFork SessionKind = "fork"
|
||||
SessionKindChild SessionKind = "child"
|
||||
SessionKindSide SessionKind = "side"
|
||||
SessionKindSpecDraft SessionKind = "spec-draft"
|
||||
SessionKindSpecImpl SessionKind = "spec-impl"
|
||||
)
|
||||
@@ -126,13 +125,11 @@ type CreateInput struct {
|
||||
}
|
||||
|
||||
type ForkInput struct {
|
||||
SessionID string
|
||||
SessionKind SessionKind
|
||||
Title string
|
||||
Cwd string
|
||||
ModelID string
|
||||
Provider string
|
||||
Tag string
|
||||
SessionID string
|
||||
Title string
|
||||
Cwd string
|
||||
ModelID string
|
||||
Provider string
|
||||
}
|
||||
|
||||
type ChildInput struct {
|
||||
@@ -357,9 +354,10 @@ func (store *Store) Latest() (*Metadata, error) {
|
||||
}
|
||||
|
||||
// IsResumableKind reports whether a session kind represents a standalone,
|
||||
// user-resumable conversation rather than a transient or agent-owned sub-run.
|
||||
// Regular ("") and user fork sessions are resumable; side, child, and spec
|
||||
// sessions are not, so they do not flood the resume picker.
|
||||
// user-resumable conversation rather than an agent sub-run. Regular ("") and
|
||||
// user fork sessions are resumable; child (specialist/sub-agent) and spec
|
||||
// draft/impl sessions are not — each agent task and /spec run creates one, so
|
||||
// listing them in the resume picker floods it with non-conversation entries.
|
||||
func IsResumableKind(kind SessionKind) bool {
|
||||
switch kind {
|
||||
case "", SessionKindFork:
|
||||
@@ -420,21 +418,13 @@ func (store *Store) Fork(parentSessionID string, input ForkInput) (Metadata, err
|
||||
if title == "" && parent.Title != "" {
|
||||
title = parent.Title + " (fork)"
|
||||
}
|
||||
kind := input.SessionKind
|
||||
if kind == "" {
|
||||
kind = SessionKindFork
|
||||
}
|
||||
if kind != SessionKindFork && kind != SessionKindSide {
|
||||
return Metadata{}, fmt.Errorf("invalid zero fork session kind %q", kind)
|
||||
}
|
||||
fork, err := store.Create(CreateInput{
|
||||
SessionID: input.SessionID,
|
||||
SessionKind: kind,
|
||||
SessionKind: SessionKindFork,
|
||||
Title: title,
|
||||
Cwd: firstNonEmpty(input.Cwd, parent.Cwd),
|
||||
ModelID: firstNonEmpty(input.ModelID, parent.ModelID),
|
||||
Provider: firstNonEmpty(input.Provider, parent.Provider),
|
||||
Tag: input.Tag,
|
||||
ParentSessionID: parent.SessionID,
|
||||
RootSessionID: firstNonEmpty(parent.RootSessionID, parent.SessionID),
|
||||
ForkedFromEventID: last.ID,
|
||||
|
||||
@@ -181,32 +181,6 @@ func TestStoreForkCopiesEventsAndLineage(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestStoreForkSupportsNonResumableSideSession(t *testing.T) {
|
||||
store := NewStore(StoreOptions{RootDir: t.TempDir()})
|
||||
parent, err := store.Create(CreateInput{SessionID: "parent", Title: "Parent"})
|
||||
if err != nil {
|
||||
t.Fatalf("Create parent: %v", err)
|
||||
}
|
||||
if _, err := store.AppendEvent(parent.SessionID, AppendEventInput{Type: EventMessage, Payload: map[string]string{"content": "context"}}); err != nil {
|
||||
t.Fatalf("AppendEvent: %v", err)
|
||||
}
|
||||
|
||||
side, err := store.Fork(parent.SessionID, ForkInput{
|
||||
SessionID: "side",
|
||||
SessionKind: SessionKindSide,
|
||||
Tag: "btw",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Fork side: %v", err)
|
||||
}
|
||||
if side.SessionKind != SessionKindSide || side.Tag != "btw" || side.ParentSessionID != parent.SessionID {
|
||||
t.Fatalf("side metadata = %#v", side)
|
||||
}
|
||||
if IsResumableKind(side.SessionKind) {
|
||||
t.Fatal("side sessions must not appear as resumable conversations")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStoreForkSkipsUsageEvents(t *testing.T) {
|
||||
store := NewStore(StoreOptions{RootDir: t.TempDir(), Now: fixedClock("2026-06-04T11:00:00Z")})
|
||||
parent, err := store.Create(CreateInput{SessionID: "parent", Title: "Parent"})
|
||||
@@ -407,7 +381,6 @@ func TestListAndLatestResumableExcludeSubRuns(t *testing.T) {
|
||||
mk(SessionKindSpecImpl, "spec-impl-1")
|
||||
newestResumable := mk("", "conversation-2") // newest standalone conversation
|
||||
mk(SessionKindChild, "child-2") // newer overall, but a sub-run
|
||||
mk(SessionKindSide, "side-1") // newer overall, but non-resumable
|
||||
|
||||
resumable, err := store.ListResumable()
|
||||
if err != nil {
|
||||
@@ -431,7 +404,7 @@ func TestListAndLatestResumableExcludeSubRuns(t *testing.T) {
|
||||
if latest != nil {
|
||||
got = latest.SessionID
|
||||
}
|
||||
t.Fatalf("LatestResumable = %s, want newest resumable %s (must skip newer child and side sessions)", got, newestResumable.SessionID)
|
||||
t.Fatalf("LatestResumable = %s, want newest resumable %s (must skip the newer child)", got, newestResumable.SessionID)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -562,9 +535,6 @@ func TestPrepareExecSessionResolvesResumeAndFork(t *testing.T) {
|
||||
if _, err := store.AppendEvent("latest", AppendEventInput{Type: EventMessage, Payload: map[string]any{"content": "previous answer"}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := store.Create(CreateInput{SessionID: "newer-side", SessionKind: SessionKindSide}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
prepared, err := PrepareExec(PrepareExecOptions{Store: store, ResumeLatest: true})
|
||||
if err != nil {
|
||||
@@ -576,9 +546,6 @@ func TestPrepareExecSessionResolvesResumeAndFork(t *testing.T) {
|
||||
if got := FormatExecPrompt("continue", prepared); got == "continue" || !strings.Contains(got, "previous answer") {
|
||||
t.Fatalf("expected session context in prompt, got %q", got)
|
||||
}
|
||||
if _, err := PrepareExec(PrepareExecOptions{Store: store, Resume: "newer-side"}); err == nil || !strings.Contains(err.Error(), "Zero session is not resumable: newer-side") {
|
||||
t.Fatalf("explicit side-session resume error = %v, want non-resumable rejection", err)
|
||||
}
|
||||
|
||||
forked, err := PrepareExec(PrepareExecOptions{Store: store, Fork: "latest", SessionID: "forked"})
|
||||
if err != nil {
|
||||
|
||||
@@ -1,325 +0,0 @@
|
||||
package tui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
tea "charm.land/bubbletea/v2"
|
||||
|
||||
"github.com/Gitlawb/zero/internal/sessions"
|
||||
"github.com/Gitlawb/zero/internal/usage"
|
||||
)
|
||||
|
||||
const (
|
||||
btwSessionTag = "btw"
|
||||
// btwRunIDGap keeps the hidden parent's current run below the first side run.
|
||||
// A parent cannot start another user turn while its surface is hidden; the
|
||||
// monotonic btwRunIDSeq separately prevents collisions across BTW re-entry.
|
||||
btwRunIDGap = 1_000_000
|
||||
|
||||
btwContextBoundary = `You are in an isolated side conversation. The inherited session history is reference context only.
|
||||
Do not continue or complete earlier tasks, plans, tool calls, approvals, or requests. Only instructions submitted after this boundary are active.
|
||||
Answer questions and explore lightly. Do not modify workspace state unless the user explicitly asks for that mutation in this side conversation.
|
||||
Nothing from this side conversation will be merged into the main session.`
|
||||
)
|
||||
|
||||
// btwState keeps the main surface alive while an isolated side conversation is
|
||||
// visible. The parent model continues receiving its own run messages, but its
|
||||
// transcript and session events stay hidden until the user returns.
|
||||
type btwState struct {
|
||||
active bool
|
||||
parent *model
|
||||
sideRunIDBase int
|
||||
parentNeedsInput bool
|
||||
}
|
||||
|
||||
func (m model) handleBTWCommand(question string) (model, tea.Cmd) {
|
||||
question = strings.TrimSpace(question)
|
||||
if m.btw.active {
|
||||
if question != "" {
|
||||
return m.appendSystemNotice("A BTW conversation is already active. Run /btw with no question to return to the main session."), nil
|
||||
}
|
||||
return m.leaveBTW()
|
||||
}
|
||||
if m.compactInFlight {
|
||||
return m.appendSystemNotice("Compaction is running. Wait for it to finish before opening a BTW conversation."), nil
|
||||
}
|
||||
if m.exiting {
|
||||
return m.appendSystemNotice("Zero is waiting for the current run to finish saving before exit. A BTW conversation cannot start now."), nil
|
||||
}
|
||||
if m.activeSession.SessionID == "" {
|
||||
return m.appendSystemNotice("Start the main session with a prompt before opening a BTW conversation."), nil
|
||||
}
|
||||
if m.sessionStore == nil {
|
||||
return m.appendSystemNotice("BTW conversation unavailable: no session store configured."), nil
|
||||
}
|
||||
|
||||
fork, err := m.sessionStore.Fork(m.activeSession.SessionID, sessions.ForkInput{
|
||||
SessionKind: sessions.SessionKindSide,
|
||||
Title: btwTitle(m.activeSession.Title),
|
||||
Cwd: m.cwd,
|
||||
ModelID: m.modelName,
|
||||
Provider: m.providerName,
|
||||
Tag: btwSessionTag,
|
||||
})
|
||||
if err != nil {
|
||||
return m.appendSystemNotice("Could not open BTW conversation: " + err.Error()), nil
|
||||
}
|
||||
events, err := m.resumeEvents(fork.SessionID)
|
||||
if err != nil {
|
||||
return m.appendSystemNotice("Could not load BTW conversation: " + err.Error()), nil
|
||||
}
|
||||
|
||||
// Foreground loops are session-scoped. Stop them only after the side session
|
||||
// is ready, so a failed fork cannot destroy work in the main session.
|
||||
parent := m
|
||||
clearedLoops := 0
|
||||
if updated, cleared := parent.clearLoopsForSessionSwitch(); cleared > 0 {
|
||||
parent = updated
|
||||
clearedLoops = cleared
|
||||
parent.transcript = reduceTranscript(parent.transcript, transcriptAction{
|
||||
kind: actionAppendSystem,
|
||||
text: fmt.Sprintf("Stopped %d loop(s) before opening the BTW conversation.", cleared),
|
||||
})
|
||||
}
|
||||
parent.btw = btwState{}
|
||||
// A scrollback print that was already scheduled may acknowledge after the
|
||||
// side surface is active. The hidden model does not receive that unscoped
|
||||
// acknowledgement, so clear its print latch and rebuild on return.
|
||||
parent.printInFlight = false
|
||||
parent.flushQueue = nil
|
||||
|
||||
side := parent
|
||||
side.activeSession = fork
|
||||
side.sessionEvents = events
|
||||
side.transcript = initialTranscript()
|
||||
side.transcript = appendRow(side.transcript, rowSystem, "BTW conversation · isolated from the main session · /btw or Ctrl+C to return")
|
||||
if clearedLoops > 0 {
|
||||
side.transcript = appendRow(side.transcript, rowSystem, fmt.Sprintf("Stopped %d main-session loop(s) before opening this conversation.", clearedLoops))
|
||||
}
|
||||
side.transcript = appendTranscriptRowsDedup(side.transcript, transcriptRowsFromSessionEvents(events))
|
||||
side.printInFlight = false
|
||||
side.flushQueue = nil
|
||||
side.resetFlushFrontier("· btw conversation ·")
|
||||
side.pending = false
|
||||
side.exiting = false
|
||||
side.runCancel = nil
|
||||
side.activeRunID = 0
|
||||
side.runID = maxInt(parent.runID+btwRunIDGap, parent.btwRunIDSeq)
|
||||
side.flushRunIDs = map[int]string{}
|
||||
side.liveUsageCounts = map[int]int{}
|
||||
side.usageTracker = usage.NewTracker(usage.TrackerOptions{Registry: &side.modelCatalog, Now: side.now})
|
||||
side.lastUsage = usage.Normalized{}
|
||||
side.lastUsageSeen = false
|
||||
side.unpricedRequests = 0
|
||||
side.unpricedTokens = 0
|
||||
side.compactRequests = 0
|
||||
side.compactFrame = 0
|
||||
side.lastCompactResult = nil
|
||||
side.lastCompactError = ""
|
||||
side.turnLatencySum = 0
|
||||
side.turnLatencyCount = 0
|
||||
side.turnTTFTSum = 0
|
||||
side.turnTTFTCount = 0
|
||||
side.pendingPermission = nil
|
||||
side.pendingAskUser = nil
|
||||
side.pendingSpecReview = nil
|
||||
side.queuedMessage = ""
|
||||
side.lastPrompt = ""
|
||||
side.lastImages = nil
|
||||
side.lastImageLabels = nil
|
||||
side.lastDocuments = nil
|
||||
side.inputHistory = nil
|
||||
side.historyIdx = 0
|
||||
side.historyDraft = ""
|
||||
if question == "" {
|
||||
side.pendingImages = nil
|
||||
side.pendingImageLabels = nil
|
||||
side.pendingDocuments = nil
|
||||
}
|
||||
side.loops = nil
|
||||
side.activeLoopID = ""
|
||||
side.loopTicking = false
|
||||
side.specialists.clear()
|
||||
side.plan.clear()
|
||||
side.planDetailGen++
|
||||
side.streamingText = nil
|
||||
side.streamingReasoning = ""
|
||||
side.streamingReasoningExpanded = false
|
||||
side.clearStreamingToolCall()
|
||||
side.resetStreamingFade()
|
||||
side.btw = btwState{
|
||||
active: true,
|
||||
parent: &parent,
|
||||
sideRunIDBase: side.runID,
|
||||
}
|
||||
|
||||
if question == "" {
|
||||
return side, nil
|
||||
}
|
||||
return side.launchPrompt(question)
|
||||
}
|
||||
|
||||
func (m model) leaveBTW() (model, tea.Cmd) {
|
||||
if !m.btw.active || m.btw.parent == nil {
|
||||
return m, nil
|
||||
}
|
||||
if m.pending {
|
||||
return m.appendSystemNotice("A BTW response is still running. Press Esc twice to cancel it, or wait for it to finish before returning."), nil
|
||||
}
|
||||
if len(m.flushRunIDs) > 0 {
|
||||
return m.appendSystemNotice("The cancelled BTW response is still saving its session events. Wait for it to finish before returning."), nil
|
||||
}
|
||||
if m.compactInFlight {
|
||||
return m.appendSystemNotice("BTW compaction is still running. Wait for it to finish before returning."), nil
|
||||
}
|
||||
m, _ = m.clearLoopsForSessionSwitch()
|
||||
parent := *m.btw.parent
|
||||
parent.btwRunIDSeq = maxInt(parent.btwRunIDSeq, m.runID)
|
||||
parent.btw = btwState{}
|
||||
// A hidden parent completion may have scheduled an unscoped git-sweep result
|
||||
// that landed on the side surface. Re-run it after restoring the parent so
|
||||
// its FILES sidebar cannot stay permanently marked in-flight or stale.
|
||||
parent.gitSweepInFlight = false
|
||||
var sweepCmd tea.Cmd
|
||||
parent, sweepCmd = parent.maybeGitSweep()
|
||||
// The side surface owns its own spinner tick chain. If the hidden parent is
|
||||
// still active, explicitly restart that chain after restoring it.
|
||||
parent.spinnerTicking = false
|
||||
var spinnerCmd tea.Cmd
|
||||
if parent.pending || parent.compactInFlight || parent.doctorInFlight || parent.sidebarHasAgents() || parent.aimlapiOnboardAnimating() {
|
||||
parent.spinnerTicking = true
|
||||
spinnerCmd = parent.spinner.Tick
|
||||
}
|
||||
parent.transcript = reduceTranscript(parent.transcript, transcriptAction{
|
||||
kind: actionAppendSystem,
|
||||
text: "Returned from the isolated BTW conversation. Its messages were not added to this session.",
|
||||
})
|
||||
parent.resetFlushFrontier("· returned from btw ·")
|
||||
return parent, batchCommands(sweepCmd, spinnerCmd)
|
||||
}
|
||||
|
||||
func btwCommandUnavailable(command parsedCommand) bool {
|
||||
arg := strings.ToLower(strings.TrimSpace(command.text))
|
||||
switch command.kind {
|
||||
case commandNew, commandResume, commandRetitle, commandSpec, commandLoop,
|
||||
commandRewind, commandCompact, commandSTTModel, commandMCP:
|
||||
return true
|
||||
case commandModel:
|
||||
return arg != "list" && arg != "ls"
|
||||
case commandProvider:
|
||||
return arg != "status"
|
||||
case commandTurns, commandProfile:
|
||||
return arg != "" && arg != "status"
|
||||
case commandTheme:
|
||||
return arg != "list"
|
||||
case commandConfig:
|
||||
return arg != ""
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// resizeBTWParent carries terminal geometry into the hidden parent. Window-size
|
||||
// messages have no run ID, so normal BTW routing intentionally leaves them on
|
||||
// the visible side surface; copying the layout fields prevents stale wrapping
|
||||
// after the parent is restored.
|
||||
func (m model) resizeBTWParent(msg tea.WindowSizeMsg) model {
|
||||
if !m.btw.active || m.btw.parent == nil {
|
||||
return m
|
||||
}
|
||||
parent := *m.btw.parent
|
||||
parent.width = msg.Width
|
||||
parent.height = msg.Height
|
||||
parent = parent.clearHover()
|
||||
parent.lineAges = nil
|
||||
parent.lastStreamActivity = parent.now()
|
||||
parent.input.SetWidth(maxInt(20, chatWidth(msg.Width)-14))
|
||||
m.btw.parent = &parent
|
||||
return m
|
||||
}
|
||||
|
||||
func btwTitle(parent string) string {
|
||||
parent = strings.TrimSpace(parent)
|
||||
if parent == "" {
|
||||
return "BTW conversation"
|
||||
}
|
||||
return parent + " (BTW)"
|
||||
}
|
||||
|
||||
// routeBTWParentMessage lets a main-session run finish while the side surface is
|
||||
// active. Side run IDs start far above the captured parent's counter, so messages
|
||||
// below that boundary unambiguously belong to the hidden parent model.
|
||||
func (m model) routeBTWParentMessage(msg tea.Msg) (model, tea.Cmd, bool) {
|
||||
if !m.btw.active || m.btw.parent == nil {
|
||||
return m, nil, false
|
||||
}
|
||||
if title, ok := msg.(sessionTitleGeneratedMsg); ok {
|
||||
if title.sessionID != m.btw.parent.activeSession.SessionID {
|
||||
return m, nil, false
|
||||
}
|
||||
return m.routeBTWMessageToParent(msg)
|
||||
}
|
||||
runID, ok := btwMessageRunID(msg)
|
||||
if !ok || runID <= 0 || runID >= m.btw.sideRunIDBase {
|
||||
return m, nil, false
|
||||
}
|
||||
return m.routeBTWMessageToParent(msg)
|
||||
}
|
||||
|
||||
func (m model) routeBTWMessageToParent(msg tea.Msg) (model, tea.Cmd, bool) {
|
||||
parentNext, cmd := m.btw.parent.updateModel(msg)
|
||||
parent, ok := parentNext.(model)
|
||||
if !ok {
|
||||
return m, cmd, true
|
||||
}
|
||||
parent.btw = btwState{}
|
||||
m.btw.parent = &parent
|
||||
switch msg.(type) {
|
||||
case permissionRequestMsg, askUserRequestMsg:
|
||||
if !m.btw.parentNeedsInput {
|
||||
m.btw.parentNeedsInput = true
|
||||
m = m.appendSystemNotice("The main session needs your input. Return with /btw or Ctrl+C to respond.")
|
||||
}
|
||||
case agentResponseMsg:
|
||||
m.btw.parentNeedsInput = parent.pendingPermission != nil || parent.pendingAskUser != nil
|
||||
}
|
||||
return m, cmd, true
|
||||
}
|
||||
|
||||
func btwMessageRunID(msg tea.Msg) (int, bool) {
|
||||
switch typed := msg.(type) {
|
||||
case agentTextMsg:
|
||||
return typed.runID, true
|
||||
case agentReasoningMsg:
|
||||
return typed.runID, true
|
||||
case agentUsageMsg:
|
||||
return typed.runID, true
|
||||
case agentResponseMsg:
|
||||
return typed.runID, true
|
||||
case agentRowMsg:
|
||||
return typed.runID, true
|
||||
case toolCallStreamStartMsg:
|
||||
return typed.runID, true
|
||||
case toolCallStreamDeltaMsg:
|
||||
return typed.runID, true
|
||||
case planUpdateMsg:
|
||||
return typed.runID, true
|
||||
case specialistStartMsg:
|
||||
return typed.runID, true
|
||||
case specialistCompleteMsg:
|
||||
return typed.runID, true
|
||||
case specialistProgressMsg:
|
||||
return typed.runID, true
|
||||
case swarmSessionsMsg:
|
||||
return typed.runID, true
|
||||
case permissionRequestMsg:
|
||||
return typed.runID, true
|
||||
case askUserRequestMsg:
|
||||
return typed.runID, true
|
||||
case recapGeneratedMsg:
|
||||
return typed.runID, true
|
||||
default:
|
||||
return 0, false
|
||||
}
|
||||
}
|
||||
@@ -1,430 +0,0 @@
|
||||
package tui
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
tea "charm.land/bubbletea/v2"
|
||||
|
||||
"github.com/Gitlawb/zero/internal/sessions"
|
||||
)
|
||||
|
||||
func newBTWTestModel(t *testing.T) model {
|
||||
t.Helper()
|
||||
store := sessions.NewStore(sessions.StoreOptions{RootDir: t.TempDir()})
|
||||
parent, err := store.Create(sessions.CreateInput{
|
||||
SessionID: "main-session",
|
||||
Title: "Main task",
|
||||
Cwd: "/repo",
|
||||
ModelID: "test-model",
|
||||
Provider: "test-provider",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("create parent session: %v", err)
|
||||
}
|
||||
for _, payload := range []map[string]any{
|
||||
{"role": "user", "content": "implement the main task"},
|
||||
{"role": "assistant", "content": "working on it"},
|
||||
} {
|
||||
if _, err := store.AppendEvent(parent.SessionID, sessions.AppendEventInput{Type: sessions.EventMessage, Payload: payload}); err != nil {
|
||||
t.Fatalf("append parent event: %v", err)
|
||||
}
|
||||
}
|
||||
loaded, err := store.Get(parent.SessionID)
|
||||
if err != nil || loaded == nil {
|
||||
t.Fatalf("load parent session: session=%#v err=%v", loaded, err)
|
||||
}
|
||||
events, err := store.ReadEvents(parent.SessionID)
|
||||
if err != nil {
|
||||
t.Fatalf("read parent events: %v", err)
|
||||
}
|
||||
m := newModel(context.Background(), Options{
|
||||
Cwd: "/repo",
|
||||
ModelName: "test-model",
|
||||
ProviderName: "test-provider",
|
||||
SessionStore: store,
|
||||
})
|
||||
m.activeSession = *loaded
|
||||
m.sessionEvents = events
|
||||
m.transcript = appendTranscriptRowsDedup(initialTranscript(), transcriptRowsFromSessionEvents(events))
|
||||
return m
|
||||
}
|
||||
|
||||
func TestBTWCommandParsesInlineQuestion(t *testing.T) {
|
||||
got := parseCommand("/btw double-check the approach")
|
||||
if got.kind != commandBTW || got.text != "double-check the approach" {
|
||||
t.Fatalf("parseCommand(/btw ...) = %#v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBTWCreatesIsolatedForkAndReturnsWithoutMerge(t *testing.T) {
|
||||
m := newBTWTestModel(t)
|
||||
parentID := m.activeSession.SessionID
|
||||
parentEventCount := len(m.sessionEvents)
|
||||
|
||||
side, cmd := m.handleBTWCommand("")
|
||||
if cmd != nil {
|
||||
t.Fatal("bare /btw should not start an agent run")
|
||||
}
|
||||
if !side.btw.active || side.btw.parent == nil {
|
||||
t.Fatal("expected active BTW state with saved parent")
|
||||
}
|
||||
if side.activeSession.SessionKind != sessions.SessionKindSide || side.activeSession.ParentSessionID != parentID {
|
||||
t.Fatalf("side metadata = %#v", side.activeSession)
|
||||
}
|
||||
if side.activeSession.Tag != btwSessionTag {
|
||||
t.Fatalf("side tag = %q, want %q", side.activeSession.Tag, btwSessionTag)
|
||||
}
|
||||
if len(side.sessionEvents) <= parentEventCount {
|
||||
t.Fatalf("side should contain copied context plus fork marker: got %d events", len(side.sessionEvents))
|
||||
}
|
||||
if !strings.Contains(side.sessionPrompt("question"), btwContextBoundary) {
|
||||
t.Fatal("side prompt is missing the inherited-context boundary")
|
||||
}
|
||||
|
||||
updated, err := side.appendSessionEvent(sessions.EventMessage, map[string]any{
|
||||
"role": "assistant", "content": "side-only answer",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("append side event: %v", err)
|
||||
}
|
||||
returned, _ := updated.leaveBTW()
|
||||
if returned.activeSession.SessionID != parentID {
|
||||
t.Fatalf("returned session = %q, want %q", returned.activeSession.SessionID, parentID)
|
||||
}
|
||||
if len(returned.sessionEvents) != parentEventCount {
|
||||
t.Fatalf("side events merged into parent: got %d events, want %d", len(returned.sessionEvents), parentEventCount)
|
||||
}
|
||||
parentEvents, err := returned.sessionStore.ReadEvents(parentID)
|
||||
if err != nil {
|
||||
t.Fatalf("read parent after return: %v", err)
|
||||
}
|
||||
for _, event := range parentEvents {
|
||||
if strings.Contains(string(event.Payload), "side-only answer") {
|
||||
t.Fatal("side-only event was persisted into the parent session")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestBTWCanOpenWhileParentRunContinues(t *testing.T) {
|
||||
m := newBTWTestModel(t)
|
||||
m.pending = true
|
||||
m.runID = 7
|
||||
m.activeRunID = 7
|
||||
|
||||
side, _ := m.handleBTWCommand("")
|
||||
if side.pending || side.activeRunID != 0 {
|
||||
t.Fatalf("side inherited parent run state: pending=%v activeRunID=%d", side.pending, side.activeRunID)
|
||||
}
|
||||
if side.btw.parent == nil || !side.btw.parent.pending || side.btw.parent.activeRunID != 7 {
|
||||
t.Fatalf("parent run was not preserved: %#v", side.btw.parent)
|
||||
}
|
||||
|
||||
routed, _, ok := side.routeBTWParentMessage(agentTextMsg{runID: 7, delta: "main progress"})
|
||||
if !ok {
|
||||
t.Fatal("parent run message was not routed")
|
||||
}
|
||||
if strings.Contains(routed.streamingTextString(), "main progress") {
|
||||
t.Fatal("parent streaming output leaked into the side transcript")
|
||||
}
|
||||
if routed.btw.parent == nil || !strings.Contains(routed.btw.parent.streamingTextString(), "main progress") {
|
||||
t.Fatal("parent streaming output was not retained on the hidden parent")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBTWInlineQuestionStartsSideRun(t *testing.T) {
|
||||
m := newBTWTestModel(t)
|
||||
m.provider = &fakeProvider{}
|
||||
|
||||
side, cmd := m.handleBTWCommand("double-check this assumption")
|
||||
if cmd == nil || !side.pending {
|
||||
t.Fatalf("inline /btw question did not start a run: pending=%v cmd=%v", side.pending, cmd)
|
||||
}
|
||||
if side.lastPrompt != "double-check this assumption" {
|
||||
t.Fatalf("side last prompt = %q", side.lastPrompt)
|
||||
}
|
||||
if side.btw.parent == nil || side.btw.parent.pending {
|
||||
t.Fatal("idle parent should remain idle while the side run starts")
|
||||
}
|
||||
parentEvents, err := side.sessionStore.ReadEvents(side.btw.parent.activeSession.SessionID)
|
||||
if err != nil {
|
||||
t.Fatalf("read parent events: %v", err)
|
||||
}
|
||||
for _, event := range parentEvents {
|
||||
if strings.Contains(string(event.Payload), "double-check this assumption") {
|
||||
t.Fatal("inline side question was written into the parent session")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestBTWRejectsBeforeMainSessionStarts(t *testing.T) {
|
||||
m := newModel(context.Background(), Options{SessionStore: sessions.NewStore(sessions.StoreOptions{RootDir: t.TempDir()})})
|
||||
got, cmd := m.handleBTWCommand("")
|
||||
if cmd != nil {
|
||||
t.Fatal("pre-session /btw should not start work")
|
||||
}
|
||||
if got.btw.active || !transcriptContains(got.transcript, "Start the main session") {
|
||||
t.Fatalf("unexpected pre-session /btw result: active=%v transcript=%#v", got.btw.active, got.transcript)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBTWBlocksCommandsThatWouldReplaceItsSession(t *testing.T) {
|
||||
m := newBTWTestModel(t)
|
||||
side, _ := m.handleBTWCommand("")
|
||||
updated, _ := side.dispatchCommand(parseCommand("/new"))
|
||||
got := updated.(model)
|
||||
if !got.btw.active || got.activeSession.SessionKind != sessions.SessionKindSide {
|
||||
t.Fatalf("/new replaced the active BTW session: active=%v metadata=%#v", got.btw.active, got.activeSession)
|
||||
}
|
||||
if !transcriptContains(got.transcript, "unavailable in a BTW conversation") {
|
||||
t.Fatalf("missing blocked-command guidance: %#v", got.transcript)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBTWBlocksPersistentConfigurationCommands(t *testing.T) {
|
||||
for _, input := range []string{
|
||||
"/model other",
|
||||
"/provider add",
|
||||
"/turns 100",
|
||||
"/profile fast",
|
||||
"/theme dark",
|
||||
"/config recaps off",
|
||||
"/stt-model",
|
||||
"/mcp",
|
||||
"/rewind",
|
||||
"/compact",
|
||||
} {
|
||||
t.Run(input, func(t *testing.T) {
|
||||
m := newBTWTestModel(t)
|
||||
side, _ := m.handleBTWCommand("")
|
||||
updated, _ := side.dispatchCommand(parseCommand(input))
|
||||
got := updated.(model)
|
||||
if !got.btw.active || got.activeSession.SessionKind != sessions.SessionKindSide {
|
||||
t.Fatalf("%s escaped the active BTW session: active=%v metadata=%#v", input, got.btw.active, got.activeSession)
|
||||
}
|
||||
if !transcriptContains(got.transcript, "unavailable in a BTW conversation") {
|
||||
t.Fatalf("%s missing blocked-command guidance: %#v", input, got.transcript)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestBTWAllowsReadOnlyConfigurationCommands(t *testing.T) {
|
||||
for _, input := range []string{
|
||||
"/model list",
|
||||
"/provider status",
|
||||
"/turns",
|
||||
"/profile status",
|
||||
"/theme list",
|
||||
"/config",
|
||||
} {
|
||||
t.Run(input, func(t *testing.T) {
|
||||
m := newBTWTestModel(t)
|
||||
side, _ := m.handleBTWCommand("")
|
||||
updated, _ := side.dispatchCommand(parseCommand(input))
|
||||
got := updated.(model)
|
||||
if transcriptContains(got.transcript, "unavailable in a BTW conversation") {
|
||||
t.Fatalf("%s was blocked even though it is read-only", input)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestBTWExitBlockedWhileParentRunActive(t *testing.T) {
|
||||
m := newBTWTestModel(t)
|
||||
m.pending = true
|
||||
m.activeRunID = 7
|
||||
side, _ := m.handleBTWCommand("")
|
||||
|
||||
updated, cmd := side.dispatchCommand(parseCommand("/exit"))
|
||||
got := updated.(model)
|
||||
if cmd != nil || got.exiting || !got.btw.active {
|
||||
t.Fatalf("/exit escaped BTW while parent was active: cmd=%v exiting=%v active=%v", cmd, got.exiting, got.btw.active)
|
||||
}
|
||||
if got.btw.parent == nil || !got.btw.parent.pending {
|
||||
t.Fatalf("hidden parent run was not preserved: %#v", got.btw.parent)
|
||||
}
|
||||
if !transcriptContains(got.transcript, "main session is still running") {
|
||||
t.Fatalf("missing active-parent exit guidance: %#v", got.transcript)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBTWReturnRestartsParentSpinner(t *testing.T) {
|
||||
for _, reducedMotion := range []bool{false, true} {
|
||||
t.Run(map[bool]string{false: "animated", true: "reduced-motion"}[reducedMotion], func(t *testing.T) {
|
||||
m := newBTWTestModel(t)
|
||||
m.reducedMotion = reducedMotion
|
||||
m.pending = true
|
||||
m.spinnerTicking = true
|
||||
side, _ := m.handleBTWCommand("")
|
||||
side.spinnerTicking = false
|
||||
|
||||
returned, cmd := side.leaveBTW()
|
||||
if !returned.pending || !returned.spinnerTicking {
|
||||
t.Fatalf("parent spinner was not restarted: pending=%v ticking=%v", returned.pending, returned.spinnerTicking)
|
||||
}
|
||||
if cmd == nil {
|
||||
t.Fatal("returning to an active parent did not schedule a spinner tick")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestBTWCancelledRunFlushesBeforeReturnAndRunIDsStayUnique(t *testing.T) {
|
||||
m := newBTWTestModel(t)
|
||||
m.provider = &fakeProvider{}
|
||||
|
||||
side1, _ := m.handleBTWCommand("first side question")
|
||||
firstRunID := side1.activeRunID
|
||||
side1.cancelRun()
|
||||
blocked, _ := side1.leaveBTW()
|
||||
if !blocked.btw.active || !transcriptContains(blocked.transcript, "still saving its session events") {
|
||||
t.Fatal("BTW returned before the cancelled side run finished flushing")
|
||||
}
|
||||
|
||||
flushedModel, _ := side1.updateModel(agentResponseMsg{runID: firstRunID})
|
||||
flushed := flushedModel.(model)
|
||||
if len(flushed.flushRunIDs) != 0 {
|
||||
t.Fatalf("cancelled side run did not drain: %#v", flushed.flushRunIDs)
|
||||
}
|
||||
parent, _ := flushed.leaveBTW()
|
||||
side2, _ := parent.handleBTWCommand("second side question")
|
||||
if side2.activeRunID == firstRunID {
|
||||
t.Fatalf("BTW run ID was reused across re-entry: %d", firstRunID)
|
||||
}
|
||||
|
||||
updated, _ := side2.updateModel(agentResponseMsg{
|
||||
runID: firstRunID,
|
||||
rows: []transcriptRow{{kind: rowAssistant, text: "answer to the FIRST question"}},
|
||||
})
|
||||
got := updated.(model)
|
||||
if !got.pending || transcriptContains(got.transcript, "answer to the FIRST question") {
|
||||
t.Fatal("a stale side response hijacked the next BTW run")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBTWRejectsExplicitResumeOfSideSession(t *testing.T) {
|
||||
m := newBTWTestModel(t)
|
||||
side, _ := m.handleBTWCommand("")
|
||||
|
||||
if _, err := m.resolveResumeSession(side.activeSession.SessionID); err == nil || !strings.Contains(err.Error(), "not resumable") {
|
||||
t.Fatalf("explicit side-session resume error = %v, want non-resumable rejection", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBTWCannotStartDuringDeferredExit(t *testing.T) {
|
||||
m := newBTWTestModel(t)
|
||||
m.exiting = true
|
||||
|
||||
got, cmd := m.handleBTWCommand("should not run")
|
||||
if cmd != nil || got.btw.active {
|
||||
t.Fatalf("BTW started during deferred exit: active=%v cmd=%v", got.btw.active, cmd)
|
||||
}
|
||||
if !transcriptContains(got.transcript, "cannot start now") {
|
||||
t.Fatalf("missing deferred-exit guidance: %#v", got.transcript)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBTWStatusAndHelpStayVisible(t *testing.T) {
|
||||
m := newBTWTestModel(t)
|
||||
side, _ := m.handleBTWCommand("")
|
||||
|
||||
if status := plainRender(t, side.statusLine(100)); !strings.Contains(status, "BTW") {
|
||||
t.Fatalf("status line has no persistent BTW indicator: %q", status)
|
||||
}
|
||||
groups := side.buildKeybindingGroups()
|
||||
if got := groups[0].bindings[3].desc; !strings.Contains(got, "return to the main session") {
|
||||
t.Fatalf("BTW Ctrl+C help = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBTWResizeUpdatesHiddenParent(t *testing.T) {
|
||||
m := newBTWTestModel(t)
|
||||
m.width = 80
|
||||
m.height = 24
|
||||
side, _ := m.handleBTWCommand("")
|
||||
|
||||
updated, _ := side.updateModel(tea.WindowSizeMsg{Width: 120, Height: 50})
|
||||
got := updated.(model)
|
||||
if got.btw.parent == nil || got.btw.parent.width != 120 || got.btw.parent.height != 50 {
|
||||
t.Fatalf("hidden parent kept stale geometry: %#v", got.btw.parent)
|
||||
}
|
||||
returned, _ := got.leaveBTW()
|
||||
if returned.width != 120 || returned.height != 50 {
|
||||
t.Fatalf("restored parent geometry = %dx%d, want 120x50", returned.width, returned.height)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBTWUsesIndependentUsageTracker(t *testing.T) {
|
||||
m := newBTWTestModel(t)
|
||||
parentTracker := m.usageTracker
|
||||
side, _ := m.handleBTWCommand("")
|
||||
if side.usageTracker == nil || side.usageTracker == parentTracker {
|
||||
t.Fatal("BTW conversation shared the main session usage tracker")
|
||||
}
|
||||
returned, _ := side.leaveBTW()
|
||||
if returned.usageTracker != parentTracker {
|
||||
t.Fatal("returning from BTW did not restore the main session usage tracker")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBTWFailedForkKeepsMainSessionLoops(t *testing.T) {
|
||||
badRoot := filepath.Join(t.TempDir(), "sessions")
|
||||
if err := os.WriteFile(badRoot, []byte("not a directory"), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m := newModel(context.Background(), Options{SessionStore: sessions.NewStore(sessions.StoreOptions{RootDir: badRoot})})
|
||||
m.activeSession = sessions.Metadata{SessionID: "main-session"}
|
||||
m.loops = []*loopState{{id: "loop-1"}}
|
||||
|
||||
got, _ := m.handleBTWCommand("")
|
||||
if len(got.loops) != 1 || got.loops[0].id != "loop-1" {
|
||||
t.Fatalf("failed BTW fork cleared main-session loops: %#v", got.loops)
|
||||
}
|
||||
if !transcriptContains(got.transcript, "Could not open BTW conversation") {
|
||||
t.Fatalf("missing fork failure notice: %#v", got.transcript)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBTWCommandReturnsToParentSession(t *testing.T) {
|
||||
m := newBTWTestModel(t)
|
||||
parentID := m.activeSession.SessionID
|
||||
side, _ := m.handleBTWCommand("")
|
||||
|
||||
updated, cmd := side.dispatchCommand(parseCommand("/btw"))
|
||||
returned := updated.(model)
|
||||
if cmd != nil {
|
||||
t.Fatal("returning from an idle BTW conversation should not start work")
|
||||
}
|
||||
if returned.btw.active || returned.btw.parent != nil {
|
||||
t.Fatalf("BTW state remained active after /btw: %#v", returned.btw)
|
||||
}
|
||||
if returned.activeSession.SessionID != parentID {
|
||||
t.Fatalf("returned session = %q, want parent %q", returned.activeSession.SessionID, parentID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBTWCtrlCDuringRunDoesNotClearDraft(t *testing.T) {
|
||||
m := newBTWTestModel(t)
|
||||
side, _ := m.handleBTWCommand("")
|
||||
side.pending = true
|
||||
side.input.SetValue("keep this draft")
|
||||
|
||||
updated, cmd := side.handleCtrlC()
|
||||
got := updated.(model)
|
||||
if cmd != nil {
|
||||
t.Fatal("Ctrl+C should not start a command while a BTW response is running")
|
||||
}
|
||||
if !got.btw.active {
|
||||
t.Fatal("Ctrl+C returned from BTW while its response was still running")
|
||||
}
|
||||
if got.composerValue() != "keep this draft" {
|
||||
t.Fatalf("Ctrl+C cleared the in-flight BTW draft: %q", got.composerValue())
|
||||
}
|
||||
if !transcriptContains(got.transcript, "BTW response is still running") {
|
||||
t.Fatalf("missing in-flight return guidance: %#v", got.transcript)
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,6 @@ const (
|
||||
commandCopy
|
||||
commandExport
|
||||
commandNew
|
||||
commandBTW
|
||||
commandSkills
|
||||
commandLoop
|
||||
commandVoice
|
||||
@@ -193,13 +192,6 @@ var commandDefinitions = []commandDefinition{
|
||||
description: "Start a fresh session; the current one stays resumable via /resume.",
|
||||
kind: commandNew,
|
||||
},
|
||||
{
|
||||
name: "/btw",
|
||||
usage: "/btw [question]",
|
||||
group: commandGroupSession,
|
||||
description: "Open an isolated side conversation; run /btw again to return.",
|
||||
kind: commandBTW,
|
||||
},
|
||||
{
|
||||
name: "/search",
|
||||
aliases: []string{"/find"},
|
||||
|
||||
@@ -31,10 +31,6 @@ type keybindingGroup struct {
|
||||
// Sourced from the real key cases in model.go (Update) — not invented. When a
|
||||
// binding is added/changed there, update this method too.
|
||||
func (m model) buildKeybindingGroups() []keybindingGroup {
|
||||
ctrlCDescription := "cancel the run, then quit"
|
||||
if m.btw.active {
|
||||
ctrlCDescription = "return to the main session when the BTW run is idle"
|
||||
}
|
||||
return []keybindingGroup{
|
||||
{
|
||||
title: "Chat",
|
||||
@@ -42,7 +38,7 @@ func (m model) buildKeybindingGroups() []keybindingGroup {
|
||||
{"Enter", "send the message"},
|
||||
{"Shift+Enter / Alt+Enter", "insert a newline (multi-line compose)"},
|
||||
{"Esc (\u00d72)", "cancel the run / dismiss a popup / clear the input"},
|
||||
{"Ctrl+C", ctrlCDescription},
|
||||
{"Ctrl+C", "cancel the run, then quit"},
|
||||
{"Ctrl+X then letter", "common slash commands (m=/model, p=/provider, r=/resume, \u2026)"},
|
||||
{"Ctrl+X ?", "list every Ctrl+X slash shortcut"},
|
||||
{"?", "show this help (on an empty input)"},
|
||||
|
||||
@@ -103,11 +103,6 @@ type model struct {
|
||||
doctorFrame int
|
||||
activeSession sessions.Metadata
|
||||
sessionEvents []sessions.Event
|
||||
btw btwState
|
||||
// btwRunIDSeq is the highest run ID issued by any completed or abandoned BTW
|
||||
// surface. It survives returning to the parent so a late message from an old
|
||||
// side run can never match a run in a later BTW conversation.
|
||||
btwRunIDSeq int
|
||||
// titledSessions records session ids for which a model-generated title has
|
||||
// already been attempted this process, so a finished turn re-fires the title
|
||||
// generator at most once per session (even before its async result lands).
|
||||
@@ -1034,14 +1029,6 @@ func (m model) shutdownLSPManager() {
|
||||
}
|
||||
|
||||
func (m model) handleCtrlC() (tea.Model, tea.Cmd) {
|
||||
if m.btw.active {
|
||||
if !m.pending && m.composerValue() != "" && m.noBlockingModal() && !m.transcriptDetailed && !m.subchat.active {
|
||||
m.clearComposer()
|
||||
m.clearSuggestions()
|
||||
return m, nil
|
||||
}
|
||||
return m.leaveBTW()
|
||||
}
|
||||
if !m.pending && m.composerValue() != "" && m.noBlockingModal() && !m.transcriptDetailed && !m.subchat.active {
|
||||
m.clearComposer()
|
||||
m.clearSuggestions()
|
||||
@@ -1121,12 +1108,6 @@ func batchCommands(cmds ...tea.Cmd) tea.Cmd {
|
||||
}
|
||||
|
||||
func (m model) updateModel(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
if size, ok := msg.(tea.WindowSizeMsg); ok {
|
||||
m = m.resizeBTWParent(size)
|
||||
}
|
||||
if next, cmd, routed := m.routeBTWParentMessage(msg); routed {
|
||||
return next, cmd
|
||||
}
|
||||
switch msg := msg.(type) {
|
||||
case composerBlinkMsg:
|
||||
switch {
|
||||
@@ -4133,21 +4114,6 @@ func (m model) handleSubmit() (tea.Model, tea.Cmd) {
|
||||
// dispatchCommand runs a parsed slash/prompt command after submit/leader
|
||||
// preamble (history, composer clear, leave-prompt disarm) has already run.
|
||||
func (m model) dispatchCommand(command parsedCommand) (tea.Model, tea.Cmd) {
|
||||
if m.btw.active && command.kind == commandExit && m.btw.parent != nil &&
|
||||
(m.btw.parent.pending || m.btw.parent.compactInFlight || len(m.btw.parent.flushRunIDs) > 0) {
|
||||
m.transcript = reduceTranscript(m.transcript, transcriptAction{
|
||||
kind: actionAppendSystem,
|
||||
text: "The main session is still running. Return to it first with /btw or Ctrl+C before exiting.",
|
||||
})
|
||||
return m, nil
|
||||
}
|
||||
if m.btw.active && btwCommandUnavailable(command) {
|
||||
m.transcript = reduceTranscript(m.transcript, transcriptAction{
|
||||
kind: actionAppendSystem,
|
||||
text: command.name + " is unavailable in a BTW conversation. Return to the main session first with /btw or Ctrl+C.",
|
||||
})
|
||||
return m, nil
|
||||
}
|
||||
switch command.kind {
|
||||
case commandEmpty:
|
||||
return m, nil
|
||||
@@ -4186,8 +4152,6 @@ func (m model) dispatchCommand(command parsedCommand) (tea.Model, tea.Cmd) {
|
||||
return m, nil
|
||||
}
|
||||
return m.startNewSession(), nil
|
||||
case commandBTW:
|
||||
return m.handleBTWCommand(command.text)
|
||||
case commandLoop:
|
||||
return m.handleLoopCommand(command.text)
|
||||
case commandExit:
|
||||
|
||||
@@ -246,15 +246,11 @@ func (m model) sessionPrompt(prompt string) string {
|
||||
if m.activeSession.SessionID == "" || len(m.sessionEvents) == 0 {
|
||||
return prompt
|
||||
}
|
||||
formatted := sessions.FormatExecPrompt(prompt, sessions.PreparedExec{
|
||||
return sessions.FormatExecPrompt(prompt, sessions.PreparedExec{
|
||||
Mode: sessions.ModeResume,
|
||||
Session: m.activeSession,
|
||||
ContextEvents: append([]sessions.Event{}, m.sessionEvents...),
|
||||
})
|
||||
if m.activeSession.SessionKind == sessions.SessionKindSide {
|
||||
return btwContextBoundary + "\n\n" + formatted
|
||||
}
|
||||
return formatted
|
||||
}
|
||||
|
||||
func (m model) resolveResumeSession(args string) (*sessions.Metadata, error) {
|
||||
@@ -280,9 +276,6 @@ func (m model) resolveResumeSession(args string) (*sessions.Metadata, error) {
|
||||
if session == nil {
|
||||
return nil, fmt.Errorf("zero session not found: %s", args)
|
||||
}
|
||||
if !sessions.IsResumableKind(session.SessionKind) {
|
||||
return nil, fmt.Errorf("zero session is not resumable: %s", args)
|
||||
}
|
||||
return session, nil
|
||||
}
|
||||
|
||||
|
||||
+8
-12
@@ -195,21 +195,17 @@ func (m model) statusLine(width int) string {
|
||||
// in its mode colour. This was previously only on the easy-to-miss composer
|
||||
// rule; the persistent footer is where users look for "will it run commands?".
|
||||
modeText, modeStyle := m.modeLabel()
|
||||
btwChip := ""
|
||||
if m.btw.active {
|
||||
btwChip = zeroTheme.amber.Render("BTW") + zeroTheme.muted.Render(" · ")
|
||||
}
|
||||
left := prefix + btwChip + zeroTheme.accent.Render("●") + " " + modeStyle.Render(modeText)
|
||||
left := prefix + zeroTheme.accent.Render("●") + " " + modeStyle.Render(modeText)
|
||||
|
||||
if tier == tierTiny {
|
||||
if m.exitConfirmActive {
|
||||
return fitStyledLine(prefix+btwChip+zeroTheme.amber.Render("●")+" "+zeroTheme.amber.Render(ctrlCExitConfirmText), width)
|
||||
return fitStyledLine(prefix+zeroTheme.amber.Render("●")+" "+zeroTheme.amber.Render(ctrlCExitConfirmText), width)
|
||||
}
|
||||
if m.cancelConfirmActive {
|
||||
return fitStyledLine(prefix+btwChip+zeroTheme.amber.Render("●")+" "+zeroTheme.amber.Render(escCancelConfirmText), width)
|
||||
return fitStyledLine(prefix+zeroTheme.amber.Render("●")+" "+zeroTheme.amber.Render(escCancelConfirmText), width)
|
||||
}
|
||||
if dictation := m.dictationStatusChip(); dictation != "" {
|
||||
return fitStyledLine(prefix+btwChip+dictation, width)
|
||||
return fitStyledLine(prefix+dictation, width)
|
||||
}
|
||||
return fitStyledLine(left, width)
|
||||
}
|
||||
@@ -219,16 +215,16 @@ func (m model) statusLine(width int) string {
|
||||
left += zeroTheme.muted.Render(" · ") + zeroTheme.accent.Render(string(m.reasoningEffort))
|
||||
}
|
||||
if m.exitConfirmActive {
|
||||
left = prefix + btwChip + zeroTheme.amber.Render("●") + " " + zeroTheme.amber.Render(ctrlCExitConfirmText)
|
||||
left = prefix + zeroTheme.amber.Render("●") + " " + zeroTheme.amber.Render(ctrlCExitConfirmText)
|
||||
} else if m.cancelConfirmActive {
|
||||
left = prefix + btwChip + zeroTheme.amber.Render("●") + " " + zeroTheme.amber.Render(escCancelConfirmText)
|
||||
left = prefix + zeroTheme.amber.Render("●") + " " + zeroTheme.amber.Render(escCancelConfirmText)
|
||||
} else if m.dictation.downloading && m.dictation.downloadStatus != "" {
|
||||
// A model download in progress takes over the left chip with a live percentage.
|
||||
left = prefix + btwChip + zeroTheme.accent.Render("⬇ ") + zeroTheme.muted.Render(m.dictation.downloadStatus)
|
||||
left = prefix + zeroTheme.accent.Render("⬇ ") + zeroTheme.muted.Render(m.dictation.downloadStatus)
|
||||
} else if dictation := m.dictationStatusChip(); dictation != "" && m.dictation.active() {
|
||||
// An active recording/transcription takes over the left chip — it is the
|
||||
// most time-sensitive thing on screen (the mic is live).
|
||||
left = prefix + btwChip + dictation
|
||||
left = prefix + dictation
|
||||
} else {
|
||||
if voice := m.voiceModeIndicator(); voice != "" {
|
||||
left += zeroTheme.muted.Render(" · ") + voice
|
||||
|
||||
Reference in new issue
Block a user