Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
fix(computer): continue an early-started Antigravity Run in a new session
jeffrey7fe2d733b8d3
diff --git a/apps/computer/local-daemon/README.md b/apps/computer/local-daemon/README.mdindex ce09fa00..fb9bf148 100644--- a/apps/computer/local-daemon/README.md+++ b/apps/computer/local-daemon/README.md@@ -280,11 +280,14 @@ for a browser sign-in when signed out.stored is not a usable session: `session/load` accepts it, but the promptthen fails, so Linger never assigns one. A stored session replays at leastthe prompt that made it, so a load that replays no prompt, or that- Antigravity refuses, ends as `session_not_found` before the prompt is sent.- A resumed Run reports its turn-started event before `session/load`,- because loading takes seconds and the Room shows the Agent working from- that event. A Run yields to the scheduler only after native work, because- its session holds no prompt before that.+ Antigravity refuses, finds no session. A resumed Run reports its+ turn-started event before `session/load`, because loading takes seconds+ and the Room shows the Agent working from that event. The executor can then+ no longer start a fresh session, so the adapter opens `session/new` in the+ same process and the terminal result carries the new session. A Run that+ resumes after a yield ends as `session_not_found` instead. A Run yields to+ the scheduler only after native work, because its session holds no prompt+ before that.- A tool call is named by Antigravity's own tool name, such as`run_command`; its title is the whole command line, which the call'sredacted input already shows.@@ -294,7 +297,8 @@ for a browser sign-in when signed out.Context has one, with `execute` calls reviewed as shell commands from`rawInput.CommandLine`. A completed `run_command` whose `rawOutput.exit_code`is not zero finishes as failed. Otherwise- the adapter selects the allow option, as Pi runs without review.+ the adapter selects the allow option, as the Runtime runs with the Agent's+ full local authority.- Antigravity reports a model error, such as a rejected API key, as reply textand ends the turn with `end_turn`. With no structured signal, such a Runcompletes and the Room shows the text.diff --git a/apps/computer/local-daemon/internal/provider/executor.go b/apps/computer/local-daemon/internal/provider/executor.goindex af3dded5..b97d6b3d 100644--- a/apps/computer/local-daemon/internal/provider/executor.go+++ b/apps/computer/local-daemon/internal/provider/executor.go@@ -566,6 +566,7 @@ func (e Executor) Start(ctx context.Context, spec OperationSpec, emit EmitFunc)AssignSessionID: spec.CreateProviderSessionID,ResumeID: spec.ResumeSessionID,ResumeRequired: spec.ResumeSessionID != "",+ FreshSessionOnRefusal: !spec.ResumeAfterYield,Budget: spec.Timeout,ComputerArgs: append([]string(nil), spec.ExtraArgs...),AgentArgs: append([]string(nil), spec.CustomArgs...),diff --git a/apps/computer/local-daemon/internal/provider/native/antigravity_runtime.go b/apps/computer/local-daemon/internal/provider/native/antigravity_runtime.goindex 16e20864..955868a3 100644--- a/apps/computer/local-daemon/internal/provider/native/antigravity_runtime.go+++ b/apps/computer/local-daemon/internal/provider/native/antigravity_runtime.go@@ -165,7 +165,9 @@ func (t *antigravityTurn) exchange(prompt string, servers []any) Outcome {}// A resumed session is known before agy loads it, which takes seconds,// so the Run starts now; a new session reports its id once agy names it.- if spec.ResumeID != "" {+ resumed := spec.ResumeID != ""+ startedEarly := resumed && spec.ExposeTurnStarted+ if startedEarly {t.started(spec.ResumeID, started)}if err := acpInitialize(t.runCtx, conn); err != nil {@@ -179,34 +181,60 @@ func (t *antigravityTurn) exchange(prompt string, servers []any) Outcome {// one and replays it as updates, which the turn drops until its own// prompt is sent.method := "session/new"- if spec.ResumeID != "" {+ if resumed {method, params["sessionId"] = "session/load", spec.ResumeID}- raw, err := acpOpenSession(t.runCtx, conn, t.profile.Env, func() (json.RawMessage, error) {- return conn.call(t.runCtx, method, params)- })+ open := func() (json.RawMessage, error) {+ return acpOpenSession(t.runCtx, conn, t.profile.Env, func() (json.RawMessage, error) {+ return conn.call(t.runCtx, method, params)+ })+ }+ raw, err := open()if acpNeedsAuth(err) {return failed("authentication_required", "Antigravity sign-in is required")}+ refusal := ""var refused *acpError- if spec.ResumeID != "" && errors.As(err, &refused) {- return t.resumeRefused(failed("session_not_found", "Antigravity could not load session "+spec.ResumeID+": "+err.Error()))- }- if err != nil {+ switch {+ case resumed && errors.As(err, &refused):+ refusal = "Antigravity could not load session " + spec.ResumeID + ": " + err.Error()+ case err != nil:return failed("", "Antigravity "+method+" failed: "+err.Error())+ case resumed:+ t.mu.Lock()+ replayed := t.replayedPrompts+ t.mu.Unlock()+ // session/load accepts an id Antigravity never stored and only the+ // prompt fails. A stored session holds at least the prompt of the+ // turn that made it, so a load that replays no prompt found no+ // session.+ if replayed == 0 {+ refusal = "Antigravity has no stored session " + spec.ResumeID+ }}- t.mu.Lock()- replayed := t.replayedPrompts- t.mu.Unlock()- // session/load accepts an id Antigravity never stored and only the- // prompt fails. A stored session holds at least the prompt of the turn- // that made it, so a load that replays no prompt found no session.- if spec.ResumeID != "" && replayed == 0 {- return t.resumeRefused(failed("session_not_found", "Antigravity has no stored session "+spec.ResumeID))+ if refusal != "" {+ // The Run already started on the retained session, so the executor+ // can no longer continue it in a new one; this process does, and the+ // terminal result carries the new session.+ if !startedEarly || !spec.FreshSessionOnRefusal {+ return t.resumeRefused(failed("session_not_found", refusal))+ }+ if t.profile.Logger != nil {+ t.profile.Logger.Warn("runtime.session.fresh_start", "provider", "antigravity", "reason", "session_not_found")+ }+ resumed, method = false, "session/new"+ delete(params, "sessionId")+ raw, err = open()+ if acpNeedsAuth(err) {+ return failed("authentication_required", "Antigravity sign-in is required")+ }+ if err != nil {+ return failed("", "Antigravity "+method+" failed: "+err.Error())+ }}var session acpSessionif json.Unmarshal(raw, &session) != nil || session.SessionID == "" {- if spec.ResumeID == "" {+ if !resumed {return failed("", "Antigravity "+method+" returned no session")}session.SessionID = spec.ResumeID@@ -229,7 +257,7 @@ func (t *antigravityTurn) exchange(prompt string, servers []any) Outcome {t.mu.Unlock()dispatched := time.Now()t.requests.begin("", dispatched)- if spec.ResumeID == "" {+ if !startedEarly {t.started(session.SessionID, dispatched)}raw, err = conn.call(t.runCtx, "session/prompt", map[string]any{diff --git a/apps/computer/local-daemon/internal/provider/native/antigravity_runtime_test.go b/apps/computer/local-daemon/internal/provider/native/antigravity_runtime_test.goindex 10129cbb..f918fa46 100644--- a/apps/computer/local-daemon/internal/provider/native/antigravity_runtime_test.go+++ b/apps/computer/local-daemon/internal/provider/native/antigravity_runtime_test.go@@ -401,3 +401,27 @@ func TestAntigravityStartsAResumedRunBeforeTheSessionLoads(t *testing.T) {cancel()drainAgy(t, run)}++func TestAntigravityContinuesAnEarlyStartedRunInANewSession(t *testing.T) {+ h := newAgyHarness(t, "unknown-session", nil)+ run, err := h.runtime.Start(t.Context(), "again", RunSpec{Dir: h.dir, ResumeID: "moved-session", ExposeTurnStarted: true, FreshSessionOnRefusal: true})+ if err != nil {+ t.Fatal(err)+ }+ events, outcome := drainAgy(t, run)+ if outcome.Status != statusCompleted || outcome.SessionID != "fake-session" {+ t.Fatalf("outcome=%+v", outcome)+ }+ var starts []Event+ for _, event := range events {+ if event.Kind == EventStatus && event.TurnID != "" {+ starts = append(starts, event)+ }+ }+ if len(starts) != 1 || starts[0].SessionID != "moved-session" {+ t.Fatalf("turn-started events=%+v", starts)+ }+ if requests := h.requests(t); len(requests["session/new"]) != 1 || len(requests["session/prompt"]) != 1 {+ t.Fatalf("requests=%v", requests)+ }+}diff --git a/apps/computer/local-daemon/internal/provider/native/runtime.go b/apps/computer/local-daemon/internal/provider/native/runtime.goindex 71e5ecfc..0fd05151 100644--- a/apps/computer/local-daemon/internal/provider/native/runtime.go+++ b/apps/computer/local-daemon/internal/provider/native/runtime.go@@ -87,12 +87,16 @@ type Profile struct {}type RunSpec struct {- Dir string- Model string- Budget time.Duration- ResumeID string- AssignSessionID string- ResumeRequired bool+ Dir string+ Model string+ Budget time.Duration+ ResumeID string+ AssignSessionID string+ ResumeRequired bool+ // FreshSessionOnRefusal lets a Runtime that reported its turn started+ // before its retained session loaded continue in a new session when the+ // session is gone, as the executor does for one that reported nothing.+ FreshSessionOnRefusal boolPrepareOnly boolWarmMCP boolMCPReady func(context.Context) errordiff --git a/apps/web/src/features/rooms/room-shell.test.tsx b/apps/web/src/features/rooms/room-shell.test.tsxindex 089295bc..24661f04 100644--- a/apps/web/src/features/rooms/room-shell.test.tsx+++ b/apps/web/src/features/rooms/room-shell.test.tsx@@ -714,7 +714,11 @@ describe("Room shell Tenant transition", () => {await renderAccountShell({initialEntry: "/t/tenant-northstar/rooms/room-all/chat",});- expect(markSpy).toHaveBeenCalledWith("room.shell_visible");+ // The mark is a passive effect, which may run after the shell's DOM is+ // found on a loaded runner.+ await waitFor(() =>+ expect(markSpy).toHaveBeenCalledWith("room.shell_visible"),+ );});});