Skip to content

[AGE-4112] feat(frontend): Deep-link and share agent sessions - #6252

Open
ardaerzin wants to merge 4 commits into
mainfrom
fe-feat/session-deep-links
Open

[AGE-4112] feat(frontend): Deep-link and share agent sessions#6252
ardaerzin wants to merge 4 commits into
mainfrom
fe-feat/session-deep-links

Conversation

@ardaerzin

Copy link
Copy Markdown
Contributor

Closes #5990.

Context

Opening an agent session left the URL at /apps/<appId>/playground. The session you were looking at was held in client state only, so nothing in the address bar named it. You could not send a teammate a link to a session, and a reload came back on whichever session the last visit left open instead of the one you had open.

Mobile was better off, since a session already has a page of its own at /w/<ws>/p/<proj>/sessions/<sessionId>. Getting that link still meant selecting the address bar by hand.

Changes

The playground URL names the open session. useOpenAgentSession now navigates to /apps/<appId>/playground?session_id=<id>, AgentChatPanel adopts the linked session on arrival, and the param follows the tab you switch to.

The param is session_id rather than the more obvious session, because ?session= is already taken. oss/src/state/url/session.ts owns it for the observability session drawer and runs on every route change, stripping it from any route that is not /observability or /sessions. The playground is one of those routes, so a ?session= link there would be deleted from the URL before it could be read. Adding /playground to that matcher is not the fix either: it would open the trace drawer on top of the playground.

Both link shapes live in one new package subpath, @agenta/sessions/link, so no surface hand-rolls the string:

desktop  /w/<ws>/p/<proj>/apps/<appId>/playground?session_id=<id>   (session as a tab)
mobile   /w/<ws>/p/<proj>/sessions/<id>                             (session as a page)

"Copy share link" in the session menu. Added to the shared verb set in @agenta/sessions-ui, gated on a host-supplied link builder. Both apps supply one, so the entry shows up everywhere the menu already does: the sessions list, the sidebar rows, the open conversation's kebab, Home, the agent overview and the sessions pane. A host whose sessions have no URL passes nothing and the entry never appears.

One difference between the apps. Mobile can link any session, because the route is project-scoped. The desktop can only link at an agent's playground, so a session with no resolved agent (one with no turns yet) has nothing to link at and the entry disables itself.

Sidebar session rows are real links now. They pointed at /apps/<appId>/playground, with a comment explaining that the playground had no way to read the session from the route. They now carry the session, so middle-click and "copy link address" work. Highlighting still matches on the bare playground path, which required wiring childMatchPaths. It was declared in SidebarEntityConfig but never mapped through defineSidebarEntity.

Tests

  • tsc --noEmit clean on oss, ee, mobile, @agenta/sessions, @agenta/sessions-ui, @agenta/navigation.
  • eslint clean on every touched file.
  • 13 new unit tests for the link helpers, plus the existing 326 AgentChatSlice and sessions tests.
  • Not yet exercised in a browser. The QA steps below are the ones that matter.

What to QA

  • Open a session from the sessions list. The URL gains ?session_id=<id>. Reload. You land back on that session, not on the agent's default one.
  • Paste that URL into a fresh tab, or a browser that has never opened this agent. The session opens and its transcript hydrates from records.
  • Switch between session tabs in the playground. The session_id in the address bar follows the active tab.
  • Kebab on a session row, then "Copy share link". Paste it. It opens that session.
  • Same check on the open conversation's kebab, and on a sidebar session row.
  • On mobile, use the same menu from the sessions list and from the open session's tab. The link points at /sessions/<id>.
  • Regression: open a trace from /observability. The session drawer still opens off ?session= and closing it still clears the param.
  • Regression: land on the playground with no session_id at all. You get one blank tab, not two, and no stray empty session in history.

An agent session had no address of its own: the playground read the target
from client state, so the URL stayed /apps/<appId>/playground for every
session. A link could not name one, and a reload came back on whichever
session the last visit left open.

