background-agents icon indicating copy to clipboard operation
background-agents copied to clipboard

Session filters by user

Open Bnowako opened this issue 7 months ago • 5 comments

Problem: When multiple people colaborate on open-inspect it's easy to loose your sessions.

Solution: Allow to filter sessions by user.

By default show current user sessions, and allow to toggle 'all' / filter by user.

Bnowako avatar Apr 24 '26 17:04 Bnowako

@ColeMurray I think it would be nicer if we would show in my sessions, all sessions the user participated in, but this info is in DO. Wdyt about adding a table which would be an index of user-session that we can easily retrieve there?

If you sent 1 message to a session it will be shown as "My sessions"

Bnowako avatar Apr 29 '26 16:04 Bnowako

hey @ColeMurray, @Bnowako. I am interested in working on this, I did notice that both prior PRs (#599, #600) went creator only and closed silently. want to confirm the design before opening another one. @Bnowako's proposal on this issue is participation based and I think that's the right call.

Proposed design

  1. New D1 table session_participants(user_id, session_id, scm_login, first_seen_at). Composite PK (user_id, session_id), index on (user_id, first_seen_at DESC). Backfilled from existing sessions rows where user_id IS NOT NULL.

  2. "Participation" means any of: created the session, explicitly added via POST /participants, or sent ≥1 prompt (WS or API). The prompt case is the load bearing one per @Bnowako's wording. Writes are idempotent (INSERT OR IGNORE) from initialize.ts and the prompt enqueue paths in message-queue.ts. All keyed on canonical users.id, resolved via UserStore.getIdentity for both bot provider:id prefixes and raw web ids. Read only, never auto creates.

  3. API: GET /sessions?mineScmUserId=<id>&mineProvider=<github|slack|linear> plus optional ?scmLogin= fallback for pre migration rows where sessions.user_id IS NULL. Control plane resolves (provider, providerUserId) to canonical users.id and JOINs session_participants. Unresolved identity returns an empty page. 400s on empty values or asymmetric params.

  4. BFF identity flow (the bit #600 got wrong):

    sign-in:  session.user.id = <github numeric>
    create:   resolveOrCreateUser(github, <num>) = <canonical UUID>
              → session_participants(user_id=<UUID>, session_id=X)
    list:     BFF /api/sessions?mine=true injects mineScmUserId=<num>&mineProvider=github
              → getIdentity(github, <num>) = <same UUID>
              → JOIN matches
    

    BFF strips client supplied identity claims before forwarding. Fails closed (empty page, no upstream call) when session.user?.id is missing. Fresh session with zero prompts still shows up in "Mine" because the create time write already landed.

  5. Cross user safety on the scmLogin fallback: legacy branch is gated on sessions.user_id IS NULL, so a session owned by user A with a typo'd scm_login of user B never leaks.

Want to confirm a couple of things

  • @Bnowako, does "sent ≥1 prompt → My sessions" match what you meant, or did you mean only the explicit add path?
  • @ColeMurray, OK with empty page for unresolved identities vs. 404? Felt right since "no sessions for this user" and "user not registered" are both legitimately empty, but want to confirm.
  • Worth keeping the scmLogin fallback at all? Only matters for sessions created before this migration. Happy to drop it if you'd rather not carry that complexity.

Krishnachaitanyakc avatar May 29 '26 05:05 Krishnachaitanyakc

@Krishnachaitanyakc I shipped the "sessions started by me" in https://github.com/ColeMurray/background-agents/pull/688.

Sessions I am a part of is a bit more involved as it requires moving some of the properties currently only stored in the DO into D1.

ColeMurray avatar May 30 '26 22:05 ColeMurray

@ColeMurray can I help with "Sessions I am a part of"? Happy to pick up any other issues as well.

Krishnachaitanyakc avatar May 30 '26 22:05 Krishnachaitanyakc

Handled by koala73/butler PR #70: https://github.com/koala73/butler/pull/70 (merged 2026-06-17). This upstream issue can be closed now that the Butler fork fix has landed.

koala73 avatar Jun 17 '26 05:06 koala73