Skip to content

fix(core): preserve session recency on permission sync - #65009

Open
r266-tech wants to merge 1 commit into
anomalyco:devfrom
r266-tech:keep-session-recency
Open

r266-tech wants to merge 1 commit into
anomalyco:devfrom
r266-tech:keep-session-recency

Conversation

@r266-tech

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #63920

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Browser attach and detach persist permission changes. Stamping time_updated during that write moves idle sessions to the top of Recent. Explicitly keep the stored timestamp so Drizzle's $onUpdate leaves recency alone while the grant or revoke is saved.

How did you verify your code works?

The browser attach regression fails on unmodified dev and passes with the fix. It checks the grant and revoke, timestamps, list order, and message count. On macOS, 56 targeted tests passed, as did ten randomized runs of the browser attach file (30 tests), bun run check, and the core TypeScript check. Windows desktop validation is pending.

Screenshots / recordings

The regression asserts the session order returned by the core list.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

AI-assisted implementation and validation.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified the fix. I ran the reproduction script from #63920 against opencode serve from source. On the base branch, an idle session's time_updated moved forward on browser attach and again on detach, and the session list showed the detach time as its last update. With this PR, time_updated stays the same through both, and the browser permission rules are still granted and then revoked. The new test fails on the base branch and passes here. The related core tests pass, and tsc -b passes for packages/core.

Public API: no endpoint, schema or event changes. The only behaviour change is that a session.update({ permissions }) call no longer bumps the session's updated time. In this repo the browser plugin is the only caller that updates permissions, so this has no other in-repo effect. Keeping recency here matches how the other bookkeeping writes already work (Viewed, and claim/release in store.ts).

No blocking concerns.

@r266-tech
r266-tech force-pushed the keep-session-recency branch from 3d172e3 to 9a6e372 Compare November 30, 2026 02:17

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

session: idle sessions gain time_updated after a service restart and jump to the top of the list

1 participant