Encode it as ?session_id=, owned by @agenta/sessions/link so every surface
that builds or reads the link agrees on it. Not ?session=, which the
observability drawer already owns app-wide and strips off the playground.

The panel adopts the linked session on arrival and keeps the param pointed
at the tab in front of you, and the sidebar's session rows now link to the
session rather than to its agent.
Reaching for the address bar is the only way to hand someone a session.
Add the verb to the shared session menu, so the sessions list, the sidebar
rows and the open conversation's kebab all offer it from one definition.

The link builder is the host's: an app whose sessions have no URL (mobile
opens them by route) passes none and the entry never appears.
Mobile already gives a session a page of its own, so the link existed — it
just took selecting the address bar to get at it. Bind the shared verb here
too, and the same menu on the sessions list, Home, the agent overview, the
sessions pane and the open session's tab all offer it.

Both link shapes now live in @agenta/sessions/link: the desktop opens a
session as a tab on its agent's playground, this app routes to it.
@linear-code

linear-code Bot commented Aug 24, 2026

Copy link
Copy Markdown

AGE-4112

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Aug 24, 2026
@vercel

vercel Bot commented Aug 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agenta-documentation Error Error Aug 25, 2026 8:38am

Request Review

@dosubot dosubot Bot added enhancement New feature or request frontend labels Aug 24, 2026
@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 31ab2598-9a7a-4ebd-b6d4-f151da335b36

📥 Commits

Reviewing files that changed from the base of the PR and between c1cbf58 and a681ce6.

📒 Files selected for processing (7)
  • web/mobile/src/features/sessions/useSessionRowMenu.ts
  • web/oss/src/components/AgentChatSlice/hooks/useOpenAgentSession.ts
  • web/oss/src/components/AgentChatSlice/hooks/useSessionActions.tsx
  • web/packages/agenta-sessions-ui/src/useSessionActions.tsx
  • web/packages/agenta-sessions/src/link/index.ts
  • web/packages/agenta-sessions/src/link/sessionDeepLink.ts
  • web/packages/agenta-sessions/tests/unit/sessionDeepLink.test.ts
💤 Files with no reviewable changes (1)
  • web/packages/agenta-sessions/src/link/index.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added deep links for opening specific sessions directly in the playground or standalone session page.
    • Added support for loading and preserving linked sessions through the session_id URL parameter.
    • Added a “Copy share link” action for sessions, with unavailable links disabled when sharing is unsupported.
    • Updated navigation to highlight the relevant agent while retaining the selected session.
  • Tests

    • Added coverage for session link generation, query handling, route matching, and URL preservation.

Walkthrough

Session deep links now identify sessions in playground URLs. The application adopts linked sessions on load, keeps the active session in the URL, and adds conditional “Copy share link” actions to desktop and mobile session menus.

Changes

Session deep-linking and sharing

