From d408600406352392b27b74dbe4140d9d42ee6ef6 Mon Sep 17 00:00:00 2001 From: OrwellVII <56531592+OrwellVII@users.noreply.github.com> Date: Wed, 28 Oct 2026 18:34:38 +0800 Subject: [PATCH] feat(sidebar): show sessions waiting for your answer A running session paused on a dialog the user must answer (ask tool, select/confirm/input/editor, "Allow tool" prompts) now carries `awaitingInput` + `awaitingInputMethod` in each `runningSessions` entry of /api/sessions and the `running` channel. The sidebar shows an amber "Waiting for your answer" bubble instead of the spinner, and the project activity summary counts the session as waiting rather than running. Only DIALOG_UI_METHODS count; open_url stays a replayed blocking request but is fire-and-forget per omp's RPC docs. Answering a dialog and its expiry timer now broadcast a running-change, alongside the existing omp cancel, process exit, destroy and restart paths. --- AGENTS.md | 1 + CHANGELOG.md | 4 + components/SessionSidebar-chrome.tsx | 27 +++- components/SessionSidebar-rows.tsx | 46 +++++-- .../SessionSidebar.awaiting-input.test.mjs | 117 +++++++++++++++++ components/SessionSidebar.tsx | 19 ++- lib/i18n/locales/en.json | 4 +- lib/i18n/locales/ja.json | 4 +- lib/i18n/locales/zh-CN.json | 4 +- lib/notification-events.ts | 9 +- lib/project-ordering.test.mjs | 19 ++- lib/project-ordering.ts | 31 +++-- lib/rpc-manager.test.mjs | 119 ++++++++++++++++++ lib/rpc-manager.ts | 41 ++++-- lib/types.ts | 10 ++ 15 files changed, 410 insertions(+), 45 deletions(-) create mode 100644 components/SessionSidebar.awaiting-input.test.mjs diff --git a/AGENTS.md b/AGENTS.md index 197270781..c756b2463 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -397,6 +397,7 @@ during the wait. ### Running state + reconciliation - The sidebar subscribes to the `running` channel, backed by `subscribeRunningSessions()` in `lib/rpc-manager.ts`, so running badges update without polling. +- `runningSessions` entries (`RunningRpcSession` in `lib/types.ts`; `/api/sessions` and the `running` channel) carry `awaitingInput: true` + `awaitingInputMethod` while a dialog the user must answer is pending — `DIALOG_UI_METHODS` (`select`/`confirm`/`input`/`editor`/`ask`) in `lib/notification-events.ts`, a subset of `BLOCKING_UI_METHODS` without the fire-and-forget `open_url`. The sidebar then shows the amber "Waiting for your answer" bubble instead of the spinner and `projectActivityCounts` counts the session as `waiting`, not `running`. The flag lives in the broadcast snapshot, so every path that settles a pending dialog (answer in `send`, omp `cancel`, expiry timer, replay-time expiry, process exit/destroy/restart) must reach `notifyRunningChange()`. - `useAgentSession` still treats its `session` channel as primary for chat events, but while a run is active it periodically calls `GET /api/agent/[id]` and also reconciles on `visibilitychange`/`online`. This fixes missed `agent_end` events from background tabs or half-open connections. - Prompt runs use a monotonic run id; late SSE or slow reconciliation responses from an old run must be ignored so they cannot resurrect stale streaming bubbles. diff --git a/CHANGELOG.md b/CHANGELOG.md index f25ddce22..402afe0c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f ## [Unreleased] +### Added + +- **The sidebar shows which sessions are waiting for you.** A session paused on a question or approval (the agent's `ask` tool, a select/confirm/input/editor dialog, an "Allow tool" prompt) now shows an amber question bubble labelled **Waiting for your answer** instead of the running spinner, and its workspace row counts it as waiting rather than running. Open the session to answer; the row returns to the spinner as soon as the answer is sent, the dialog is cancelled or times out, or the omp process exits. Every open browser updates live. + ### Fixes & Improvements - **In-app updates work when ompweb runs as a systemd service.** The update worker ran inside the service's cgroup, so stopping the server killed the worker too: nothing was installed, the service could stay down (`Restart=on-failure` does not restart a clean SIGTERM exit), and every page load reopened the update dialog at "Stop ompweb-managed sessions". The worker now runs in its own transient scope (`systemd-run --scope`) and stops, updates and starts the unit through `systemctl`, starting it again if the install fails. diff --git a/components/SessionSidebar-chrome.tsx b/components/SessionSidebar-chrome.tsx index 2dde5a106..4be8d1d62 100644 --- a/components/SessionSidebar-chrome.tsx +++ b/components/SessionSidebar-chrome.tsx @@ -4,7 +4,7 @@ import { useCallback, useEffect, useLayoutEffect, useRef, useState, type CSSProp import { createPortal } from "react-dom"; import { useI18n } from "@/lib/i18n"; import { usePrefersReducedMotion } from "@/hooks/usePrefersReducedMotion"; -import { AlertTriangle, Check } from "lucide-react"; +import { AlertTriangle, Check, MessageCircleQuestionMark } from "lucide-react"; import OmpWebLogo from "./OmpWebLogo"; /** * Path label that ellipsizes on the LEFT, keeping the (most relevant) trailing @@ -398,6 +398,30 @@ function RunningSessionIndicator({ size = 14 }: { size?: number }) { ); } +/** A running session paused on a question/approval only the user can answer. */ +function AwaitingInputIndicator({ size = 14, title }: { size?: number; title?: string }) { + const { t } = useI18n(); + const label = title ?? t("sessionSidebar.awaitingInput"); + return ( + + + ); +} function ExitedSessionIndicator({ title, size = 14 }: { title: string; size?: number }) { return ( ; + /** Running sessions waiting for the user's answer (subset of runningSessionIds). */ + awaitingInputSessionIds: Set; unreadSessionIds: Set; recentlyCompletedIds?: Set; exitedSessions: Map; @@ -77,6 +81,7 @@ function ProjectRow({ hiddenCount, selectedSessionId, runningSessionIds, + awaitingInputSessionIds, unreadSessionIds, recentlyCompletedIds, exitedSessions, @@ -128,7 +133,8 @@ function ProjectRow({ const label = project.alias ?? projectLabel(project.path); const pinned = pinnable && project.pinOrder !== undefined; const canReorder = !pinnable || pinned; - const hasActivity = Boolean(activity && (activity.running > 0 || activity.unread > 0 || activity.exited > 0)); + const hasActivity = Boolean(activity && (activity.running > 0 || activity.waiting > 0 || activity.unread > 0 || activity.exited > 0)); + const activityLabel = t("projects.activity", { running: activity?.running ?? 0, waiting: activity?.waiting ?? 0, unread: activity?.unread ?? 0, exited: activity?.exited ?? 0 }); const visibleRoots = hiddenCount > 0 && !showAllSessions ? tree.slice(0, MAX_PROJECT_SESSIONS) : tree; @@ -280,16 +286,19 @@ function ProjectRow({ )} {hasActivity && ( 0 ? "true" : "false"} + data-waiting={(activity?.waiting ?? 0) > 0 ? "true" : "false"} role="status" aria-live="polite" style={{ display: "inline-flex", alignItems: "center", justifyContent: "center", width: SIDEBAR_STATUS_SLOT, height: SIDEBAR_STATUS_SLOT, flexShrink: 0, lineHeight: 0 }} > {(activity?.exited ?? 0) > 0 ? ( + ) : (activity?.waiting ?? 0) > 0 ? ( + ) : (