Commit Graph

1073 Commits

Author SHA1 Message Date
harshitsinghbhandari db340fad88 fix: finish PR #1300 major follow-up fixes 2026-04-18 12:35:15 +05:30
harshitsinghbhandari 76ae4ef426 fix: preserve partial lifecycle payloads for PR #1300 review 2026-04-18 12:20:14 +05:30
harshitsinghbhandari 1d1f11f535 docs: update PR #1300 follow-up note
Record that the remaining lifecycle-state review regressions were fixed in this follow-up branch so the changeset summary matches the actual scope of the patch.
2026-04-18 12:12:49 +05:30
harshitsinghbhandari 8a94c5b0e6 fix(core): address PR #1300 lifecycle regressions
Fix legacy merged-session rehydration so merged PRs stay non-restorable after v2 synthesis. Also validate canonical lifecycle payloads before normalizing them so malformed statePayload data falls back to synthesized metadata instead of corrupting lifecycle state.
2026-04-18 12:11:17 +05:30
harshitsinghbhandari bcdda4b9ba fix: address PR #1300 requested changes 2026-04-18 11:13:53 +05:30
harshitsinghbhandari 79c7ef85a6 fix(core): address PR #1300 review feedback 2026-04-18 01:54:38 +05:30
Harshit Singh Bhandari c67ac51f54
Merge pull request #142 from harshitsinghbhandari/session/aa-22-lifecycle-fixes
feat(lifecycle): bounded detecting state + centralized transitions + report watcher
2026-04-18 01:05:12 +05:30
harshitsinghbhandari 5f3cdf4e5e fix: remove unused TERMINAL_STATUSES import
Fixes CI lint error in dashboard-page-data.ts.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-18 00:58:27 +05:30
harshitsinghbhandari 0d03c46ca5 Merge upstream/main into session/aa-22-lifecycle-fixes
Resolved conflicts in:
- packages/web/src/lib/types.ts (merged canonical type imports with DashboardAttentionZoneMode)
- packages/web/src/lib/dashboard-page-data.ts (kept upstream imports)
- packages/web/src/components/Dashboard.tsx (kept upstream mobileKanbanOrder)

Updated getAttentionLevel to support mode parameter from upstream
while preserving lifecycle-aware helper functions.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-18 00:53:06 +05:30
harshitsinghbhandari 0ab62c8f13 fix: set detectingEscalatedAt for time-based escalation too
The isDetectingEscalated check now considers both attempt limit
AND time limit, ensuring detectingEscalatedAt is set regardless
of which escalation path triggers the stuck state.

Addresses suppressed review comment about time-based escalation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-18 00:46:02 +05:30
Harshit Singh Bhandari e7b7270435
Merge pull request #141 from harshitsinghbhandari/session/aa-22-lifecycle-fixes
feat(lifecycle): bounded detecting state + centralized transitions + report watcher
2026-04-18 00:44:24 +05:30
Harshit Singh Bhandari 2859aa6af7
Merge pull request #1299 from harshitsinghbhandari/docs/add-working-principles
docs: add working principles to contributor docs
2026-04-18 00:39:43 +05:30
harshitsinghbhandari 7b82374ca8 fix: address PR review comments for lifecycle transitions
- Allow spawning sessions in shouldAuditSession for acknowledge timeout
- Remove dead agent_blocked trigger type (never returned)
- Clear audit metadata when no trigger fires
- Protect completedAt/terminatedAt from being overwritten
- Ensure lifecycle patch takes precedence over additionalMetadata
- Add changeset entry for new exports

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-18 00:39:35 +05:30
harshitsinghbhandari 93fa946ac8 docs: add working principles to contributor docs
Document the Karpathy-style working principles in CLAUDE.md and add condensed references in contributor-facing docs so humans and agents follow the same guidance.
2026-04-18 00:32:10 +05:30
harshitsinghbhandari 89c17f49f4 feat(lifecycle): bounded detecting state + centralized transitions + report watcher
Issue #137: Centralize lifecycle transitions
- Create lifecycle-transition.ts with applyLifecycleDecision function
- Provide consistent mutation boundary for lifecycle state changes
- Export buildTransitionMetadataPatch and createStateTransitionDecision helpers

