Skip to content
Merged
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f
- **Traditional Chinese (`zh-TW`) interface language.** Select Traditional Chinese (繁體中文) in the top-bar language menu. On compact layouts, open **More controls** first. Alternatively, let omp-web pick it automatically when the browser language is `zh-TW`, `zh-HK`, `zh-MO`, or `zh-Hant`. Localized Web Push notifications and a Traditional Chinese README (`README.zh-TW.md`) are included.
- **Several web apps can share one host daemon and the same live sessions.** Link additional servers with `ompweb host login --add --url <server>` (token from stdin). Prompts, tool progress, results and dialogs stay synchronized, and restarting one web app leaves the other connected to the same omp process. Link protocol v7 moves session startup, idle cleanup and interrupted-run recovery into the host; older links remain supported without sharing their processes. Schedule the first daemon upgrade while its host is quiescent.
- **Sidebar marks sessions with an unsent draft.** A session whose composer still holds text or attachments shows a small pencil beside its title, so a half-written message is easy to find again. The mark follows this browser tab's drafts.
- **Sidebar marks sessions waiting for your input.** A session with an open question, confirmation or other blocking dialog shows a small question-bubble icon beside its title, next to the unsent-draft pencil. The mark clears as soon as the dialog is answered, cancelled or expires, in every open browser.
- **Identify untagged builds from the logo.** Clicking or tapping the ompweb logo still reveals the version; builds made from an untagged Git commit also show its full hash and commit date (`YYYY-MM-DD`). Builds made on a tag keep the version-only display. The metadata is embedded in the browser bundle, so installed packages and binaries do not need Git.
- **Workspace file APIs run on the owning host.** Directory listings, file metadata and previews, downloads, file search and referenced shell output go through that machine's daemon, including This machine. File downloads stream in bounded chunks rather than being limited by the host link's per-result size. A stopped or older daemon reports unavailable or unsupported instead of reading a path on the web server.
- **File tabs keep their owning workspace.** Files with the same path on different hosts open in separate tabs. Switching chats does not redirect a tab's reads, Markdown links, images or downloads to the new host. Explorer and composer file suggestions follow the selected host, and confirming an agent's file-open request keeps that request's source host. Mention and reveal actions are disabled while the active chat belongs to another host.
Expand Down
2 changes: 2 additions & 0 deletions components/SessionSidebar-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ interface LivePlace {
poolId?: string;
projectId?: string;
projectKey?: string;
/** Running entries only: a blocking dialog waits for the user. */
awaitingInput?: boolean;
}

/** Where a live session the session list lacks gets its placeholder row: the
Expand Down
21 changes: 20 additions & 1 deletion components/SessionSidebar-rows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { memo, useCallback, useId, useRef, useState, useSyncExternalStore, type ReactNode } from "react";
import type { AgentMessage, ExitedRpcSession, ManagedProject, ProjectLaunchConfig, SessionInfo } from "@/lib/types";
import { formatExitedSessionNotice, useI18n } from "@/lib/i18n";
import { ChevronDown, ChevronRight, Folder, GitBranch, MoreHorizontal, Pencil, Pin, Plus } from "lucide-react";
import { ChevronDown, ChevronRight, Folder, GitBranch, MessageCircleQuestion, MoreHorizontal, Pencil, Pin, Plus } from "lucide-react";
import { Tooltip } from "./ui/primitives";
import { ConfirmDialog } from "./ui/field";
import { copyText } from "@/lib/clipboard";
Expand Down Expand Up @@ -101,6 +101,7 @@ interface ProjectRowProps {
hiddenCount: number;
selectedSessionId: string | null;
runningSessionIds: Set<string>;
awaitingInputIds: Set<string>;
unreadSessionIds: Set<string>;
recentlyCompletedIds?: Set<string>;
exitedSessions: Map<string, ExitedRpcSession>;
Expand Down Expand Up @@ -140,6 +141,7 @@ function ProjectRow({
hiddenCount,
selectedSessionId,
runningSessionIds,
awaitingInputIds,
unreadSessionIds,
recentlyCompletedIds,
exitedSessions,
Expand Down Expand Up @@ -482,6 +484,7 @@ function ProjectRow({
node={node}
selectedSessionId={selectedSessionId}
runningSessionIds={runningSessionIds}
awaitingInputIds={awaitingInputIds}
unreadSessionIds={unreadSessionIds}
exitedSessions={exitedSessions}
recentlyCompletedIds={recentlyCompletedIds}
Expand Down Expand Up @@ -535,6 +538,7 @@ const SessionTreeItem = memo(function SessionTreeItem({
node,
selectedSessionId,
runningSessionIds,
awaitingInputIds,
unreadSessionIds,
exitedSessions,
recentlyCompletedIds,
Expand All @@ -549,6 +553,7 @@ const SessionTreeItem = memo(function SessionTreeItem({
node: SessionTreeNode;
selectedSessionId: string | null;
runningSessionIds: Set<string>;
awaitingInputIds: Set<string>;
unreadSessionIds: Set<string>;
exitedSessions: Map<string, ExitedRpcSession>;
recentlyCompletedIds?: Set<string>;
Expand All @@ -570,6 +575,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 = awaitingInputIds.has(sessionId);
const isUnread = unreadSessionIds.has(sessionId);
const isRecentlyCompleted = !isRunning && (recentlyCompletedIds?.has(sessionId) ?? false);
const exited = exitedSessions.get(sessionId);
Expand Down Expand Up @@ -610,6 +616,7 @@ const SessionTreeItem = memo(function SessionTreeItem({
session={node.session}
isSelected={isSelected}
isRunning={isRunning}
isAwaitingInput={isAwaitingInput}
isUnread={isUnread}
exited={exited}
isRecentlyCompleted={isRecentlyCompleted}
Expand All @@ -636,6 +643,7 @@ const SessionTreeItem = memo(function SessionTreeItem({
node={child}
selectedSessionId={selectedSessionId}
runningSessionIds={runningSessionIds}
awaitingInputIds={awaitingInputIds}
unreadSessionIds={unreadSessionIds}
exitedSessions={exitedSessions}
recentlyCompletedIds={recentlyCompletedIds}
Expand Down Expand Up @@ -664,6 +672,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.awaitingInputIds !== next.awaitingInputIds) {
const id = prev.node.session.id;
if (prev.awaitingInputIds.has(id) !== next.awaitingInputIds.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 @@ -685,6 +697,7 @@ const SessionItem = memo(function SessionItem({
session,
isSelected,
isRunning,
isAwaitingInput,
isUnread,
exited,
isRecentlyCompleted,
Expand All @@ -702,6 +715,7 @@ const SessionItem = memo(function SessionItem({
session: SessionInfo;
isSelected: boolean;
isRunning?: boolean;
isAwaitingInput?: boolean;
isUnread?: boolean;
exited?: ExitedRpcSession;
isRecentlyCompleted?: boolean;
Expand Down Expand Up @@ -882,6 +896,11 @@ const SessionItem = memo(function SessionItem({
<span title={title} style={{ minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", color: "var(--text)", fontSize: 12.5, fontWeight: isSelected ? 600 : 500, lineHeight: 1.35, letterSpacing: "-0.005em" }}>
{title}
</span>
{isAwaitingInput && (
<span role="img" title={t("sessionSidebar.awaitingInput")} aria-label={t("sessionSidebar.awaitingInput")} style={{ display: "inline-flex", flexShrink: 0, marginLeft: 5, color: "var(--accent)" }}>
<MessageCircleQuestion size={11} strokeWidth={2.2} aria-hidden="true" />
</span>
)}
{hasUnsentDraft && (
<span role="img" title={t("sessionSidebar.unsentDraft")} aria-label={t("sessionSidebar.unsentDraft")} style={{ display: "inline-flex", flexShrink: 0, marginLeft: 5, color: "var(--accent)" }}>
<Pencil size={11} strokeWidth={2.2} aria-hidden="true" />
Expand Down
2 changes: 2 additions & 0 deletions components/SessionSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export const SessionSidebar = memo(function SessionSidebar({ selectedSessionId,
const [runningSessionIds, setRunningSessionIds] = useState<Set<string>>(() => new Set());
const [runningSessionPlaces, setRunningSessionPlaces] = useState<Record<string, LivePlace>>({});
const [exitedSessions, setExitedSessions] = useState<Map<string, ExitedRpcSession>>(() => new Map());
const awaitingInputIds = useMemo(() => new Set(Object.keys(runningSessionPlaces).filter((id) => runningSessionPlaces[id].awaitingInput)), [runningSessionPlaces]);
const knownRunningPlacesRef = useRef<Map<string, LivePlace>>(new Map());
const { limit: recentRunsLimit } = useRecentRunsLimit();
const [unreadSessionIds, setUnreadSessionIds] = useState<Set<string>>(() => loadUnreadSessionIds());
Expand Down Expand Up @@ -1804,6 +1805,7 @@ export const SessionSidebar = memo(function SessionSidebar({ selectedSessionId,
hiddenCount={filtersActive ? 0 : Math.max(0, tree.length - MAX_PROJECT_SESSIONS)}
selectedSessionId={selectedSessionId}
runningSessionIds={runningSessionIds}
awaitingInputIds={awaitingInputIds}
unreadSessionIds={unreadSessionIds}
exitedSessions={exitedSessions}
recentlyCompletedIds={effectiveRecentCompletedSet}
Expand Down
1 change: 1 addition & 0 deletions lib/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,7 @@
"sessionSidebar.copyTranscriptCopied": "Transcript copied to clipboard",
"sessionSidebar.copyTranscriptFailed": "Could not copy the transcript",
"sessionSidebar.unsentDraft": "Unsent draft",
"sessionSidebar.awaitingInput": "Waiting for your input",
"sessionSidebar.selectProjectFirst": "Select a project first",
"sessionSidebar.switchWorktree": "Switch worktree",
"sessionSidebar.launchConfigDirectory": "Directory",
Expand Down
1 change: 1 addition & 0 deletions lib/i18n/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,7 @@
"sessionSidebar.copyTranscriptCopied": "トランスクリプトをコピーしました",
"sessionSidebar.copyTranscriptFailed": "トランスクリプトをコピーできませんでした",
"sessionSidebar.unsentDraft": "未送信の下書き",
"sessionSidebar.awaitingInput": "入力を待っています",
"sessionSidebar.selectProjectFirst": "先にプロジェクトを選択してください",
"sessionSidebar.switchWorktree": "ワークツリーを切り替え",
"sessionSidebar.launchConfigDirectory": "ディレクトリ",
Expand Down
1 change: 1 addition & 0 deletions lib/i18n/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,7 @@
"sessionSidebar.copyTranscriptCopied": "对话记录已复制到剪贴板",
"sessionSidebar.copyTranscriptFailed": "无法复制对话记录",
"sessionSidebar.unsentDraft": "未发送的草稿",
"sessionSidebar.awaitingInput": "等待你的输入",
"sessionSidebar.selectProjectFirst": "请先选择一个项目",
"sessionSidebar.switchWorktree": "切换工作树",
"sessionSidebar.launchConfigDirectory": "目录",
Expand Down
1 change: 1 addition & 0 deletions lib/i18n/locales/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,7 @@
"sessionSidebar.copyTranscriptCopied": "逐字稿已複製到剪貼簿",
"sessionSidebar.copyTranscriptFailed": "無法複製逐字稿",
"sessionSidebar.unsentDraft": "未傳送的草稿",
"sessionSidebar.awaitingInput": "等待您的輸入",
"sessionSidebar.selectProjectFirst": "請先選取專案",
"sessionSidebar.switchWorktree": "切換工作樹",
"sessionSidebar.launchConfigDirectory": "目錄",
Expand Down
40 changes: 40 additions & 0 deletions lib/rpc-manager.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2998,6 +2998,46 @@ test("a running remote session is listed with its host, so the sidebar groups it
await session.destroyAndWait();
});

test("a session with an open dialog is listed as awaiting input until the dialog is answered", async (t) => {
const { getRunningRpcSessions, startRpcSession, subscribeRunningSessions } = await import("./rpc-manager.ts");
let emitLine;
const transport = {
write(line, callback) {
const command = JSON.parse(line);
const data = command.type === "get_state" ? { sessionId: "s-awaiting", sessionFile: "/nonexistent/s-awaiting.jsonl", isStreaming: false, isCompacting: false } : {};
if (command.id) queueMicrotask(() => emitLine(JSON.stringify({ type: "response", id: command.id, command: command.type, success: true, data })));
callback(null);
},
onLine(listener) { emitLine = listener; queueMicrotask(() => listener('{"type":"ready"}')); },
onStderr() {},
onExit(listener) { this.exit = listener; },
endInput() { queueMicrotask(() => this.exit?.(0, null)); },
killTree() { queueMicrotask(() => this.exit?.(null, "SIGTERM")); },
};
const host = {
id: "laptop",
label: "Laptop",
status: () => "online",
onStatus: () => () => {},
spawnRpc: async (request) => ({ transport, cwd: request.cwd, fellBack: false, launchAdvisor: false }),
sessionFileExists: async () => false,
invalidateSessionLists() {},
autoApproveExtension: () => false,
};
const { session } = await startRpcSession("s-awaiting", "", "/srv/app", undefined, false, null, undefined, host);
t.after(() => session.destroyAndWait());
const awaiting = () => getRunningRpcSessions().find((running) => running.id === "s-awaiting")?.awaitingInput === true;
const pushed = [];
t.after(subscribeRunningSessions((update) => pushed.push(update.runningSessions.some((running) => running.id === "s-awaiting" && running.awaitingInput))));

emitLine(JSON.stringify({ type: "extension_ui_request", id: "q", method: "confirm", title: "Continue?", message: "" }));
assert.equal(awaiting(), true);
assert.equal(pushed.at(-1), true, "the sidebar is told the session waits on the user");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔥 The Roast: This test asserts pushed.at(-1) === true after emitting the dialog event, but pushed only gets values when notifyRunningChange() fires. Since the bug above prevents that notification, this test passes only because awaiting() calls getRunningRpcSessions() directly (bypassing the notification system). The subscription callback never actually runs — the test doesn't verify the real code path the sidebar uses.

🩹 The Fix: Fix the notification bug in trackExtensionUiRequest first, then verify pushed actually receives the update. Consider awaiting a microtask or using a test helper that waits for the subscription callback.

📏 Severity: warning

await session.send({ type: "extension_ui_response", id: "q", confirmed: true });
assert.equal(awaiting(), false);
assert.equal(pushed.at(-1), false, "answering clears the mark without waiting for another omp frame");
});

test("a reload whose host drops while the old child exits fails host_offline and spawns nothing beside it", async () => {
const { getRpcSession, startRpcSession } = await import("./rpc-manager.ts");
let emitLine;
Expand Down
16 changes: 14 additions & 2 deletions lib/rpc-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,10 @@ export class AgentSessionWrapper {
|| this.pendingUiRequests.size > 0 || this.pendingHostTools.size > 0 || this.pendingHostUris.size > 0);
}

isAwaitingInput(): boolean {
return this.pendingUiRequests.size > 0;
}

/** Local history navigation is busy control work, not an interruptible model turn. */
isEditingHistory(): boolean {
return this.historyEditInFlight;
Expand Down Expand Up @@ -1465,7 +1469,8 @@ export class AgentSessionWrapper {

/** Forget a pending dialog and its expiry timer. */
private forgetPendingUiRequest(id: string): void {
this.pendingUiRequests.delete(id);
// An answered or expired dialog no longer waits on the user: the sidebar follows.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔥 The Roast: You added notifyRunningChange() when a dialog is removed (line 1472), but the code that adds dialogs (trackExtensionUiRequest, unchanged in this PR) doesn't notify. Result: the sidebar learns when the user answers a dialog, but never learns when a new dialog appears. The awaiting-input icon stays hidden until something else triggers a refresh.

🩹 The Fix: In trackExtensionUiRequest (around line 1538), after this.pendingUiRequests.set(id, event);, return true so the caller notifies. Or call notifyRunningChange() directly there.

📏 Severity: critical

if (this.pendingUiRequests.delete(id)) notifyRunningChange();
const timer = this.uiExpiryTimers.get(id);
if (timer) {
clearTimeout(timer);
Expand Down Expand Up @@ -3109,6 +3114,8 @@ export interface RunningRpcSession {
cwd: string;
/** Absent on this machine, as on `SessionInfo`: the sidebar groups a placeholder under it. */
hostId?: string;
/** A blocking dialog (ask, confirm, input, …) waits for the user. */
awaitingInput?: true;
}

export interface RunningSessionUpdate {
Expand Down Expand Up @@ -3197,7 +3204,12 @@ export function getRunningRpcSessions(): RunningRpcSession[] {
for (const [sessionId, session] of getRegistry()) {
if (session.isRunning()) {
const id = session.sessionId || sessionId;
map.set(id, { id, cwd: session.cwd, ...(session.host.id === LOCAL_HOST_ID ? {} : { hostId: session.host.id }) });
map.set(id, {
id,
cwd: session.cwd,
...(session.host.id === LOCAL_HOST_ID ? {} : { hostId: session.host.id }),
...(session.isAwaitingInput() ? { awaitingInput: true as const } : {}),
});
}
}
return [...map.values()];
Expand Down
4 changes: 2 additions & 2 deletions lib/session-routes.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1623,7 +1623,7 @@ test("GET /api/sessions returns ETag and 304 across unchanged session list and r

// Running sessions change invalidates ETag
const previousSessions = globalThis.__ompSessions;
globalThis.__ompSessions = new Map([["running-1", { isRunning: () => true, cwd: dir, isAlive: () => true, host: { id: "local" } }]]);
globalThis.__ompSessions = new Map([["running-1", { isRunning: () => true, isAwaitingInput: () => false, cwd: dir, isAlive: () => true, host: { id: "local" } }]]);
try {
const res4 = await sessionsListRoute.GET(new Request("http://localhost/api/sessions"));
assert.equal(res4.status, 200);
Expand All @@ -1638,7 +1638,7 @@ test("GET /api/sessions returns ETag and 304 across unchanged session list and r

// Running session hostId change (while id and cwd stay the same) invalidates ETag
globalThis.__ompSessions = new Map([
["running-1", { isRunning: () => true, cwd: dir, isAlive: () => true, host: { id: "remote-worker-1" } }],
["running-1", { isRunning: () => true, isAwaitingInput: () => false, cwd: dir, isAlive: () => true, host: { id: "remote-worker-1" } }],
]);
const resHostChange = await sessionsListRoute.GET(new Request("http://localhost/api/sessions", {
headers: { "if-none-match": etag4 },
Expand Down
Loading