Skip to content

[feat] Add automation history to session rows - #5927

Merged
mmabrouk merged 4 commits into
release/v0.112.0from
frontend/session-ux
Aug 11, 2026
Merged

[feat] Add automation history to session rows#5927
mmabrouk merged 4 commits into
release/v0.112.0from
frontend/session-ux

Conversation

@mmabrouk

Copy link
Copy Markdown
Member

Context

Sessions started by schedules and subscriptions need to stay out of human-work lists by default, while automation mode must show which automation ran and let users inspect the exact delivery. The UI previously depended on reserved tags and had no exact-delivery row action.

Changes

Each session-list caller now declares its origin and expansion policy. Row models consume typed automation data, show schedule or subscription kind, and preserve the session as the primary click target. Secondary actions open the automation configuration or one exact delivery. Deleted configurations remain available in read-only historical drawers while normal lists and mutations stay live-only.

Exact delivery mode calls GET /triggers/deliveries/{delivery_id} once and does not mount the owner-wide delivery-list query.

Tests / notes

  • pnpm lint-fix passed.
  • Relevant package builds, type checks, and focused/full unit suites passed.
  • The EE deployment is healthy at http://144.76.237.122:8280.
  • Automated browser QA remains blocked by host Chromium sandbox support.

What to QA

  • Open Sessions in default mode. Automation sessions stay hidden.
  • Switch to automation mode. Only automation sessions appear with the correct kind and current name.
  • Click the row body. The session opens.
  • Use Open automation. The matching configuration drawer opens.
  • Use View delivery. Only the linked delivery loads and shows the linked session.
  • Rename, then delete an automation. Existing rows show the current name, and historical configuration and delivery details remain readable.
  • Regression: a user without trigger-view permission can still open the session.

Stack: 3 of 4. Base: clients/session-ux-contract.

@dosubot dosubot Bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Aug 11, 2026
@vercel

vercel Bot commented Aug 11, 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 11, 2026 11:27am

Request Review

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

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added session automation actions, labels, context-menu options, and drawers for schedules, subscriptions, and deliveries.
    • Added detailed delivery views with status, inputs, results, errors, timestamps, identifiers, and linked-session navigation.
    • Added support for viewing exact deliveries and owner delivery history.
    • Added clearer automation attribution and filtering across session lists, home, overview, and sidebar views.
  • Bug Fixes
    • Deleted schedules and subscriptions are now read-only.
    • Improved pagination and retention of sessions beyond the initial visible rows.

Walkthrough

This PR adds typed paginated session queries, centralized session-list policies, automation metadata in session rows, automation menus, and owner-history or exact-delivery drawer flows. Deleted schedules and subscriptions now render as read-only.

Changes

Session querying and automation delivery

Layer / File(s) Summary
Paginated session query contracts
web/packages/agenta-entities/src/session/...
Adds structured session page requests, typed response metadata, normalized filters, cursor windowing, and compatibility handling for legacy queries.
Session policies and automation row models
web/packages/agenta-sessions/src/state/..., web/packages/agenta-sessions/src/row/...
Adds reusable list policies and derives validated automation and delivery metadata for session rows.
Mobile and OSS session consumers
web/mobile/src/features/sessions/..., web/oss/src/components/AgentChatSlice/..., web/oss/src/components/Sidebar/dynamic/...
Migrates mobile, reconciliation, and sidebar queries to shared paginated options and policies.
Automation session rows and menus
web/packages/agenta-sessions-ui/..., web/oss/src/components/pages/sessions/..., web/oss/src/components/pages/agent-home/...
Adds automation labels, menu actions, drawer wiring, and policy-based session-list configuration.
Delivery queries and drawers
web/packages/agenta-entities/src/gatewayTrigger/..., web/packages/agenta-entity-ui/src/gatewayTrigger/..., web/packages/agenta-sdk/src/resources.ts
Adds project-scoped delivery fetching and mode-specific owner-history or exact-delivery drawer rendering.
Deleted trigger forms
web/packages/agenta-entity-ui/src/gatewayTrigger/drawers/schedule/..., web/packages/agenta-entity-ui/src/gatewayTrigger/drawers/subscription/...
Makes deleted schedules and subscriptions read-only and suppresses edit, save, enable, and run actions.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SessionListConsumer
  participant sessionListQueryOptions
  participant querySessionsPage
  participant SessionsClient
  SessionListConsumer->>sessionListQueryOptions: build policy and cursor options
  sessionListQueryOptions->>querySessionsPage: request structured session page
  querySessionsPage->>SessionsClient: send serialized query
  SessionsClient-->>querySessionsPage: return session page envelope
  querySessionsPage-->>SessionListConsumer: return sessions and pagination metadata
