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
Let --state shared include stale shares
Claude470ef388f4ba
diff --git a/cli/beacon/cmd/endpoint.go b/cli/beacon/cmd/endpoint.goindex 47119756..b21fd120 100644--- a/cli/beacon/cmd/endpoint.go+++ b/cli/beacon/cmd/endpoint.go@@ -481,7 +481,7 @@ func init() {endpointTracesResetCmd.Flags().BoolVar(&endpointTraceHistoryOpts.yes, "yes", false, "Delete without asking")endpointTracesListCmd.Flags().StringVarP(&endpointTraceOpts.query, "query", "q", "", "Filter traces by text")endpointTracesListCmd.Flags().IntVar(&endpointTraceOpts.page, "page", 1, "Page number for trace listing")- endpointTracesListCmd.Flags().StringVar(&endpointTraceOpts.state, "state", "", "Filter by sharing state")+ endpointTracesListCmd.Flags().StringVar(&endpointTraceOpts.state, "state", "", "Filter by sharing state: local_only, shared (including stale) or stale")endpointTracesListCmd.Flags().StringVar(&endpointTraceOpts.visibility, "visibility", "", "Filter by sharing visibility")endpointTracesSearchCmd.Flags().StringVar(&endpointTraceOpts.resultLevel, "result-level", "trace", "Return trace or event results")endpointTracesShowCmd.Flags().IntVar(&endpointTraceOpts.offset, "offset", 1, "Start at this event number")diff --git a/cli/beacon/internal/endpoint/dashboard/history_query.go b/cli/beacon/internal/endpoint/dashboard/history_query.goindex 21a85206..1b9e13c7 100644--- a/cli/beacon/internal/endpoint/dashboard/history_query.go+++ b/cli/beacon/internal/endpoint/dashboard/history_query.go@@ -140,7 +140,11 @@ func (m textMatch) condition(alias, fts string) (string, []any) {func sharingCondition(alias string, query TraceQuery) (string, []any) {var parts []stringvar args []any- if query.State != "" {+ switch {+ case strings.EqualFold(query.State, "shared"):+ // As sharingStateMatches: shared includes stale.+ parts = append(parts, "("+alias+".state = 'shared' COLLATE NOCASE OR "+alias+".state = 'stale' COLLATE NOCASE)")+ case query.State != "":parts = append(parts, alias+".state = ? COLLATE NOCASE")args = append(args, query.State)}diff --git a/cli/beacon/internal/endpoint/dashboard/sharing_view_test.go b/cli/beacon/internal/endpoint/dashboard/sharing_view_test.goindex f0add59a..480f04d4 100644--- a/cli/beacon/internal/endpoint/dashboard/sharing_view_test.go+++ b/cli/beacon/internal/endpoint/dashboard/sharing_view_test.go@@ -292,3 +292,42 @@ func TestSharingStateAcrossARotatedLog(t *testing.T) {t.Fatal("trace list missed rot1")}}++// "stale" is a kind of "shared": --state shared lists a shared session with newer activity, and+// --state stale narrows to it, on the JSONL scan and on the history alike.+func TestStateSharedIncludesStale(t *testing.T) {+ path := newTestLog(t, parityFixture())+ ids := func(state string) map[string]bool {+ t.Helper()+ list, err := ReadTraceList(path, TraceQuery{State: state, Limit: 50})+ if err != nil {+ t.Fatal(err)+ }+ got := map[string]bool{}+ for _, trace := range list.Traces {+ got[trace.ID] = true+ }+ return got+ }+ check := func(name string) {+ t.Helper()+ shared, stale, upper := ids("shared"), ids("stale"), ids("SHARED")+ if !shared["session:claude_code:s7"] || !shared["session:claude_code:s8"] {+ t.Fatalf("%s: --state shared = %v, want the stale s7 and the current s8", name, shared)+ }+ if !stale["session:claude_code:s7"] || stale["session:claude_code:s8"] {+ t.Fatalf("%s: --state stale = %v, want only s7", name, stale)+ }+ if len(upper) != len(shared) {+ t.Fatalf("%s: --state SHARED = %v, want the same as shared", name, upper)+ }+ if local := ids("local_only"); local["session:claude_code:s7"] || local["session:claude_code:s8"] {+ t.Fatalf("%s: --state local_only = %v", name, local)+ }+ }+ withoutHistory(t)+ check("jsonl")+ withHistory(t)+ optIn(t, path)+ check("history")+}diff --git a/cli/beacon/internal/endpoint/dashboard/traces.go b/cli/beacon/internal/endpoint/dashboard/traces.goindex 41ad03a3..ecdeb818 100644--- a/cli/beacon/internal/endpoint/dashboard/traces.go+++ b/cli/beacon/internal/endpoint/dashboard/traces.go@@ -875,10 +875,20 @@ func updateContentSummary(summary *TraceContentSummaryV1, info *schema.ContentIn}}+// sharingStateMatches is the --state filter. "stale" is a kind of "shared" (published, with newer+// local activity), so asking for shared sessions includes stale ones and "stale" narrows to them.+// The history query (sharingCondition) applies the same rule.+func sharingStateMatches(state, want string) bool {+ if strings.EqualFold(want, "shared") {+ return strings.EqualFold(state, "shared") || strings.EqualFold(state, "stale")+ }+ return strings.EqualFold(state, want)+}+func filterTraceSummaries(traces map[string]*traceAggregate, query TraceQuery) []TraceSummaryV1 {out := make([]TraceSummaryV1, 0, len(traces))for _, agg := range traces {- if query.State != "" && !strings.EqualFold(agg.summary.Sharing.State, query.State) {+ if query.State != "" && !sharingStateMatches(agg.summary.Sharing.State, query.State) {continue}if query.Visibility != "" && !strings.EqualFold(agg.summary.Sharing.Visibility, query.Visibility) {diff --git a/docs/cli/endpoint-traces.mdx b/docs/cli/endpoint-traces.mdxindex 489f140f..77d7cf38 100644--- a/docs/cli/endpoint-traces.mdx+++ b/docs/cli/endpoint-traces.mdx@@ -86,7 +86,7 @@ All commands accept:|------|-------------|| `--query <text>`, `-q <text>` | Filter traces by text || `--page <n>` | Page number for trace listing. Defaults to `1` |-| `--state <state>` | Filter by sharing state: `local_only`, `shared` for sessions published with [`beacon share`](/cli/share), or `stale` for shared sessions with newer local activity |+| `--state <state>` | Filter by sharing state: `local_only`, `shared` for sessions published with [`beacon share`](/cli/share) (including stale ones), or `stale` for only the shared sessions with newer local activity || `--visibility <visibility>` | Filter by sharing visibility: `private` for local-only traces, or the `public`, `direct` or `private` a shared trace was given |`search` also accepts:diff --git a/docs/cli/share.mdx b/docs/cli/share.mdxindex 421b66c9..06f02944 100644--- a/docs/cli/share.mdx+++ b/docs/cli/share.mdx@@ -255,7 +255,7 @@ agent:## Local record-After an upload, `beacon share` writes one `session.shared` event to the runtime log, in the session's own timeline. It carries the link, the visibility and when the session was shared (and refreshed), so [`beacon endpoint traces list --state shared`](/cli/endpoint-traces) and the local dashboard show the session as shared. The event is marked `event.fidelity=inferred` and has no collection method, because no runtime reported it. It is not itself uploaded with the trace.+After an upload, `beacon share` writes one `session.shared` event to the runtime log, in the session's own timeline. It carries the link, the visibility and when the session was shared (and refreshed), so [`beacon endpoint traces list --state shared`](/cli/endpoint-traces) and the local dashboard show the session as shared. A shared session with newer local activity shows as stale; `--state shared` still lists it, and `--state stale` lists only those. The event is marked `event.fidelity=inferred` and has no collection method, because no runtime reported it. It is not itself uploaded with the trace.## Output