Issue #138: Make detecting a real bounded transition state
- Add time-based escalation (5 min hard cap) in addition to attempt-based (3 attempts)
- Add evidence hashing to prevent counter reset on unchanged evidence
- Track detectingStartedAt and detectingEvidenceHash in metadata
- Escalate to stuck when either limit is exceeded

Issue #140: Report Watcher for agent reports
- Create report-watcher.ts with audit functions
- Add checkAcknowledgeTimeout (10 min default)
- Add checkStaleReport (30 min default)
- Add checkBlockedAgent for needs_input state
- Integrate auditAndReactToReports into lifecycle polling loop
- Surface triggers as reactions (report-no-acknowledge, report-stale, etc.)

Tests:
- 19 tests for lifecycle-status-decisions (detecting bounds, hashing)
- 13 tests for lifecycle-transition (decision application, metadata)
- 19 tests for report-watcher (audit triggers, priorities)

Closes #137, #138, #140

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-18 00:27:21 +05:30
Harshit Singh Bhandari d48b067c66
Merge pull request #139 from harshitsinghbhandari/feat/136
refactor(core): split determineStatus decision helpers
2026-04-17 23:45:58 +05:30
harshitsinghbhandari 6b36efd9ee refactor(core): keep lifecycle decision helpers internal
Move extracted determineStatus decision helpers into an internal module so the refactor does not expand the public lifecycle-manager API surface.

Also share merged and closed PR terminal-state mapping between cached and live SCM decision paths to prevent drift while addressing PR review feedback.
2026-04-17 23:35:23 +05:30
harshitsinghbhandari 245db8f8f9 refactor(core): split lifecycle status decisions for #136
Extract probe and PR decision helpers out of determineStatus so lifecycle state selection is easier to review without mixing it with mutation and metadata commits.