Layer / File(s) Summary
Session link helpers and public exports
web/packages/agenta-sessions/src/link/*, web/packages/agenta-sessions/tests/unit/sessionDeepLink.test.ts, web/packages/agenta-sessions/package.json
Added helpers to build, read, update, and share session URLs. Added scoped playground matching and unit tests. Exported the link module publicly.
Session navigation and URL adoption
web/packages/agenta-navigation/src/dynamic/registry.ts, web/oss/src/components/AgentChatSlice/hooks/useOpenAgentSession.ts, web/oss/src/components/AgentChatSlice/AgentChatPanel.tsx
Session navigation now includes the session identifier. AgentChatPanel adopts linked sessions, delays default-session creation while links are pending, and synchronizes the active session with the URL.
Copy-link actions across session menus
web/packages/agenta-sessions-ui/src/useSessionActions.tsx, web/oss/src/components/AgentChatSlice/hooks/useSessionActions.tsx, web/oss/src/components/pages/sessions/SessionsPage.tsx, web/mobile/src/features/sessions/useSessionRowMenu.ts
Added conditional “Copy share link” menu handling. Desktop and mobile callers now generate session-specific links and invoke clipboard actions.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to a681c

The PR adds session-specific URLs and share-link behavior across desktop and mobile. No actionable merge-blocking risk remains, so it is merge-ready after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant Browser
  participant AgentChatPanel
  participant pendingSessionOpenAtom
  participant history.replaceState
  Browser->>AgentChatPanel: Open URL with session_id
  AgentChatPanel->>pendingSessionOpenAtom: Adopt linked session
  AgentChatPanel->>history.replaceState: Write active session_id
  history.replaceState-->>Browser: Update address bar
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the frontend changes for deep-linking and sharing agent sessions.
Description check ✅ Passed The description directly explains the deep-linking behavior, share-link action, affected applications, tests, and QA scope.
Linked Issues check ✅ Passed The changes satisfy issue #5990 by encoding session IDs in URLs, restoring linked sessions after navigation or refresh, and adding conditional "Copy share link" actions to session menus.
Out of Scope Changes check ✅ Passed The changes remain focused on session deep links, share-link generation, session menu actions, sidebar session links, and supporting tests. No unrelated code changes are evident.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 60.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 7 files.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fe-feat/session-deep-links

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
web/packages/agenta-sessions/tests/unit/sessionDeepLink.test.ts (1)

3-10: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Test the public subpath export.

Line 10 imports internal source files. This bypasses the new @agenta/sessions/link export and does not validate the consumer import path.

Proposed change
 } from "../../src/link/sessionDeepLink"
+} from "`@agenta/sessions/link`"

As per coding guidelines, workspace packages must “use exported subpath imports for tree-shaking”.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: f0686e75-a68c-4a66-951d-ba9fc77d0d5a

📥 Commits

Reviewing files that changed from the base of the PR and between 753af38 and c1cbf58.

📒 Files selected for processing (11)
  • web/mobile/src/features/sessions/useSessionRowMenu.ts
  • web/oss/src/components/AgentChatSlice/AgentChatPanel.tsx
  • web/oss/src/components/AgentChatSlice/hooks/useOpenAgentSession.ts
  • web/oss/src/components/AgentChatSlice/hooks/useSessionActions.tsx
  • web/oss/src/components/pages/sessions/SessionsPage.tsx
  • web/packages/agenta-navigation/src/dynamic/registry.ts
  • web/packages/agenta-sessions-ui/src/useSessionActions.tsx
  • web/packages/agenta-sessions/package.json
  • web/packages/agenta-sessions/src/link/index.ts
  • web/packages/agenta-sessions/src/link/sessionDeepLink.ts
  • web/packages/agenta-sessions/tests/unit/sessionDeepLink.test.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Railway Preview Environment

Preview URL https://gateway-pr-6252.up.railway.app/w
Project agenta-oss-clone-spike
Image tag pr-6252-eb65a6f
Status Deployed
Railway logs Open logs
Workflow logs View workflow run
Updated at 2026-08-25T08:49:51.497Z

…graph

Two problems in the share-link wiring, both from building an absolute URL
where a path would do.

useSessionActions runs once per SIDEBAR ROW, so subscribing it to urlAtom
re-rendered the whole session list on every route change (urlAtom recomputes
from the app-state snapshot and returns a fresh object each time). Read it
through the store instead, the way the hook already reads its local cache.

The menu asks on every render whether a session can be linked, and that
answer reached for window.location.origin. Hosts now supply sharePathFor,
a pure path, and the hook absolutizes it on the copy itself. shareUrl is
the one place that touches window.

Both path builders now return "" when they have no base or no target, so a
caller that asks before the project resolves gets nothing instead of a path
missing its middle, and the menu entry disables itself.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request frontend size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(feat) Make agent sessions deep-linkable and add a "Copy share link" action

1 participant