Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
27 changes: 26 additions & 1 deletion components/SessionSidebar-chrome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -398,6 +398,30 @@ function RunningSessionIndicator({ size = 14 }: { size?: number }) {
</span>
);
}
/** 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 (
<span
title={label}
aria-label={label}
role="img"
data-awaiting-input="true"
style={{
width: size,
height: size,
display: "inline-flex",
alignItems: "center",
justifyContent: "center",
flexShrink: 0,
color: "var(--status-warning)",
}}
>
<MessageCircleQuestionMark size={size} strokeWidth={2.4} aria-hidden="true" />
</span>
);
}
function ExitedSessionIndicator({ title, size = 14 }: { title: string; size?: number }) {
return (
<span
Expand Down Expand Up @@ -471,6 +495,7 @@ function UnreadSessionIndicator({ size = 14 }: { size?: number }) {
export {
OmpWebTitle,
PathLabel,
AwaitingInputIndicator,
ExitedSessionIndicator,
RunningSessionIndicator,
RecentlyCompletedIndicator,
Expand Down
46 changes: 35 additions & 11 deletions components/SessionSidebar-rows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import {
projectLabel,
type SessionTreeNode,
} from "./SessionSidebar-helpers";
import type { ProjectActivity } from "@/lib/project-ordering";
import {
AwaitingInputIndicator,
ExitedSessionIndicator,
RecentlyCompletedIndicator,
RunningSessionIndicator,
Expand All @@ -37,12 +39,14 @@ interface ProjectRowProps {
project: ManagedProject;
isActive: boolean;
isExpanded: boolean;
activity: { running: number; unread: number; exited: number } | undefined;
activity: ProjectActivity | undefined;
tree: SessionTreeNode[];
/** Sessions beyond the cap (0 when a filter is active — show all matches). */
hiddenCount: number;
selectedSessionId: string | null;
runningSessionIds: Set<string>;
/** Running sessions waiting for the user's answer (subset of runningSessionIds). */
awaitingInputSessionIds: Set<string>;
unreadSessionIds: Set<string>;
recentlyCompletedIds?: Set<string>;
exitedSessions: Map<string, ExitedRpcSession>;
Expand Down Expand Up @@ -77,6 +81,7 @@ function ProjectRow({
hiddenCount,
selectedSessionId,
runningSessionIds,
awaitingInputSessionIds,
unreadSessionIds,
recentlyCompletedIds,
exitedSessions,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -280,16 +286,19 @@ function ProjectRow({
)}
{hasActivity && (
<span
aria-label={t("projects.activity", { running: activity?.running ?? 0, unread: activity?.unread ?? 0, exited: activity?.exited ?? 0 })}
title={t("projects.activity", { running: activity?.running ?? 0, unread: activity?.unread ?? 0, exited: activity?.exited ?? 0 })}
aria-label={activityLabel}
title={activityLabel}
className="sidebar-project-activity"
data-running={(activity?.running ?? 0) > 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 ? (
<ExitedSessionIndicator title={t("projects.exited", { count: activity?.exited ?? 0 })} size={11} />
) : (activity?.waiting ?? 0) > 0 ? (
<AwaitingInputIndicator title={t("projects.waiting", { count: activity?.waiting ?? 0 })} size={11} />
) : (
<span
aria-hidden="true"
Expand Down Expand Up @@ -399,6 +408,7 @@ function ProjectRow({
node={node}
selectedSessionId={selectedSessionId}
runningSessionIds={runningSessionIds}
awaitingInputSessionIds={awaitingInputSessionIds}
unreadSessionIds={unreadSessionIds}
exitedSessions={exitedSessions}
recentlyCompletedIds={recentlyCompletedIds}
Expand Down Expand Up @@ -450,6 +460,7 @@ const SessionTreeItem = memo(function SessionTreeItem({
node,
selectedSessionId,
runningSessionIds,
awaitingInputSessionIds,
unreadSessionIds,
exitedSessions,
recentlyCompletedIds,
Expand All @@ -462,6 +473,7 @@ const SessionTreeItem = memo(function SessionTreeItem({
node: SessionTreeNode;
selectedSessionId: string | null;
runningSessionIds: Set<string>;
awaitingInputSessionIds: Set<string>;
unreadSessionIds: Set<string>;
exitedSessions: Map<string, ExitedRpcSession>;
recentlyCompletedIds?: Set<string>;
Expand All @@ -479,6 +491,7 @@ const SessionTreeItem = memo(function SessionTreeItem({
// check then never re-renders unless this row's flags actually changed.
const isSelected = sessionId === selectedSessionId;
const isRunning = runningSessionIds.has(sessionId);
const isAwaitingInput = isRunning && awaitingInputSessionIds.has(sessionId);
const isUnread = unreadSessionIds.has(sessionId);
const isRecentlyCompleted = !isRunning && (recentlyCompletedIds?.has(sessionId) ?? false);
const exited = exitedSessions.get(sessionId);
Expand Down Expand Up @@ -513,6 +526,7 @@ const SessionTreeItem = memo(function SessionTreeItem({
session={node.session}
isSelected={isSelected}
isRunning={isRunning}
isAwaitingInput={isAwaitingInput}
isUnread={isUnread}
exited={exited}
isRecentlyCompleted={isRecentlyCompleted}
Expand All @@ -534,6 +548,7 @@ const SessionTreeItem = memo(function SessionTreeItem({
node={child}
selectedSessionId={selectedSessionId}
runningSessionIds={runningSessionIds}
awaitingInputSessionIds={awaitingInputSessionIds}
unreadSessionIds={unreadSessionIds}
exitedSessions={exitedSessions}
recentlyCompletedIds={recentlyCompletedIds}
Expand All @@ -560,6 +575,10 @@ const SessionTreeItem = memo(function SessionTreeItem({
const id = prev.node.session.id;
if (prev.runningSessionIds.has(id) !== next.runningSessionIds.has(id)) return false;
}
if (prev.awaitingInputSessionIds !== next.awaitingInputSessionIds) {
const id = prev.node.session.id;
if (prev.awaitingInputSessionIds.has(id) !== next.awaitingInputSessionIds.has(id)) return false;
}
if (prev.recentlyCompletedIds !== next.recentlyCompletedIds) {
const id = prev.node.session.id;
if ((prev.recentlyCompletedIds?.has(id) ?? false) !== (next.recentlyCompletedIds?.has(id) ?? false)) return false;
Expand All @@ -579,6 +598,7 @@ const SessionItem = memo(function SessionItem({
session,
isSelected,
isRunning,
isAwaitingInput,
isUnread,
exited,
isRecentlyCompleted,
Expand All @@ -594,6 +614,8 @@ const SessionItem = memo(function SessionItem({
session: SessionInfo;
isSelected: boolean;
isRunning?: boolean;
/** Running, but paused on a dialog only the user can answer. */
isAwaitingInput?: boolean;
isUnread?: boolean;
exited?: ExitedRpcSession;
isRecentlyCompleted?: boolean;
Expand Down Expand Up @@ -760,13 +782,15 @@ const SessionItem = memo(function SessionItem({
<div style={{ display: "flex", alignItems: "center", gap: SIDEBAR_STATUS_GAP, flexShrink: 0 }}>
{(isRunning || exited || isRecentlyCompleted || isUnread) && (
<span style={{ display: "flex", alignItems: "center", justifyContent: "center", width: SIDEBAR_STATUS_SLOT, height: SIDEBAR_STATUS_SLOT, flexShrink: 0 }}>
{isRunning
? <RunningSessionIndicator size={12} />
: exited
? <ExitedSessionIndicator title={exitTitle} size={12} />
: isRecentlyCompleted
? <RecentlyCompletedIndicator size={12} />
: <UnreadSessionIndicator size={11} />}
{isAwaitingInput
? <AwaitingInputIndicator size={12} />
: isRunning
? <RunningSessionIndicator size={12} />
: exited
? <ExitedSessionIndicator title={exitTitle} size={12} />
: isRecentlyCompleted
? <RecentlyCompletedIndicator size={12} />
: <UnreadSessionIndicator size={11} />}
</span>
)}
<div className="session-item-trailing" style={{ display: "flex", alignItems: "center", justifyContent: "flex-end", flexShrink: 0 }}>
Expand Down
117 changes: 117 additions & 0 deletions components/SessionSidebar.awaiting-input.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import assert from "node:assert/strict";
import test from "node:test";
import React from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { createJiti } from "jiti";

// A running session paused on a dialog only the user can answer shows the
// amber "waiting for your answer" indicator instead of the running spinner,
// and its project row counts it as waiting rather than running.

const jiti = createJiti(import.meta.url, {
jsx: { runtime: "automatic" },
tsconfigPaths: true,
});
const { ProjectRow } = await jiti.import("./SessionSidebar-rows.tsx");
const { projectActivityCounts } = await jiti.import("../lib/project-ordering.ts");
const { comparableProjectPath } = await jiti.import("../lib/comparable-path.ts");

const noop = () => {};
const project = { path: "/repo", addedAt: "2026-01-01T00:00:00.000Z" };
const session = (id, name) => ({
id,
name,
firstMessage: name,
path: `/sessions/${id}.jsonl`,
cwd: "/repo",
projectRoot: "/repo",
created: "2026-10-28T00:00:00.000Z",
modified: "2026-10-28T00:00:00.000Z",
messageCount: 2,
});
const sessions = [session("working", "Working session"), session("waiting", "Waiting session"), session("idle", "Idle session")];
const tree = sessions.map((s) => ({ session: s, children: [] }));

function renderProject({ running, awaiting }) {
const runningIds = new Set(running);
const awaitingIds = new Set(awaiting);
const activity = projectActivityCounts(sessions, runningIds, [], [], awaitingIds).get(comparableProjectPath("/repo"));
return renderToStaticMarkup(React.createElement(ProjectRow, {
project,
isActive: true,
isExpanded: true,
activity,
tree,
hiddenCount: 0,
selectedSessionId: null,
runningSessionIds: runningIds,
awaitingInputSessionIds: awaitingIds,
unreadSessionIds: new Set(),
recentlyCompletedIds: new Set(),
exitedSessions: new Map(),
relativeTimeNow: Date.parse("2026-10-28T00:05:00.000Z"),
onActivate: noop,
onToggleExpand: noop,
onRemoveProject: noop,
onEditLaunchConfig: noop,
onUpdatePresentation: noop,
onDragPathChange: noop,
onDropProject: noop,
onMoveProject: noop,
pinnable: false,
onTogglePin: async () => {},
isDragTarget: false,
removeBusy: false,
onSelectSession: noop,
}));
}

/** Markup of the session row whose title is `name`. */
function rowFor(html, name) {
const start = html.indexOf(`title="${name}"`);
assert.ok(start >= 0, `row ${name} renders`);
const rowStart = html.lastIndexOf('class="session-item-row"', start);
const rowEnd = html.indexOf('class="session-item-row"', start);
return html.slice(rowStart, rowEnd === -1 ? undefined : rowEnd);
}

const WAITING_LABEL = 'aria-label="Waiting for your answer"';
const SPINNER = 'class="sidebar-running-spinner"';

test("a session waiting for an answer shows the waiting indicator, not the spinner", () => {
const html = renderProject({ running: ["working", "waiting"], awaiting: ["waiting"] });
const waiting = rowFor(html, "Waiting session");
assert.ok(waiting.includes(WAITING_LABEL), "waiting row is labelled for assistive tech");
assert.ok(waiting.includes('title="Waiting for your answer"'), "waiting row has a tooltip");
assert.ok(waiting.includes('data-awaiting-input="true"'));
assert.ok(waiting.includes("var(--status-warning)"), "amber, distinct from the accent spinner");
assert.ok(!waiting.includes(SPINNER), "no spinner while waiting");

const working = rowFor(html, "Working session");
assert.ok(working.includes(SPINNER), "a working session keeps the spinner");
assert.ok(!working.includes(WAITING_LABEL));

const idle = rowFor(html, "Idle session");
assert.ok(!idle.includes(SPINNER) && !idle.includes(WAITING_LABEL));
});

test("the project summary counts waiting sessions separately from running ones", () => {
const html = renderProject({ running: ["working", "waiting"], awaiting: ["waiting"] });
assert.match(html, /aria-label="1 running, 1 waiting for your answer, 0 unread, 0 exited unexpectedly"/);
assert.match(html, /class="sidebar-project-activity"[^>]*data-waiting="true"/);
assert.match(html, /title="1 waiting for your answer"/, "the project badge shows the waiting icon");
});

test("once answered the row returns to the spinner and the summary to running only", () => {
const html = renderProject({ running: ["working", "waiting"], awaiting: [] });
assert.ok(rowFor(html, "Waiting session").includes(SPINNER));
assert.ok(!html.includes(WAITING_LABEL));
assert.match(html, /aria-label="2 running, 0 waiting for your answer, 0 unread, 0 exited unexpectedly"/);
assert.match(html, /class="sidebar-project-activity"[^>]*data-waiting="false"/);
});

test("an awaiting id without a running session never shows the waiting indicator", () => {
const html = renderProject({ running: [], awaiting: ["waiting"] });
assert.ok(!html.includes(WAITING_LABEL));
assert.ok(!html.includes('class="sidebar-project-activity"'), "no activity badge for an idle project");
});
Loading
Loading