Loading
sequenceDiagram
  participant SessionRow
  participant SessionAutomationActions
  participant TriggerDeliveriesDrawer
  participant useTriggerDelivery
  participant TriggersClient
  SessionRow->>SessionAutomationActions: select automation or delivery action
  SessionAutomationActions->>TriggerDeliveriesDrawer: open schedule, subscription, or exact delivery
  TriggerDeliveriesDrawer->>useTriggerDelivery: request project-scoped delivery
  useTriggerDelivery->>TriggersClient: fetch delivery
  TriggersClient-->>TriggerDeliveriesDrawer: return delivery or error
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 29.41% which is insufficient. The required threshold is 60.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: adding automation history to session rows.
Description check ✅ Passed The description directly explains the automation history changes, UI behavior, exact delivery mode, testing, and QA scope.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch frontend/session-ux

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.

const openSchedule = useSetAtom(triggerScheduleDrawerAtom)
const openSubscription = useSetAtom(triggerSubscriptionDrawerAtom)
const openDelivery = useSetAtom(triggerDeliveriesDrawerAtom)
const canViewTriggers = hasPermission("view_triggers")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Review focus: view_triggers gates only the two automation-specific secondary actions. The session row click is wired separately and must remain available to users without trigger permission; the action and row tests cover that regression.

Signed: OpenCode

