The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
Give up following a session that has nothing to share any more
Claudead74cd67ddfd
diff --git a/cli/beacon/cmd/share_follow.go b/cli/beacon/cmd/share_follow.goindex 41c74900..097e2840 100644--- a/cli/beacon/cmd/share_follow.go+++ b/cli/beacon/cmd/share_follow.go@@ -103,7 +103,10 @@ func runShareFollow(cmd *cobra.Command, client *account.ShareClient, subject sha}fingerprint, end, err := shareFollowState(subject)ended = end- if readErr == nil && err != nil && !errors.Is(err, errShareNothingYet) {+ // Before the first upload a session with nothing to share yet is waited for; after it, a+ // session that has nothing to share any more (its store lost it, and the log holds only+ // this command's own session.shared records) is a read failure, not a reason to wait forever.+ if readErr == nil && err != nil && (uploads > 0 || !errors.Is(err, errShareNothingYet)) {readErr = err}if uploads > 0 {diff --git a/cli/beacon/cmd/share_follow_test.go b/cli/beacon/cmd/share_follow_test.goindex d5ac928f..a1df059f 100644--- a/cli/beacon/cmd/share_follow_test.go+++ b/cli/beacon/cmd/share_follow_test.go@@ -485,3 +485,45 @@ func TestShareFollowIgnoresAnOldEndOfAResumedSession(t *testing.T) {t.Fatalf("polls = %d, want 3 (the old end must not stop it)\n%s", polls, stderr)}}++// A store session that disappears after the first upload leaves only --follow's own session.shared+// records in the runtime log: nothing to share any more is a read failure, reported once, and+// --follow gives up rather than poll forever.+func TestShareFollowGivesUpWhenTheSessionDisappears(t *testing.T) {+ env := newShareEnv(t)+ src := &growingSource{+ session: handoff.Session{Harness: handoff.HarnessClaude, ID: shareTestSession, Directory: env.projectDir, UpdatedAt: time.Now()},+ events: shareFixtureEvents(env.projectDir),+ }+ stubHandoffSources(t, src)+ srv := newFakeShareServer(t)+ srv.signIn(account.ScopeTracesWrite)+ polls := 0+ prevWait := shareFollowWait+ shareFollowWait = func(ctx context.Context, d time.Duration) error {+ polls+++ if polls == 1 {+ src.mu.Lock()+ src.fail = handoff.ErrNotFound // the store lost the session+ src.mu.Unlock()+ }+ if polls > 20 {+ return errors.New("the loop did not give up")+ }+ return nil+ }+ t.Cleanup(func() { shareFollowWait = prevWait })+ _, stderr, err := runShareCommand(t, "--follow", "--cwd", env.projectDir, "--log-path", env.logPath)+ if err == nil || !strings.Contains(err.Error(), "could not be read") || !strings.Contains(err.Error(), "nothing to share") {+ t.Fatalf("follow err = %v\n%s", err, stderr)+ }+ if polls != shareFollowMaxReadFailures {+ t.Fatalf("waits = %d, want %d", polls, shareFollowMaxReadFailures)+ }+ if n := strings.Count(stderr, "warning: could not read the session"); n != 1 {+ t.Fatalf("warnings = %d, want one:\n%s", n, stderr)+ }+ if records := shareEventsIn(t, env.logPath); len(records) == 0 {+ t.Fatal("the first upload was not recorded")+ }+}