Add focused helper coverage and lock merged PR metadata truth to avoid regressions toward a no-PR state while refactoring the lifecycle path.
2026-04-17 23:00:55 +05:30
Ashish Huddar 237c99f76e
feat(web): collapse attention zones to 4 with 5-zone feature flag (#1202)
* feat(web): collapse attention zones to 4 with feature flag for 5 (#1201)

Simplify the dashboard to a 4-zone kanban by default (WORKING,
PENDING, ACTION, READY), merging the former REVIEW + RESPOND
columns into a single ACTION zone that just asks "does the human
need to do something?". The card-level badges still surface the
underlying granular state (ci_failed, needs_input, changes_requested),
so nothing is lost — it just moves off the column header.

Add a `dashboard.attentionZones` config (defaults to "simple") that
opts back into the original 5-zone layout for power users. The
function-level `getAttentionLevel(session, mode)` still defaults to
"detailed" so card-level call sites (SessionCard, BottomSheet,
ProjectSidebar, etc.) keep their granular behavior untouched. Only
the Dashboard kanban and SSE server routes read the config and pass
the mode.

Closes #1201

* fix(web): address PR review feedback on attention zones (#1201)

- Drop .strict() from DashboardConfigSchema (Cursor Bugbot):
  matches other schemas in config.ts so typos in the dashboard
  block gracefully default instead of crashing the whole loader.

- DynamicFavicon: keep `action` at yellow, not red (Codex P2).
  In simple mode, `action` collapses respond + review, which
  means it necessarily catches routine review work (ci_failed,
  changes_requested) that was previously yellow. Escalating to
  red would make every typical PR scream critical. Only the
  detailed-mode `respond` bucket still triggers red.

- useSessionEvents default → "detailed" (Codex P3). The hook
  default now matches getAttentionLevel's default so callers
  that seed with `getAttentionLevel(s)` (no mode) — notably
  PullRequestsPage — stay consistent with their seed after
  the first live SSE/refresh snapshot. Dashboard explicitly
  passes the config's attentionZones to opt into simple mode.

- Expand mobile action chip (Codex P3). When a session
  collapses to `action`, derive the most specific underlying
  cause (needs input, stuck, errored, ci failed, changes,
  waiting, conflicts) instead of falling through to the
  generic "action" label, so mobile users keep the reason to
  intervene.

- DynamicFavicon tests: add cases for `action` staying yellow
  and `respond` still escalating when both are present.

* fix(web): thread attentionZones config through PullRequestsPage (#1201)

Cursor Bugbot caught a deeper version of the same inconsistency
my previous fix didn't fully resolve: the server SSE route uses
`config.dashboard?.attentionZones ?? "simple"`, but PullRequestsPage
was seeding `initialAttentionLevels` and calling useSessionEvents
without passing any mode (falling back to the hook's "detailed"
default). Result: snapshots from the server arrived as "action"/
"merge", then scheduleRefresh recomputed them client-side as
"respond"/"review", and the favicon oscillated between yellow
and red on every refresh cycle.

Fix: plumb pageData.attentionZones through prs/page.tsx into
PullRequestsPage, use it in both the seed and useSessionEvents.
Now the seed, the server SSE, and the client refresh all use the
same mode — stable, no flicker.

* fix(web): accurate action labels for crashed agents + yellow tone (#1201)

Two Cursor Bugbot findings on the action-zone collapse work:

1. [Medium] Mobile chip mislabeled crashed agents as "needs input".
   When an agent's activity is `exited` and the session is in the
   action bucket, the agent has crashed — sending it a message
   won't help, the user needs to restart. Split the label: exited
   → "crashed", blocked → "blocked".

2. [Low] ProjectMetric for Action used tone="error" (red), which
   contradicts the favicon fix's rationale. The action bucket
   catches routine review work (ci_failed, changes_requested)
   that was previously orange/yellow severity; screaming red in
   the project overview grid would have the same cry-wolf problem
   as the favicon did. Use tone="orange" (the less severe of the
   two merged buckets) to match.

* refactor(web): make attentionZones required in useSessionEvents (#1201)

Cursor Bugbot caught that the hook default of "detailed" mismatches
the server SSE route default of "simple" — a latent footgun for any
future caller that forgets to pass the mode explicitly. The exact
oscillation bug I already fixed once for PullRequestsPage would
silently come back on the next page that uses this hook.

Real fix: refactor the hook to take an options object and make
`attentionZones` required with no default. TypeScript now enforces
that every caller explicitly passes the mode the server is using.
You literally cannot call useSessionEvents without supplying it.

Also cleaner: the hook had 6 positional parameters, which is past
the point where an options object helps readability. Dashboard and
PullRequestsPage call sites now read as self-documenting.

* fix(web): address human code review on attention zones (#1201)

Review from i-trytoohard on commit 8d27db79:

1. [Medium] `ZoneCounts` in sessions/[id]/page.tsx had an `action`
   field that was always 0 — the page always computes in detailed
   mode (getAttentionLevel with no mode = detailed), and the
   consumer (`OrchestratorZones` in SessionDetail) never reads
   an `action` field either. Removed the dead field, added a
   `continue` guard for the never-reached "action" case so
   TypeScript narrows the index correctly, and documented the
   intent in a header comment.

2. [Medium] The simple-mode action chip had 10+ sub-conditions
   with no tests. Extracted the label logic into a pure
   `getActionChipLabel(session)` helper and added 16 unit tests
   covering every branch: status-based signals (needs_input,
   stuck, errored, ci_failed, changes_requested), activity-based
   (waiting_input, exited→crashed, blocked), PR-based (failing
   CI, changes_requested, conflicts), precedence between signal
   classes, and the generic fallback.

3. [Low] `LEVEL_LABELS.action` in ProjectSidebar is dead code
   today (sidebar uses detailed mode). Added a comment explaining
   why the entry still exists (TypeScript exhaustiveness on
   `Record<AttentionLevel, string>` + forward-compat).

* fix(web): address inline review on attention zones (#1201)

- Reorder getActionChipLabel to mirror getDetailedAttentionLevel: respond-class
  activity (waiting_input/exited/blocked) now outranks review-class status
  (ci_failed/changes_requested). A crashed agent with changes_requested no
  longer reads as "changes" and hides the crash.
- Paint data-level="action" dot with --color-accent-orange to match the
  favicon's yellow-severity treatment of the collapsed bucket.
- Tighten attentionLevel on the mux boundary (mux-protocol, mux-websocket,
  useSessionEvents) from string to AttentionLevel so invalid values like "none"
  no longer launder through into DynamicFavicon's count.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-17 22:24:25 +05:30
Harshit Singh Bhandari ae7e7ad0a0
Merge pull request #134 from harshitsinghbhandari/codex/issue-131-pr-workflow-events
feat: allow agent-reported PR workflow events
2026-04-17 22:06:58 +05:30
harshitsinghbhandari 542a3b6a89 fix: address PR review feedback (#131) 2026-04-17 22:01:52 +05:30
Harshit Singh Bhandari 73866ecbb2
Merge pull request #133 from harshitsinghbhandari/issue-132-agent-reports
feat: make agent reports collapsible
2026-04-17 21:49:00 +05:30
harshitsinghbhandari e7ad928812 feat: report non-terminal PR workflow events (#131) 2026-04-17 21:46:57 +05:30
Harshit Singh Bhandari 4237dee577
Update packages/web/src/components/SessionDetail.tsx
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-04-17 21:45:45 +05:30
harshitsinghbhandari 0cf01906ca feat: make agent reports collapsible (#132)
Show explicit session, actor, and source attribution in the session audit trail so report provenance is easier to scan in Session Detail.
2026-04-17 21:39:37 +05:30
Harshit Singh Bhandari 961c064864
Merge pull request #130 from harshitsinghbhandari/feat/129
fix: avoid stuck probe failures when activity is unavailable
2026-04-17 21:33:11 +05:30
harshitsinghbhandari 795ccfb21c fix: require fresh runtime evidence for unavailable-activity downgrade (#129) 2026-04-17 21:29:54 +05:30
harshitsinghbhandari a862327dc5 fix: avoid stuck probe failures for unavailable activity (#129) 2026-04-17 21:22:44 +05:30
Harshit Singh Bhandari dddb7e200e
Merge pull request #128 from harshitsinghbhandari/feat/session-ui-audit-oscillation
Split orchestrator detail, add report audit trail, and stop respond/working oscillation
2026-04-17 21:09:02 +05:30
harshitsinghbhandari 1cbf6579c2 fix: address PR review feedback for session audit trail 2026-04-17 21:06:08 +05:30
harshitsinghbhandari 28ce462ef0 feat: unify session detail auditability and lifecycle stability (#123 #124 #126) 2026-04-17 20:48:02 +05:30
Harshit Singh Bhandari 5fe243b39e
Merge pull request #127 from harshitsinghbhandari/feat/122
fix: model missing activity evidence explicitly
2026-04-17 19:54:50 +05:30
harshitsinghbhandari f1769ec910 fix: address final lifecycle review findings (#122) 2026-04-17 19:52:15 +05:30
harshitsinghbhandari ca8c4cc7ab fix: address lifecycle review feedback (#122)
Keep reconstructed activity and activitySignal coherent, preserve stronger lifecycle states when repeated polls only surface weak evidence, and switch release notes from manual changelog edits to a Changesets entry. This also stabilizes the respond/working path investigated in issue #126.
2026-04-17 19:38:32 +05:30
harshitsinghbhandari dd83a11503 fix: model missing activity evidence explicitly (#122)
Represent missing activity probes as first-class signal states so lifecycle inference only treats valid idle evidence as proof. This prevents false stuck transitions, keeps API/UI lifecycle truth aligned, and makes root monorepo verification deterministic by serializing recursive build and typecheck.
2026-04-17 19:28:56 +05:30
Harshit Singh Bhandari 49369f4706
Merge branch 'ComposioHQ:main' into sessions-redone 2026-04-17 17:09:01 +05:30
Harshit Singh Bhandari c03b66622a
Merge pull request #125 from harshitsinghbhandari/feat/121
fix: isolate lifecycle logs from user terminal output
2026-04-17 17:02:15 +05:30
harshitsinghbhandari e584843978 fix: remove unused observability helper arg (#121) 2026-04-17 16:58:57 +05:30
Ashish Huddar 1e415ab6cc
fix: prevent sidebar flash on session detail pages (#1232)
* fix: prevent sidebar empty-state flash on session pages (#1230)

* fix: reuse sidebar data across session navigation (#1230)

* fix: revalidate cached sidebar data on session pages (#1230)

* fix: harden session sidebar live updates (#1230)

* fix: remove sidebarSessions from mux effect deps

Read from the module-level cachedSidebarSessions cache instead so the
mux effect only re-fires when new mux data arrives, not on every
sidebar state change. Addresses review feedback on #1230.

* fix: address PR #1232 review comments on sidebar session handling

- Guard against out-of-order sidebar fetches with a per-invocation token
  so concurrent pollers/retries don't overwrite fresh responses with stale ones.
- Gate mux overlay on `mux.status === "connected"`; clear pending patches on
  disconnect so a stale WS snapshot doesn't shadow fresher REST data.
- Surface a stale-data banner in the sidebar when a refresh fails but cached
  sessions are still rendered, so users see the failure instead of silently
  viewing outdated state.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-17 16:49:13 +05:30
harshitsinghbhandari 1acefddc89 fix: address review feedback for observability logging (#121) 2026-04-17 16:44:56 +05:30
harshitsinghbhandari bd36c7b447 chore: replace changelog entry with changeset (#121) 2026-04-17 16:36:37 +05:30
harshitsinghbhandari 77f9ccf637 fix: keep lifecycle observability out of session terminals (#121) 2026-04-17 16:33:36 +05:30
Harshit Singh Bhandari da037c7ed1
Merge pull request #120 from harshitsinghbhandari/fix/sessions-redone-readiness
fix: keep closed-unmerged sessions actionable in dashboard
2026-04-17 14:48:59 +05:30
harshitsinghbhandari 08667c8cb5 fix(web): keep closed-unmerged sessions actionable 2026-04-17 14:42:25 +05:30
Harshit Singh Bhandari cc587a56da
Merge pull request #119 from harshitsinghbhandari/feat/stage5-ui-api-rollout
feat: expose split lifecycle truth in dashboard
2026-04-17 13:46:09 +05:30
harshitsinghbhandari da1e2ceae2 fix: restore Next-resolvable serialize types import (#119) 2026-04-17 13:43:26 +05:30
harshitsinghbhandari d3cf4ae3de fix: address PR review comments on stage 5 rollout (#119) 2026-04-17 13:36:09 +05:30
harshitsinghbhandari 690242e379 fix: keep active PR sessions in working lane
Prevent open PR sessions with only  PR truth from being misclassified as pending during the Stage 5 rollout, and add coverage for the regression.
2026-04-17 13:15:11 +05:30
harshitsinghbhandari 88cd9e7ed1 merge: resolve sessions-redone conflicts for stage5
Preserve the split lifecycle observability and UI truth model while retaining the latest sessions-redone PR transition handling and dependency updates.
2026-04-17 13:09:13 +05:30
harshitsinghbhandari 7072143138 feat: expose split lifecycle truth in dashboard
Implement the Stage 5 rollout so API and UI consumers stop depending on one overloaded status and operators can see structured transition evidence without breaking older session metadata.
2026-04-17 13:00:26 +05:30