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
10 changes: 10 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,16 @@ The table is static imports, not a runtime glob, so `bun build --compile` (`scri
(`confirmFromServer`). Local callers never ask for this machine. A remote
caller asks before any other host unless that host allows agent starts, and
always before this machine, for `new_session` and `send_to_session` alike.
- **Message origin.** Messages created by `send_to_session`, a `new_session`
first prompt, or the GitHub watcher remain native user messages for model
authority, but carry server-authored `origin` metadata. The runner stores it
in the existing `client-message-entry` correlation journal; the reader joins
it only on the active branch, and the outbox stores it beside held entries.
Browser/HTTP commands cannot supply `origin` (`origin_not_allowed`), and
readers drop malformed or over-4096-byte metadata. The chat renders trusted
origins as left-aligned source cards; matching text without metadata remains
an ordinary user bubble. Older runners ignore the optional command field and
show the explicit model-facing source header as plain text.
- **Workspace operations are daemon-owned** (`lib/workspace-types.ts`,
`lib/hosts/workspace-ops.ts`; design `docs/specs/2026-11-03-remote-workspaces-design.md`).
Files/index/shell output/watch, Git/worktrees, browsing/default cwd and clone
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f
### Added

- **Race-free GitHub watch registration.** `watch_github` returns the metadata snapshot used as a new watch's baseline, so agents can inspect existing comments, reviews, threads and CI before relying on later watch updates.
- **Clearly attributed automated messages.** Cross-session agent-tool messages and GitHub watcher updates now render as source-labelled cards instead of looking like messages typed by the user. Attribution is server-authored, survives queues, retries and reloads, and links to the source session or GitHub item.

## [v0.7.1] - 2026-11-14

Expand Down
88 changes: 51 additions & 37 deletions components/AppShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import { normalizeLocalPath } from "@/lib/file-links";
import type { WorkspaceFileSource } from "@/lib/workspace-types";
import { buildAtMentionText, buildFileAtMentionsText, buildFileLineMentionText } from "@/lib/file-fuzzy";
import { getInitialNavigation } from "@/lib/initial-navigation";
import { findSessionTarget, getInitialNavigation, sameSessionTarget, sessionNavigationUrl } from "@/lib/initial-navigation";
import { comparableProjectPath } from "@/lib/comparable-path";
import { foldedHostProjectKey, hostProjectKey, LOCAL_HOST_ID, remoteHostId, projectIdentity, projectTargetId } from "@/lib/project-ordering";
import { isClusterTarget } from "@/lib/hosts/cluster";
Expand Down Expand Up @@ -390,7 +390,7 @@
if (container && active instanceof HTMLElement && container.contains(active)) {
active.blur();
}
}, [sidebarOpen, mobileSidebarReady]);

Check warning on line 393 in components/AppShell.tsx

View workflow job for this annotation

GitHub Actions / Verify (macos-latest)

React Hook useLayoutEffect has a missing dependency: 'sidebarContainerRef'. Either include it or remove the dependency array

Check warning on line 393 in components/AppShell.tsx

View workflow job for this annotation

GitHub Actions / Verify (ubuntu-latest)

React Hook useLayoutEffect has a missing dependency: 'sidebarContainerRef'. Either include it or remove the dependency array

Check warning on line 393 in components/AppShell.tsx

View workflow job for this annotation

GitHub Actions / Verify (windows-latest)

React Hook useLayoutEffect has a missing dependency: 'sidebarContainerRef'. Either include it or remove the dependency array
const refreshAppUpdate = useCallback(async (force = false, autoOpen = false): Promise<AppUpdateInfo | null> => {
const data = await fetchAppUpdateJson<AppUpdateInfo>(
force ? "/api/app-update?force=1" : "/api/app-update",
Expand Down Expand Up @@ -769,14 +769,20 @@
const [sessionStats, setSessionStats] = useState<SessionStatsInfo | null>(null);
const [autoNameStatus, setAutoNameStatus] = useState<AutoNameStatus>({ kind: "idle" });
const autoNameTimerRef = useRef<TimerHandle | undefined>(undefined);
const activeSessionIdRef = useRef<string | null>(selectedSession?.id ?? null);
const activeSelectedSessionId = selectedSession?.id ?? null;
const activeSelectedSessionHostId = selectedSession?.hostId;
const activeSessionIdRef = useRef<string | null>(activeSelectedSessionId);
const activeSessionTargetRef = useRef<{ id: string; hostId?: string } | null>(
activeSelectedSessionId ? { id: activeSelectedSessionId, hostId: activeSelectedSessionHostId } : null,
);
const activeSettingsTabRef = useRef(settingsTab);
const archiveRetryTimerRef = useRef<TimerHandle | undefined>(undefined);
useEffect(() => () => clearTimeout(archiveRetryTimerRef.current), []);
useLayoutEffect(() => {
activeSessionIdRef.current = selectedSession?.id ?? null;
activeSessionIdRef.current = activeSelectedSessionId;
activeSessionTargetRef.current = activeSelectedSessionId ? { id: activeSelectedSessionId, hostId: activeSelectedSessionHostId } : null;
activeSettingsTabRef.current = settingsTab;
}, [selectedSession?.id, settingsTab]);
}, [activeSelectedSessionId, activeSelectedSessionHostId, settingsTab]);
const handleSessionStatsChange = useCallback((stats: SessionStatsInfo | null) => {
setSessionStats(stats);
}, []);
Expand Down Expand Up @@ -925,7 +931,7 @@
sidebarResizeHandlersRef.current = { onMove, onUp };
window.addEventListener("mousemove", onMove);
window.addEventListener("mouseup", onUp);
}, [isMobile, sidebarWidth]);

Check warning on line 934 in components/AppShell.tsx

View workflow job for this annotation

GitHub Actions / Verify (macos-latest)

React Hook useCallback has a missing dependency: 'sidebarContainerRef'. Either include it or remove the dependency array

Check warning on line 934 in components/AppShell.tsx

View workflow job for this annotation

GitHub Actions / Verify (ubuntu-latest)

React Hook useCallback has a missing dependency: 'sidebarContainerRef'. Either include it or remove the dependency array

Check warning on line 934 in components/AppShell.tsx

View workflow job for this annotation

GitHub Actions / Verify (windows-latest)

React Hook useCallback has a missing dependency: 'sidebarContainerRef'. Either include it or remove the dependency array

// If the app unmounts mid-drag, remove the window listeners and restore the
// body cursor; otherwise the handlers leak and body stays cursor:col-resize.
Expand All @@ -942,7 +948,7 @@
const resetRightPanelWidth = useCallback(() => {
rightPanelRef.current?.style.removeProperty("--right-panel-width");
setRightPanelWidth(null);
}, []);

Check warning on line 951 in components/AppShell.tsx

View workflow job for this annotation

GitHub Actions / Verify (macos-latest)

React Hook useCallback has a missing dependency: 'rightPanelRef'. Either include it or remove the dependency array

Check warning on line 951 in components/AppShell.tsx

View workflow job for this annotation

GitHub Actions / Verify (ubuntu-latest)

React Hook useCallback has a missing dependency: 'rightPanelRef'. Either include it or remove the dependency array

Check warning on line 951 in components/AppShell.tsx

View workflow job for this annotation

GitHub Actions / Verify (windows-latest)

React Hook useCallback has a missing dependency: 'rightPanelRef'. Either include it or remove the dependency array

const changeRightPanelWidth = useCallback((delta: number) => {
setRightPanelWidth((prev) => {
Expand All @@ -953,7 +959,7 @@
rightPanelRef.current?.style.setProperty("--right-panel-width", `${next}px`);
return next;
});
}, []);

Check warning on line 962 in components/AppShell.tsx

View workflow job for this annotation

GitHub Actions / Verify (macos-latest)

React Hook useCallback has a missing dependency: 'rightPanelRef'. Either include it or remove the dependency array

Check warning on line 962 in components/AppShell.tsx

View workflow job for this annotation

GitHub Actions / Verify (ubuntu-latest)

React Hook useCallback has a missing dependency: 'rightPanelRef'. Either include it or remove the dependency array

Check warning on line 962 in components/AppShell.tsx

View workflow job for this annotation

GitHub Actions / Verify (windows-latest)

React Hook useCallback has a missing dependency: 'rightPanelRef'. Either include it or remove the dependency array

const handleRightPanelResizeKey = useCallback((e: React.KeyboardEvent) => {
// The handle sits on the panel's left edge: left widens, right narrows.
Expand Down Expand Up @@ -1022,7 +1028,7 @@
rightResizeHandlersRef.current = { onMove, onUp, cancelFrame };
window.addEventListener("mousemove", onMove);
window.addEventListener("mouseup", onUp);
}, [isMobile]);

Check warning on line 1031 in components/AppShell.tsx

View workflow job for this annotation

GitHub Actions / Verify (macos-latest)

React Hook useCallback has a missing dependency: 'rightPanelRef'. Either include it or remove the dependency array

Check warning on line 1031 in components/AppShell.tsx

View workflow job for this annotation

GitHub Actions / Verify (ubuntu-latest)

React Hook useCallback has a missing dependency: 'rightPanelRef'. Either include it or remove the dependency array

Check warning on line 1031 in components/AppShell.tsx

View workflow job for this annotation

GitHub Actions / Verify (windows-latest)

React Hook useCallback has a missing dependency: 'rightPanelRef'. Either include it or remove the dependency array

// If the app unmounts mid-drag, remove the window listeners and restore the
// body cursor; otherwise the handlers leak and body stays cursor:col-resize.
Expand Down Expand Up @@ -1315,7 +1321,7 @@
setSidebarOpen(false);
requestAnimationFrame(() => chatInputRef.current?.focus());
}
if (!isRestore && session.id === selectedSession?.id) return;
if (!isRestore && selectedSession && sameSessionTarget(session, selectedSession)) return;
setNewSessionCwd(null);
setNewSessionPoolProject(null);
setSelectedSession(session);
Expand All @@ -1333,9 +1339,9 @@
}
// Skip router.replace when restoring from the URL: the param is already correct.
if (!isRestore) {
router.replace(`?session=${encodeURIComponent(session.id)}`);
router.replace(sessionNavigationUrl(session));
}
}, [router, isMobile, selectedSession?.id]);
}, [router, isMobile, selectedSession]);

const handleNewSession = useCallback((creationId: string, cwd: string | null, hostId?: string, project?: ManagedProject, initialization?: string) => {
setSettingsTab(null);
Expand Down Expand Up @@ -1374,27 +1380,28 @@
const navViewVersionRef = useRef(0);
const navSessionId = selectedSession?.id ?? null;
const navSessionCwd = selectedSession?.cwd ?? null;
const navHostId = navSessionId ? remoteHostId(selectedSession?.hostId) : newSessionHostId;
useEffect(() => {
navViewVersionRef.current += 1;
recordNavigationView({
sessionId: navSessionId,
cwd: navSessionId ? navSessionCwd : newSessionCwd,
...(!navSessionId && newSessionHostId ? { hostId: newSessionHostId } : {}),
...(navHostId ? { hostId: navHostId } : {}),
...(!navSessionId && newSessionPoolProject ? { poolId: newSessionPoolProject.poolId, projectId: newSessionPoolProject.projectId } : {}),
...(!navSessionId ? { creationId: newSessionCreationId } : {}),
...(!navSessionId && newSessionPoolProject && newSessionCreation.initialization ? { initialization: newSessionCreation.initialization } : {}),
});
}, [navSessionId, navSessionCwd, newSessionCwd, newSessionHostId, newSessionPoolProject, newSessionCreation, newSessionCreationId, recordNavigationView]);
}, [navSessionId, navSessionCwd, navHostId, newSessionCwd, newSessionPoolProject, newSessionCreation, newSessionCreationId, recordNavigationView]);

// Resolves a history entry's session id against the live list. `null`
// means the id is gone (entry should be dropped); "unavailable" means the
// list itself could not be fetched (keep the entry, abort this navigation).
const fetchSessionForNavigation = useCallback(async (sessionId: string): Promise<SessionInfo | null | "unavailable"> => {
const fetchSessionForNavigation = useCallback(async (sessionId: string, hostId?: string): Promise<SessionInfo | null | "unavailable"> => {
try {
const res = await fetch(`/api/sessions?id=${encodeURIComponent(sessionId)}`);
if (!res.ok) return "unavailable";
const data = (await res.json()) as { sessions?: SessionInfo[] };
return data.sessions?.find((s) => s.id === sessionId) ?? null;
return data.sessions?.find((session) => sameSessionTarget(session, { id: sessionId, hostId })) ?? null;
} catch {
return "unavailable";
}
Expand All @@ -1418,7 +1425,7 @@
return;
}
const versionAtPress = navViewVersionRef.current;
const session = await fetchSessionForNavigation(entry.sessionId);
const session = await fetchSessionForNavigation(entry.sessionId, entry.hostId);
if (navViewVersionRef.current !== versionAtPress) return; // user moved on: do nothing
if (session === "unavailable") return; // list fetch failed: keep the entry, try again next press
if (session) {
Expand Down Expand Up @@ -1468,13 +1475,14 @@
// server-computed projectRoot, which the same-project check in
// handleCwdChange relies on. Hydrate it from the session list so switching
// worktrees right after creating a session doesn't close the chat.
const hydrateSelectedSession = useCallback((sessionId: string) => {
const hydrateSelectedSession = useCallback((sessionId: string, hostId?: string) => {
const target = { id: sessionId, hostId };
void fetch("/api/sessions")
.then((r) => (r.ok ? (r.json() as Promise<{ sessions: SessionInfo[] }>) : null))
.then((d) => {
const full = d?.sessions.find((s) => s.id === sessionId);
const full = findSessionTarget(d?.sessions ?? [], target);
if (!full) return;
setSelectedSession((prev) => (prev && prev.id === sessionId && (!prev.projectRoot || prev.path === "") ? full : prev));
setSelectedSession((prev) => (prev && sameSessionTarget(prev, target) && (!prev.projectRoot || prev.path === "") ? full : prev));
})
.catch(() => {});
}, []);
Expand All @@ -1485,43 +1493,46 @@
setNewSessionPoolProject(null);
setSelectedSession(session);
setRefreshKey((k) => k + 1);
hydrateSelectedSession(session.id);
router.replace(`?session=${encodeURIComponent(session.id)}`);
hydrateSelectedSession(session.id, session.hostId);
router.replace(sessionNavigationUrl(session));
}, [router, hydrateSelectedSession]);

const handleSessionMoved = useCallback((oldId: string, newId: string) => {
if (activeSessionIdRef.current !== oldId) return;
const hostId = activeSelectedSessionHostId;
activeSessionIdRef.current = newId;
setSelectedSession((current) => current?.id === oldId ? { ...current, id: newId, path: "" } : current);
activeSessionTargetRef.current = { id: newId, hostId };
setSelectedSession((current) => current && sameSessionTarget(current, { id: oldId, hostId }) ? { ...current, id: newId, path: "" } : current);
setRefreshKey((key) => key + 1);
hydrateSelectedSession(newId);
hydrateSelectedSession(newId, hostId);
// This is the same conversation. Preserve ChatWindow's run/edit fences
// and its mounted composer, including unfinished attachments and audio.
router.replace(`?session=${encodeURIComponent(newId)}`);
}, [router, hydrateSelectedSession]);
router.replace(sessionNavigationUrl({ id: newId, hostId }));
}, [router, hydrateSelectedSession, activeSelectedSessionHostId]);

const handleAgentEnd = useCallback(() => {
setRefreshKey((k) => k + 1);
setExplorerRefreshKey((k) => k + 1);
}, []);

// Notification clicks name a session id; the session list carries its cwd
// and project, which selecting needs. When the list cannot be read (the
// sign-in expired), load the session URL: sign-in carries it through.
const openSessionById = useCallback((sessionId: string) => {
// Session links and notification clicks name a session id; links may also
// carry its host so copied IDs on different machines stay distinct.
const openSessionById = useCallback((sessionId: string, hostId?: string) => {
window.focus();
// On narrow screens the file panel covers the chat it is about to show.
if (isCompactOverlay) setRightPanelOpen(false);
// A full load (not router navigation) so an expired sign-in reaches proxy.ts and the login page.
const sessionUrl = new URL(`/?session=${encodeURIComponent(sessionId)}`, window.location.origin).href;
const query = `/?session=${encodeURIComponent(sessionId)}${hostId ? `&host=${encodeURIComponent(hostId)}` : ""}`;
const sessionUrl = new URL(query, window.location.origin).href;
void fetch("/api/sessions")
.then((r) => {
if (!r.ok) {
window.location.assign(sessionUrl);
return;
}
return (r.json() as Promise<{ sessions: SessionInfo[] }>).then((d) => {
const session = d.sessions.find((s) => s.id === sessionId);
const session = d.sessions.find((candidate) => candidate.id === sessionId
&& (!hostId || (candidate.hostId ?? "local") === hostId));
if (session) handleSelectSession(session);
else toast.error(translate("notifications.sessionNotFound"));
});
Expand All @@ -1533,8 +1544,9 @@
useNotifications({ sessionId: settingsTab ? null : selectedSession?.id ?? null, locale, onOpenSession: openSessionById });

const handleAutoName = useCallback(async () => {
const sessionId = selectedSession?.id;
if (!sessionId || autoNameStatus.kind === "naming") return;
if (!activeSelectedSessionId || autoNameStatus.kind === "naming") return;
const sessionId = activeSelectedSessionId;
const sessionTarget = { id: sessionId, hostId: activeSelectedSessionHostId };
clearTimeout(autoNameTimerRef.current);
setActiveTopPanel(null);
setAutoNameStatus({ kind: "naming" });
Expand All @@ -1549,24 +1561,24 @@
}

const title = body.title.trim();
if (activeSessionIdRef.current !== sessionId) return;
if (!activeSessionTargetRef.current || !sameSessionTarget(activeSessionTargetRef.current, sessionTarget)) return;
setRefreshKey((key) => key + 1);
setSelectedSession((current) => current?.id === sessionId ? { ...current, name: title } : current);
setSelectedSession((current) => current && sameSessionTarget(current, sessionTarget) ? { ...current, name: title } : current);
setSessionStats((current) => current?.sessionId === sessionId ? { ...current, sessionName: title } : current);
setAutoNameStatus({ kind: "success" });
autoNameTimerRef.current = setTimeout(() => setAutoNameStatus({ kind: "idle" }), 1800);
} catch (error) {
if (activeSessionIdRef.current !== sessionId) return;
if (!activeSessionTargetRef.current || !sameSessionTarget(activeSessionTargetRef.current, sessionTarget)) return;
const message = error instanceof Error ? error.message : String(error);
setAutoNameStatus({ kind: "error", message });
autoNameTimerRef.current = setTimeout(() => setAutoNameStatus({ kind: "idle" }), 5000);
}
}, [autoNameStatus.kind, selectedSession?.id]);
}, [autoNameStatus.kind, activeSelectedSessionId, activeSelectedSessionHostId]);

useEffect(() => {
clearTimeout(autoNameTimerRef.current);
setAutoNameStatus({ kind: "idle" });
}, [selectedSession?.id]);
}, [activeSelectedSessionId, activeSelectedSessionHostId]);

const handleExplorerRefresh = useCallback(() => {
setExplorerRefreshing(true);
Expand All @@ -1578,6 +1590,7 @@
}, []);

const handleSessionForked = useCallback((newSessionId: string) => {
const hostId = activeSelectedSessionHostId;
setRefreshKey((k) => k + 1);
setSessionKey((k) => k + 1);
setNewSessionCwd(null);
Expand All @@ -1589,9 +1602,9 @@
// fork shows up immediately instead of waiting for a refresh.
path: "",
}));
hydrateSelectedSession(newSessionId);
router.replace(`?session=${encodeURIComponent(newSessionId)}`);
}, [router, hydrateSelectedSession]);
hydrateSelectedSession(newSessionId, hostId);
router.replace(sessionNavigationUrl({ id: newSessionId, hostId }));
}, [router, hydrateSelectedSession, activeSelectedSessionHostId]);

const handleSessionDeleted = useCallback((sessionId: string) => {
// The composer for this session can never be reopened, so its draft would
Expand Down Expand Up @@ -2010,6 +2023,7 @@
onSelectSession={handleSelectSession}
onNewSession={handleNewSession}
initialSessionId={initialSessionId}
initialSessionHostId={initialNavigation.hostId}
skipInitialProjectSelection={initialNavigation.requestedCwd !== null}
onInitialRestoreDone={handleInitialRestoreDone}
refreshKey={refreshKey}
Expand Down
11 changes: 11 additions & 0 deletions components/ChatInput.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,22 @@ test("renders single queued prompt in compact bar", () => {
queuedMessages: {
followUp: ["First follow-up task"],
steering: [],
messageOrigins: {
followUp: [{
v: 1, kind: "session", sentAt: "2026-11-15T12:41:00.000Z",
session: {
id: "source", name: "Build session", hostId: "local", hostLabel: "This machine",
tool: "send_to_session", delivery: "followUp",
},
}],
steering: [],
},
},
}),
);

assert.match(html, /First follow-up task/);
assert.match(html, /\[From Build session\]/);
assert.match(html, />(Edit|chatInput\.queuedEdit)</);
assert.match(html, />(Delete|chatInput\.queuedDelete)</);
assert.match(html, />(Steer|chatInput\.queuedSteerAction)</);
Expand Down
Loading
Loading