ownerHistory: ReactNode
exactDelivery: ReactNode
}) {
return state.mode === "exact-delivery" ? exactDelivery : ownerHistory

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Review focus: this branch keeps exact-delivery mode from mounting the owner-history subtree, so opening one delivery cannot trigger the paginated owner list request. The drawer-mode unit test pins this request boundary.

Signed: OpenCode

@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Railway Preview Environment

Status Destroyed (PR closed)

Updated at 2026-08-11T11:50:38.725Z

@mmabrouk

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🧹 Nitpick comments (7)
web/packages/agenta-entities/src/gatewayTrigger/state/atoms.ts (1)

85-87: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Shorten or remove this comment.

This comment describes normal feature behavior. It does not document a bug, race, or ordering constraint. Keep one short line if this context is required.

As per coding guidelines: “Keep in-code comments to at most one short line; use longer comments only for genuinely surprising constraints such as bugs, races, or ordering requirements.”

Source: Coding guidelines

web/packages/agenta-entities/src/session/api/api.ts (1)

262-265: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider a dedicated request type for windowing.

SessionWindowing is inferred from the response schema, where each field is .nullish(). Pick therefore admits null for limit, next, newest, oldest, and order in request parameters. Callers can pass null where the API expects an absent value. Define a request-side windowing type, or apply NonNullable per field.

♻️ Proposed refactor
-type SessionWindowingParams = Pick<
-    SessionWindowing,
-    "limit" | "next" | "newest" | "oldest" | "order"
->
+type SessionWindowingParams = {
+    [K in "limit" | "next" | "newest" | "oldest" | "order"]?: NonNullable<SessionWindowing[K]>
+}
web/packages/agenta-entities/src/session/state/listOptions.ts (1)

44-48: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

stableIds duplicates stableValues.

Both functions have the same body. stableIds is stableValues<string>.

♻️ Proposed refactor
 const stableValues = <T extends string>(values: T[] | undefined): T[] | undefined =>
     values ? [...new Set(values)].sort() : undefined
-
-const stableIds = (values: string[] | undefined): string[] | undefined =>
-    values ? [...new Set(values)].sort() : undefined

Then call stableValues(sessionIds) and stableValues(excludeSessionIds).

web/packages/agenta-entities/tests/unit/session-list-options.test.ts (1)

145-153: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a case for windowing: null.

nextSessionCursor treats windowing: null differently from an absent windowing: null stops pagination, while undefined falls back to row reconstruction. That branch decides whether a full page can be paged past. No test pins it.

💚 Proposed test
+    it("stops when the response sets windowing to null", () => {
+        expect(nextSessionCursor({count: 1, sessions: [row], windowing: null}, 1)).toBeUndefined()
+    })
web/mobile/src/features/sessions/useSessionsInfinite.ts (2)

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

Reuse the shared SESSIONS_PAGE_SIZE.

@agenta/entities/session already exports SESSIONS_PAGE_SIZE with the value 30, and useSessionListHead.ts imports it from there. This file declares a second constant with the same name and value. The two can drift.

♻️ Proposed refactor
 import {
     nextSessionCursor,
     sessionListQueryOptions,
+    SESSIONS_PAGE_SIZE,
     type SessionListCursor,
 } from "`@agenta/entities/session`"
 import {useInfiniteQuery} from "`@tanstack/react-query`"

 import {mobileSessionListPolicy} from "./sessionListPolicy"

-export const SESSIONS_PAGE_SIZE = 30
-const PAGE_SIZE = SESSIONS_PAGE_SIZE
+export {SESSIONS_PAGE_SIZE}
+const PAGE_SIZE = SESSIONS_PAGE_SIZE

Verify that no mobile consumer depends on this module owning the constant.


38-38: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Stabilize the select transform.

select is an inline arrow that TanStack re-runs whenever its identity changes. It allocates a new result object and a new pages array on each render, which propagates rerenders to list consumers. Hoist it to a module-level function, because it captures nothing from the render scope.

♻️ Proposed refactor
+const selectSessionPages = (data: {pages: {sessions: SessionStream[]}[]}) => ({
+    ...data,
+    pages: data.pages.map((page) => page.sessions),
+})

Then reference it:

-        select: (data) => ({...data, pages: data.pages.map((page) => page.sessions)}),
+        select: selectSessionPages,

As per coding guidelines: "Minimize React re-renders with useMemo, useCallback, and React.memo where appropriate; avoid unstable inline functions and objects, especially in lists."

Source: Coding guidelines

web/oss/src/components/AgentChatSlice/state/projectSessionsQuery.ts (1)

47-51: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

activity duplicates the helper in projectSessions.ts.

projectSessions.ts defines the same function at lines 69-73 with identical logic. Export the helper from this module and import it there.


ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: d1a8f18e-48c9-4f17-8a0f-74774fd60638

📥 Commits

Reviewing files that changed from the base of the PR and between 5d4cc86 and def1cc7.

⛔ Files ignored due to path filters (1)
  • web/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (72)
  • web/mobile/src/features/sessions/sessionListPolicy.ts
  • web/mobile/src/features/sessions/useSessionListHead.ts
  • web/mobile/src/features/sessions/useSessionsInfinite.ts
  • web/mobile/tests/unit/sessionListPolicy.test.ts
  • web/oss/src/components/AgentChatSlice/state/projectSessions.ts
  • web/oss/src/components/AgentChatSlice/state/projectSessionsQuery.test.ts
  • web/oss/src/components/AgentChatSlice/state/projectSessionsQuery.ts
  • web/oss/src/components/Sidebar/dynamic/sessionOptions.test.ts
  • web/oss/src/components/Sidebar/dynamic/sessionOptions.ts
  • web/oss/src/components/Sidebar/dynamic/sessionsSource.ts
  • web/oss/src/components/pages/agent-home/StripHome.tsx
  • web/oss/src/components/pages/agent-home/components/HomeAutomationsSection.tsx
  • web/oss/src/components/pages/agent-home/components/HomeSessionsSection.tsx
  • web/oss/src/components/pages/agent-home/components/YourAgentsTable/useAgentActivity.ts
  • web/oss/src/components/pages/overview/agent/AgentOverview.tsx
  • web/oss/src/components/pages/sessions/SessionsPage.tsx
  • web/oss/src/components/pages/sessions/assets/menuEntries.ts
  • web/oss/src/components/pages/sessions/assets/sessionAutomationActions.test.ts
  • web/oss/src/components/pages/sessions/assets/sessionAutomationActions.ts
  • web/oss/src/components/pages/sessions/components/SessionAutomationDrawers.tsx
  • web/oss/src/components/pages/sessions/components/SessionListCard.tsx
  • web/oss/src/components/pages/sessions/hooks/useSessionAutomationActions.ts
  • web/oss/src/components/pages/settings/Triggers/components/GatewaySchedulesSection.tsx
  • web/oss/src/components/pages/settings/Triggers/components/GatewaySubscriptionsSection.tsx
  • web/oss/src/lib/sessionListPolicies.test.ts
  • web/oss/src/lib/sessionListPolicies.ts
  • web/packages/agenta-entities/src/gatewayTrigger/api/api.ts
  • web/packages/agenta-entities/src/gatewayTrigger/core/types.ts
  • web/packages/agenta-entities/src/gatewayTrigger/hooks/index.ts
  • web/packages/agenta-entities/src/gatewayTrigger/hooks/useTriggerDeliveries.ts
  • web/packages/agenta-entities/src/gatewayTrigger/index.ts
  • web/packages/agenta-entities/src/gatewayTrigger/state/atoms.ts
  • web/packages/agenta-entities/src/gatewayTrigger/state/index.ts
  • web/packages/agenta-entities/src/session/api/api.ts
  • web/packages/agenta-entities/src/session/core/schema.ts
  • web/packages/agenta-entities/src/session/index.ts
  • web/packages/agenta-entities/src/session/state/listOptions.ts
  • web/packages/agenta-entities/tests/unit/fetchTriggerDelivery.test.ts
  • web/packages/agenta-entities/tests/unit/session-list-options.test.ts
  • web/packages/agenta-entities/tests/unit/session-query-api.test.ts
  • web/packages/agenta-entities/tests/unit/session-query-schema.test.ts
  • web/packages/agenta-entities/tests/unit/triggerApplicationArtifactId.test.ts
  • web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/TriggerManagementSection.tsx
  • web/packages/agenta-entity-ui/src/gatewayTrigger/drawers/DeliveryDetails.tsx
  • web/packages/agenta-entity-ui/src/gatewayTrigger/drawers/TriggerDeliveriesDrawer.tsx
  • web/packages/agenta-entity-ui/src/gatewayTrigger/drawers/TriggerDeliveriesDrawerContent.tsx
  • web/packages/agenta-entity-ui/src/gatewayTrigger/drawers/linkedSessionAction.ts
  • web/packages/agenta-entity-ui/src/gatewayTrigger/drawers/schedule/ScheduleForm.tsx
  • web/packages/agenta-entity-ui/src/gatewayTrigger/drawers/subscription/SubscriptionForm.tsx
  • web/packages/agenta-entity-ui/tests/unit/deliveryDetails.test.ts
  • web/packages/agenta-entity-ui/tests/unit/linkedSessionAction.test.ts
  • web/packages/agenta-entity-ui/tests/unit/triggerDeliveriesDrawerMode.test.ts
  • web/packages/agenta-sdk/src/resources.ts
  • web/packages/agenta-sessions-ui/package.json
  • web/packages/agenta-sessions-ui/src/SessionAutomationKind.tsx
  • web/packages/agenta-sessions-ui/src/SessionRow.tsx
  • web/packages/agenta-sessions-ui/src/automationMenu.ts
  • web/packages/agenta-sessions-ui/src/index.ts
  • web/packages/agenta-sessions-ui/tests/unit/SessionRow.test.ts
  • web/packages/agenta-sessions-ui/vitest.config.ts
  • web/packages/agenta-sessions/src/row/index.ts
  • web/packages/agenta-sessions/src/row/sessionRowTitle.ts
  • web/packages/agenta-sessions/src/row/sessionTrigger.ts
  • web/packages/agenta-sessions/src/row/viewModel.ts
  • web/packages/agenta-sessions/src/state/index.ts
  • web/packages/agenta-sessions/src/state/sessionListPolicy.ts
  • web/packages/agenta-sessions/src/state/useSessionCardList.ts
  • web/packages/agenta-sessions/src/state/useSessionList.ts
  • web/packages/agenta-sessions/src/state/useSessionsList.ts
  • web/packages/agenta-sessions/tests/unit/sessionListIdWindow.test.ts
  • web/packages/agenta-sessions/tests/unit/sessionListPolicy.test.ts
  • web/packages/agenta-sessions/tests/unit/sessionRowVm.test.ts

Comment thread web/mobile/src/features/sessions/useSessionListHead.ts
Comment thread web/mobile/src/features/sessions/useSessionListHead.ts
Comment thread web/oss/src/components/AgentChatSlice/state/projectSessionsQuery.ts
Comment thread web/oss/src/components/AgentChatSlice/state/projectSessionsQuery.ts Outdated
Comment thread web/packages/agenta-entities/src/session/core/schema.ts
Comment thread web/packages/agenta-entity-ui/src/gatewayTrigger/drawers/DeliveryDetails.tsx Outdated

@mmabrouk mmabrouk left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

lgtm

…es, and session-list rename/delete refresh

The schedule/subscription edit drawer showed an empty revision picker
even when a variant-level (unversioned) bind existed: the label
selectors expect a revision id, but the default bind stores a variant
id, so resolution silently returned null. Add a fallback that resolves
the label via the bound workflow id instead, with a shared
composeRevisionLabel() helper and tests.

The Agent Overview "Automation runs" section requested no expansions,
so trigger names never resolved and every row read "Missing schedule".
Request the trigger expansion for that surface only (still no
last_message, matching the surface's existing policy).

Renaming or deleting a schedule/subscription never invalidated the
session-list queries (desktop, sidebar, mobile), so an automation
session's row kept showing the old name until an unrelated refetch
happened to fire. invalidateTriggerSchedules/Subscriptions now also
invalidates every session-list query via a shared query-key token,
without enumerating each surface's nesting.
Trims session.name before using it as a chat-sidebar title (the guard
checked trim(), the assignment didn't).

Degrades an unrecognized origin/trigger.kind wire value to undefined
instead of failing the whole /sessions/query page: sessionStreamSchema
validates the entire `sessions` array in one parse, so one row with a
future/unknown enum value previously nulled out every row on the page.

Fixes the delivery status badge falling back to the default (grey)
color when only status.code is set: the badge text already fell back
to code, but the color lookup only ever received status.type.

Disables the subscription mapping editor (raw-JSON Editor and the
composer's contenteditable PillEditor) for a deleted subscription. The
surrounding <fieldset disabled> already covers native controls; these
two aren't native form elements, so they stayed interactive despite
Save being blocked.
@mmabrouk
mmabrouk force-pushed the clients/session-ux-contract branch from 8fc2123 to ebb085f Compare August 11, 2026 11:27
@mmabrouk
mmabrouk force-pushed the frontend/session-ux branch from 62571c8 to c80530c Compare August 11, 2026 11:27
@mmabrouk
mmabrouk changed the base branch from clients/session-ux-contract to release/v0.112.0 August 11, 2026 11:50
@mmabrouk
mmabrouk merged commit 1a280fd into release/v0.112.0 Aug 11, 2026
65 of 69 checks passed
@mmabrouk
mmabrouk deleted the frontend/session-ux branch August 11, 2026 11:50
@mmabrouk

Copy link
Copy Markdown
Member Author

QA walkthrough of the session UX feature (before and after fixes): session-ux-qa.mp4

(Direct comment attachment isn't available through gh, so the video is attached to a QA-only prerelease: https://github.com/Agenta-AI/agenta/releases/tag/qa-session-ux-5927)

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 lgtm This PR has been approved by a maintainer size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant