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 @@ -155,6 +155,7 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f
- **Workspace profile names are validated before they can break sessions.** The profile inputs show the naming rule and reject invalid names, and the API rejects invalid profiles and reserved launch arguments. Existing invalid profiles and reserved arguments remain visible in the workspace launch configuration; an updated host daemon refuses to start a session until they are corrected or cleared, instead of silently switching profiles or passing an orphan argument. Update remote host daemons as well: older versions do not enforce this spawn-time check.
- **A failed run no longer shows its error three times.** The duplicate "Request failed" toast is gone. A non-quota error already shown on the current run's assistant message does not also need a shelf notice; standalone errors and errors whose message cannot be confirmed remain visible in the shelf, even after partial output. If the matching assistant message is saved later, it replaces only that run's duplicate notice. Quota handling is unchanged and may show both an inline banner and a shelf notice.
- **`send_to_session` with `delivery: "followUp"` queues the message.** It failed with "Unsupported command: followUp" instead of queueing the message after the target's running turn.
- **The sidebar's green check clears once you open the conversation.** The check marked the most recently active sessions (the "recent runs" limit, 10 by default), so it stayed on conversations you had already read and never went away. It now means "finished in the background and not opened yet": opening the session removes it, a session that finishes while you are viewing it never gets one, and other tabs of the same browser drop it too. The state is kept per browser, not synced across devices. The pulsing "new activity" dot, which marked the same state, is gone. The running-only filter still keeps recently finished sessions.

---

Expand Down
41 changes: 5 additions & 36 deletions components/SessionSidebar-chrome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,13 @@ function ExitedSessionIndicator({ title, size = 14 }: { title: string; size?: nu
</span>
);
}
function RecentlyCompletedIndicator({ size = 12 }: { size?: number }) {
/** A session that finished in the background and has not been opened since. */
function CompletedUnreadIndicator({ size = 12 }: { size?: number }) {
const { t } = useI18n();
return (
<span
title={t("sessionSidebar.recentlyCompleted")}
aria-label={t("sessionSidebar.recentlyCompleted")}
title={t("sessionSidebar.completedUnread")}
aria-label={t("sessionSidebar.completedUnread")}
style={{
width: size,
height: size,
Expand All @@ -455,46 +456,14 @@ function RecentlyCompletedIndicator({ size = 12 }: { size?: number }) {
</span>
);
}


function UnreadSessionIndicator({ size = 14 }: { size?: number }) {
const { t } = useI18n();
const reducedMotion = usePrefersReducedMotion();
return (
<span
title={t("sessionSidebar.newActivity")}
aria-label={t("sessionSidebar.newSessionActivity")}
style={{
width: size,
height: size,
display: "inline-flex",
alignItems: "center",
justifyContent: "center",
flexShrink: 0,
color: "var(--accent)",
}}
>
<svg width={size} height={size} viewBox="0 0 14 14" fill="none" aria-hidden="true" style={{ display: "block" }}>
<circle cx="7" cy="7" r="2.5" fill="currentColor" />
{!reducedMotion && (
<circle cx="7" cy="7" r="3" stroke="currentColor" strokeWidth="1.4" opacity="0.32">
<animate attributeName="r" values="3;6;3" dur="1.6s" repeatCount="indefinite" />
<animate attributeName="opacity" values="0.32;0;0.32" dur="1.6s" repeatCount="indefinite" />
</circle>
)}
</svg>
</span>
);
}
export {
OmpWebTitle,
PathLabel,
ExitedSessionIndicator,
RunningSessionIndicator,
RecentlyCompletedIndicator,
CompletedUnreadIndicator,
SIDEBAR_BUTTON_TRANSITION,
SidebarIconButton,
SidebarPortalMenu,
UnreadSessionIndicator,
useScramble,
};
26 changes: 6 additions & 20 deletions components/SessionSidebar-rows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ import {
type SessionTreeNode,
} from "./SessionSidebar-helpers";
import {
CompletedUnreadIndicator,
ExitedSessionIndicator,
RecentlyCompletedIndicator,
RunningSessionIndicator,
SIDEBAR_BUTTON_TRANSITION,
SidebarIconButton,
SidebarPortalMenu,
UnreadSessionIndicator,
} from "./SessionSidebar-chrome";

/**
Expand Down Expand Up @@ -103,7 +102,6 @@ interface ProjectRowProps {
runningSessionIds: Set<string>;
awaitingInputIds: Set<string>;
unreadSessionIds: Set<string>;
recentlyCompletedIds?: Set<string>;
exitedSessions: Map<string, ExitedRpcSession>;
relativeTimeNow: number;
onActivate: (project: ManagedProject) => void;
Expand Down Expand Up @@ -143,7 +141,6 @@ function ProjectRow({
runningSessionIds,
awaitingInputIds,
unreadSessionIds,
recentlyCompletedIds,
exitedSessions,
relativeTimeNow,
onActivate,
Expand Down Expand Up @@ -487,7 +484,6 @@ function ProjectRow({
awaitingInputIds={awaitingInputIds}
unreadSessionIds={unreadSessionIds}
exitedSessions={exitedSessions}
recentlyCompletedIds={recentlyCompletedIds}
relativeTimeNow={relativeTimeNow}
onSelectSession={onSelectSession}
onRenamed={onRenamed}
Expand Down Expand Up @@ -541,7 +537,6 @@ const SessionTreeItem = memo(function SessionTreeItem({
awaitingInputIds,
unreadSessionIds,
exitedSessions,
recentlyCompletedIds,
relativeTimeNow,
onSelectSession,
onRenamed,
Expand All @@ -556,7 +551,6 @@ const SessionTreeItem = memo(function SessionTreeItem({
awaitingInputIds: Set<string>;
unreadSessionIds: Set<string>;
exitedSessions: Map<string, ExitedRpcSession>;
recentlyCompletedIds?: Set<string>;
relativeTimeNow: number;
onSelectSession: (s: SessionInfo) => void;
onRenamed?: () => void;
Expand All @@ -577,7 +571,6 @@ const SessionTreeItem = memo(function SessionTreeItem({
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);

// Stable callbacks: depend only on primitives / stable parent callbacks so
Expand Down Expand Up @@ -619,7 +612,6 @@ const SessionTreeItem = memo(function SessionTreeItem({
isAwaitingInput={isAwaitingInput}
isUnread={isUnread}
exited={exited}
isRecentlyCompleted={isRecentlyCompleted}
relativeTimeNow={relativeTimeNow}
onClick={handleClick}
onRenamed={onRenamed}
Expand All @@ -646,7 +638,6 @@ const SessionTreeItem = memo(function SessionTreeItem({
awaitingInputIds={awaitingInputIds}
unreadSessionIds={unreadSessionIds}
exitedSessions={exitedSessions}
recentlyCompletedIds={recentlyCompletedIds}
relativeTimeNow={relativeTimeNow}
onSelectSession={onSelectSession}
onRenamed={onRenamed}
Expand Down Expand Up @@ -676,11 +667,10 @@ const SessionTreeItem = memo(function SessionTreeItem({
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;
}
if (prev.unreadSessionIds !== next.unreadSessionIds) {
// Nested rows render inside this memo boundary, so a parent must pass a
// changed set down even when only a descendant's unread state flipped.
if (prev.node.children.length > 0) return false;
const id = prev.node.session.id;
if (prev.unreadSessionIds.has(id) !== next.unreadSessionIds.has(id)) return false;
}
Expand All @@ -700,7 +690,6 @@ const SessionItem = memo(function SessionItem({
isAwaitingInput,
isUnread,
exited,
isRecentlyCompleted,
onClick,
onRenamed,
onDeleted,
Expand All @@ -718,7 +707,6 @@ const SessionItem = memo(function SessionItem({
isAwaitingInput?: boolean;
isUnread?: boolean;
exited?: ExitedRpcSession;
isRecentlyCompleted?: boolean;
onClick: () => void;
onRenamed?: () => void;
onDeleted?: (id: string) => void;
Expand Down Expand Up @@ -910,15 +898,13 @@ const SessionItem = memo(function SessionItem({
{session.worktreeBranch && <span title={t("sessionSidebar.worktreeTitle", { path: session.cwd })} style={{ display: "flex", alignItems: "center", gap: 3, maxWidth: 56, minWidth: 0, overflow: "hidden", color: "var(--text-dim)", fontSize: 10, flexShrink: 1 }}><GitBranch size={10} strokeWidth={2.4} aria-hidden="true" /><span style={{ minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}>{session.worktreeBranch}</span></span>}
{hasChildren && <button className="session-item-icon-button" onClick={(event) => { event.stopPropagation(); onToggleCollapse?.(); }} title={collapsed ? t("sessionSidebar.expandForks") : t("sessionSidebar.collapseForks")} aria-label={collapsed ? t("sessionSidebar.expandForks") : t("sessionSidebar.collapseForks")} aria-expanded={!collapsed} style={{ display: "flex", alignItems: "center", justifyContent: "center", width: 24, height: 24, padding: 0, flexShrink: 0, border: "none", background: "none", color: "var(--text-dim)", cursor: "pointer", transform: collapsed ? "rotate(-90deg)" : "none", transition: "transform var(--dur-fast) var(--ease-out-warm)" }}><ChevronDown size={12} strokeWidth={1.8} aria-hidden="true" /></button>}
<div style={{ display: "flex", alignItems: "center", gap: SIDEBAR_STATUS_GAP, flexShrink: 0 }}>
{(isRunning || exited || isRecentlyCompleted || isUnread) && (
{(isRunning || exited || 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} />}
: <CompletedUnreadIndicator size={12} />}
</span>
)}
<div className="session-item-trailing" style={{ display: "flex", alignItems: "center", justifyContent: "flex-end", flexShrink: 0 }}>
Expand Down
169 changes: 169 additions & 0 deletions components/SessionSidebar.completed.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
import "../tests/setup-dom.mjs";
import assert from "node:assert/strict";
import test, { afterEach, before } from "node:test";
import React from "react";
const { act, cleanup, render, screen, waitFor, within } = await import("@testing-library/react/pure.js");
const { default: userEvent } = await import("@testing-library/user-event");

// The sidebar's green check means "finished in the background, not opened
// since": it follows the persisted unread set, never recency ranking.

const { SessionSidebar } = await import("./SessionSidebar.tsx");

const UNREAD_KEY = "omp-web:unread-session-ids";
const CHECK = "Finished — not opened yet";
const PROJECT = "/work/alpha";

function session(id, firstMessage, minutesAgo) {
const at = new Date(Date.now() - minutesAgo * 60_000).toISOString();
return { path: `${PROJECT}/${id}.jsonl`, id, cwd: PROJECT, projectRoot: PROJECT, created: at, modified: at, messageCount: 2, firstMessage };
}
const SESSIONS = [
session("s-bg", "Background task", 1),
session("s-open", "Open task", 2),
session("s-seen", "Seen task", 3),
];
/** What /api/sessions serves; a test may swap it before mounting. */
let sessions = SESSIONS;

/** The tab side of the shared event-stream worker (lib/event-stream.ts), so a
* test can push `running` frames on the channel the sidebar opened. */
const eventStreams = new Map();
const eventWorker = {
onmessage: null,
onerror: null,
postMessage(message) {
if (message.op === "open") eventStreams.set(message.id, message.channel);
else if (message.op === "close") eventStreams.delete(message.id);
},
};
function deliverRunning(runningSessionIds) {
const id = [...eventStreams].findLast(([, channel]) => channel.kind === "running")?.[0];
assert.ok(id, "the sidebar must hold a running channel");
act(() => {
eventWorker.onmessage({ data: { id, type: "message", data: JSON.stringify({ type: "running", runningSessionIds, exitedSessions: [] }) } });
});
}

/** Responses still being consumed; drained before each test ends so no state
* update lands after the DOM globals are torn down. */
const inflight = new Set();
before(() => {
globalThis.Worker = function Worker() { return eventWorker; };
window.HTMLElement.prototype.scrollIntoView = () => {};
globalThis.fetch = (url) => {
const path = String(url).split("?")[0];
const body = path === "/api/sessions"
? { sessions, runningSessionIds: [] }
: path === "/api/projects" ? { projects: [{ path: PROJECT }] } : {};
const response = Promise.resolve(new Response(JSON.stringify(body), { status: 200, headers: { "Content-Type": "application/json" } }));
inflight.add(response);
void response.then(() => setTimeout(() => inflight.delete(response), 0));
return response;
};
});
afterEach(async () => {
await act(async () => {
while (inflight.size > 0) await new Promise((resolve) => setTimeout(resolve, 5));
});
cleanup();
localStorage.clear();
sessions = SESSIONS;
});

function Harness({ initialSelected }) {
const [selected, setSelected] = React.useState(initialSelected);
return React.createElement(SessionSidebar, {
selectedSessionId: selected,
onSelectSession: (s) => setSelected(s.id),
addProjectOpen: false,
setAddProjectOpen: () => {},
onOpenArchive: () => {},
skipInitialProjectSelection: true,
});
}

async function mount({ selected = null, unread } = {}) {
localStorage.setItem("omp-web:expanded-projects", JSON.stringify([PROJECT]));
if (unread) localStorage.setItem(UNREAD_KEY, JSON.stringify(unread));
render(React.createElement(Harness, { initialSelected: selected }));
await screen.findByText("Seen task");
}

const row = (title) => screen.getByText(title).closest(".session-item-row");
/** Any check mark in the row, whatever its label (main labelled it "Recently completed"). */
const hasCheck = (title) => row(title).querySelector("svg.lucide-check") !== null;

test("a session that finishes in the background shows the check until it is opened", async () => {
await mount();
deliverRunning(["s-bg"]);
assert.equal(hasCheck("Background task"), false, "running sessions show the spinner, not the check");
deliverRunning([]);
await waitFor(() => assert.equal(hasCheck("Background task"), true));
assert.ok(within(row("Background task")).getByLabelText(CHECK));
assert.deepEqual(JSON.parse(localStorage.getItem(UNREAD_KEY)), ["s-bg"]);

await userEvent.click(screen.getByText("Background task"));
await waitFor(() => assert.equal(hasCheck("Background task"), false));
assert.equal(localStorage.getItem(UNREAD_KEY), null, "opening it clears the persisted marker");
});

test("a session that finishes while it is open never shows the check", async () => {
await mount({ selected: "s-open" });
deliverRunning(["s-open"]);
deliverRunning([]);
await waitFor(() => assert.equal(localStorage.getItem(UNREAD_KEY), null));
assert.equal(hasCheck("Open task"), false);
});

test("recent but already seen sessions show no check and stay in the running-only filter", async () => {
await mount();
for (const title of ["Background task", "Open task", "Seen task"]) assert.equal(hasCheck(title), false, title);

await userEvent.click(screen.getByRole("button", { name: "Show running sessions only" }));
// Nothing runs, yet the recent-runs retention keeps the finished sessions listed.
assert.ok(screen.getByText("Seen task"));
assert.equal(hasCheck("Seen task"), false);
});

test("opening the session in another tab clears the check here", async () => {
await mount({ unread: ["s-bg"] });
assert.equal(hasCheck("Background task"), true);

localStorage.removeItem(UNREAD_KEY);
act(() => { window.dispatchEvent(new window.StorageEvent("storage", { key: UNREAD_KEY, oldValue: '["s-bg"]', newValue: null })); });
assert.equal(hasCheck("Background task"), false);
});

test("a check adopted from another tab skips the session open in this tab", async () => {
await mount({ selected: "s-open" });
localStorage.setItem(UNREAD_KEY, JSON.stringify(["s-bg", "s-open"]));
act(() => { window.dispatchEvent(new window.StorageEvent("storage", { key: UNREAD_KEY, newValue: '["s-bg","s-open"]' })); });
assert.equal(hasCheck("Background task"), true);
assert.equal(hasCheck("Open task"), false);
assert.deepEqual(JSON.parse(localStorage.getItem(UNREAD_KEY)), ["s-bg"], "the open session is written back as seen");
});
Comment thread
OrwellVII marked this conversation as resolved.
Resolved

test("a check another tab writes for the session open here alone is written back as seen", async () => {
await mount({ selected: "s-open" });
// This tab's set is empty, so dropping the open session changes no state here.
localStorage.setItem(UNREAD_KEY, JSON.stringify(["s-open"]));
act(() => { window.dispatchEvent(new window.StorageEvent("storage", { key: UNREAD_KEY, newValue: '["s-open"]' })); });
assert.equal(hasCheck("Open task"), false);
assert.equal(localStorage.getItem(UNREAD_KEY), null, "the other tab is told the open session is seen");
});

test("a nested child's check updates when only the child becomes unread", async () => {
sessions = [...SESSIONS, { ...session("s-child", "Child task", 0), parentSessionId: "s-bg" }];
await mount();
assert.equal(hasCheck("Child task"), false);
// Let every startup fetch land so only the unread set changes below.
await act(async () => {
while (inflight.size > 0) await new Promise((resolve) => setTimeout(resolve, 5));
});

localStorage.setItem(UNREAD_KEY, JSON.stringify(["s-child"]));
act(() => { window.dispatchEvent(new window.StorageEvent("storage", { key: UNREAD_KEY, newValue: '["s-child"]' })); });
await waitFor(() => assert.equal(hasCheck("Child task"), true));
assert.equal(hasCheck("Background task"), false, "the parent itself stays unmarked");
});
Loading