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
38 changes: 38 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ app/api/
sessions/search/route.ts GET ?q= — NDJSON { scores } batches (titles + transcripts); closing the request stops the scan
sessions/[id]/route.ts GET/PATCH/DELETE session
sessions/[id]/context/route.ts GET ?leafId= — context for a specific leaf
sessions/[id]/matches/route.ts GET ?q=&limit= — best `limit` search hits in the active conversation (best match, then newest); Load more asks for a longer prefix
sessions/[id]/export/route.ts GET exported HTML for a session
agent/new/route.ts POST { cwd, message, toolNames?, provider?, modelId? }
agent/[id]/route.ts GET state | POST any RPC command
Expand Down Expand Up @@ -176,6 +177,8 @@ lib/
session-reader.ts session .jsonl parsing + path cache + buildSessionContext
session-search.ts shared fuzzy/phrase query scorer for sidebar search (title weights ≫ transcript)
session-content-search.ts server: per-file transcript text cache (size+mtime) + searchSessions()
session-search-matches.ts shared types/constants of the sidebar's per-session search hits
session-match-listing.ts server: lists a session's search hits counted per rendered text node (remark parse)
session-resume.ts running-session list for auto-resume after a restart
web-auth.ts password-hash check + session cookie signing
web-auth-secret.ts per-installation session-signing key (~/.omp/agent/omp-web/web-auth-secret.json)
Expand All @@ -197,6 +200,7 @@ components/
ChatInput.tsx input bar + model/thinking/tools/compact controls
ComposerPanels.tsx composer-attached /btw + todo + subagent panels (collapsible, live states)
BtwPanel.tsx /btw side-question panel (stream, cancel, copy, follow-up) + history dialog
SessionSearchMatches.tsx a search result's hits under its sidebar row (10 at a time + "Load more…")
TodoList.tsx todo phase grid with preview/show-all (used by ComposerPanels)
SubagentTranscriptDialog.tsx task + final output summary dialog (wide, screen-adaptive)
MessageView.tsx renders one message (user/assistant/toolCall/toolResult)
Expand Down Expand Up @@ -233,6 +237,7 @@ hooks/
useNavigationHistory.ts in-app back/forward stack (record/peek/commit/drop) for visited chat views
useWordPrediction.ts debounced omp predict_word ghost text + feedback
useBtw.ts /btw records/active panel/history dialog fed by btw_* SSE frames
useChatSearchHighlights.ts find-in-page for the sidebar search: CSS Custom Highlight API paint + jump to a picked hit

bin/
bun-runtime.js resolves the Bun binary (npm `@oven/bun-*`, else PATH, minimum version check); used by the launcher, scripts and nix
Expand Down Expand Up @@ -1030,6 +1035,39 @@ during the wait.
- Programmatic smooth scrolling must respect `prefers-reduced-motion`
(`usePrefersReducedMotion` in `hooks/usePrefersReducedMotion.ts` — also the
only way to stop SVG SMIL animations, which CSS cannot).
- A jump to a sidebar search hit calls `holdScrollPosition()` (`useAgentSession`):
it marks the initial scroll done and stops following, as a manual scroll-up
would, so the next frame does not pull the reader back to the bottom.

### Search hits in the chat (`/api/sessions/[id]/matches`, `hooks/useChatSearchHighlights.ts`)
- While the sidebar search has a query, each session row's chevron lists its
hits (`SessionSearchMatches`, 10 at a time). The server ranks hits of the
active conversation's user text and assistant text blocks (quality, then
newest message) and builds snippets for the returned hits only. "Load more"
asks for a longer prefix (`limit`), never an offset: a running session
re-ranks between requests, so offsets would repeat or skip hits.
- A hit is addressed as `(entryId, ordinal)`: its index among that message's
hits, counted per rendered text node in rendered order on both sides. The
server (`lib/session-match-listing.ts`) parses each body that has a hit in its
source (a user message's text blocks joined with `\n`, each assistant text
block separately) with the chat's remark parser and counts in text, inline
code and code nodes; link targets, image alt text, raw HTML and math render
no searchable text, and footnote definitions come last in reference order.
The chat counts in the rendered `[data-message-text][data-entry-id]` text,
skipping code-block headers, buttons, line numbers, KaTeX, Mermaid notes,
table charts and generated footnote labels (`NOT_MESSAGE_TEXT`). New chrome
inside message text must be excluded there too, and new markdown syntax
that renders text must be counted in `renderedTextNodes`, or later ordinals
shift. Known gaps: a phrase across syntax-highlighting tokens or a linked
`#123`/`agent://` ref, and block-level raw HTML; the jump then lands near it.
- Painting uses the CSS Custom Highlight API (`omp-search`,
`omp-search-current` in `globals.css`), repainted on DOM mutations; browsers
without it still jump. A jump widens the lazy render window
(`revealMessage`) first. Each click is a new target object used once:
`onSearchTargetHandled` drops it in AppShell, so reopening the session later
does not jump again. AppShell also drops a pending target when the query
changes or another session opens, and the hook drops one whose entry the
loaded branch lacks. An empty query clears the highlights and the target.

### MCP configuration (`lib/omp/mcp-config.ts`, `/api/mcp`, `components/McpConfig.tsx`)
- Project MCP config resolution order: `.omp/mcp.json`, `.omp/.mcp.json`,
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f
- **Binary prereleases from `main`.** Each commit on `main` that passes CI is published as a GitHub prerelease titled with its build time in ISO 8601 UTC (for example `2026-11-01T10:30:00Z`; tag `20261101T103000Z-<short sha>`) with the five single-binary archives. Prereleases are never marked latest, publish no npm package and trigger no update notice.
- **Settings → Hosts shows link protocol versions.** Each host shows the link protocol version its daemon speaks, and the page shows the version this web app expects.
- **Keep a host running with the single binary.** The README's "Keep a host running as a service" section has a systemd user unit (Linux), a logon scheduled task (Windows) and, for macOS, a restart script to run in tmux: launchd jobs cannot use the login keychain and SSH agent that omp sessions need. In tmux, macOS Local Network privacy blocks the daemon from LAN addresses, so link it to a URL that does not resolve to one (the server's public URL, or a VPN or tailnet name).
- **Session search shows where each session matched.** While searching the sidebar, the arrow beside a session lists its matches one per line, best match first and newest first among equals, ten at a time with **Load more…**. Matches in the messages of the open conversation are highlighted, typos and partial words included (thinking, tool output and math are not searched; link addresses and image descriptions do not count), and clicking a match opens its session, scrolls to it and marks it as the current one, like the browser's find. Closing or clearing the search removes the highlights. Browsers without the CSS Custom Highlight API (before Chrome 105, Safari 17.2 or Firefox 140) still jump to the match but do not paint it.

### Fixes & Improvements

Expand Down
41 changes: 41 additions & 0 deletions app/api/sessions/[id]/matches/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { apiErrorResponse, opErrorResponse, resolveSessionHostOr404 } from "@/lib/api-utils";
import { listSessionMatches } from "@/lib/session-match-listing";
import { MAX_SEARCH_MATCHES, SEARCH_MATCH_PAGE_SIZE } from "@/lib/session-search-matches";
import type { SessionContext } from "@/lib/types";

const MAX_QUERY_LENGTH = 500;

// GET /api/sessions/[id]/matches?q=&limit= — the query's best `limit` hits in the
// session's active conversation (what the chat shows), best match first. "Load more"
// asks for a longer prefix rather than the next offset: a running session re-ranks
// between requests, and an offset would then repeat or skip hits.
// shortcut: re-reads and re-ranks the whole session per request; cache per (session, query) if that gets slow.
export async function GET(req: Request, { params }: { params: Promise<{ id: string }> }) {
const { id } = await params;
const url = new URL(req.url);
const q = url.searchParams.get("q") ?? "";
if (q.length > MAX_QUERY_LENGTH) {
return Response.json({ error: "Query too long", code: "query_too_long" }, { status: 400 });
}
const rawLimit = url.searchParams.get("limit") ?? String(SEARCH_MATCH_PAGE_SIZE);
const limit = Number(rawLimit);
if (!/^[1-9]\d{0,3}$/.test(rawLimit) || limit > MAX_SEARCH_MATCHES) {
return Response.json({ error: "Invalid limit", code: "invalid_limit" }, { status: 400 });
}
try {
const resolved = await resolveSessionHostOr404(id);
if ("response" in resolved) return resolved.response;
const result = await resolved.host.sessionOps.readContext(id, undefined, {
deferThinking: true,
deferMedia: true,
includePreCompaction: false,
boundary: false,
sync: null,
});
if (!result.ok) return opErrorResponse(result);
const { context } = result.value as { context: SessionContext };
return Response.json(listSessionMatches(context.messages, context.entryIds, q, limit), { headers: { "Cache-Control": "no-store" } });
} catch (error) {
return apiErrorResponse(error);
}
}
18 changes: 18 additions & 0 deletions app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -4716,3 +4716,21 @@ html[data-touch-targets="accessible"] .extension-dialog-footer > button {
@media (prefers-reduced-motion: reduce) { .mcp-spin { animation: none; } .mcp-management * { transition: none !important; } }

.settings-card.mcp-source-card, .settings-card.mcp-other-configs, .settings-card.mcp-editor-card { display: block; padding: 0; margin-bottom: 0; }

/* Sidebar search hits in the chat (CSS Custom Highlight API, set by
useChatSearchHighlights) and in the sidebar's match list. */
::highlight(omp-search),
.session-search-match-hit {
background-color: color-mix(in srgb, var(--status-warning) 32%, transparent);
color: inherit;
}
::highlight(omp-search-current) {
background-color: var(--status-warning);
color: var(--bg);
}
.session-search-match {
background: none;
}
.session-search-match:hover:not(:disabled) {
background: var(--bg-hover);
}
21 changes: 21 additions & 0 deletions components/AppShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import { isMacPlatform, navigateShortcutHint, NAVIGATION_HISTORY_MAX_ENTRIES } from "@/lib/navigation-history";
import { useMobileSidebarGestures } from "@/hooks/useMobileSidebarGestures";
import { SessionSidebar } from "./SessionSidebar";
import type { SearchMatchTarget } from "./SessionSearchMatches";
import type { WorktreeContext } from "./SessionSidebar-helpers";
import { ToastProvider } from "./ui/toast";
import { toast } from "./ui/toast";
Expand Down Expand Up @@ -340,7 +341,7 @@
if (container && active instanceof HTMLElement && container.contains(active)) {
active.blur();
}
}, [sidebarOpen, mobileSidebarReady]);

Check warning on line 344 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

Check warning on line 344 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
useEffect(() => {
const controller = new AbortController();
void fetch("/api/omp-update", {
Expand Down Expand Up @@ -856,7 +857,7 @@
sidebarResizeHandlersRef.current = { onMove, onUp };
window.addEventListener("mousemove", onMove);
window.addEventListener("mouseup", onUp);
}, [isMobile, sidebarWidth]);

Check warning on line 860 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

Check warning on line 860 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

// 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 @@ -873,7 +874,7 @@
const resetRightPanelWidth = useCallback(() => {
rightPanelRef.current?.style.removeProperty("--right-panel-width");
setRightPanelWidth(null);
}, []);

Check warning on line 877 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

Check warning on line 877 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

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

Check warning on line 888 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

Check warning on line 888 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

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

Check warning on line 949 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

Check warning on line 949 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

// 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 @@ -1825,6 +1826,21 @@
return () => observer.disconnect();
}, [windowTitle]);

// The sidebar search drives the chat's find-in-page highlights.
const [chatSearchQuery, setChatSearchQuery] = useState("");
// One jump per click: dropped once the chat used it, so reopening that session later starts at the bottom.
const [searchMatchTarget, setSearchMatchTarget] = useState<SearchMatchTarget | null>(null);
const clearSearchMatchTarget = useCallback(() => setSearchMatchTarget(null), []);
// The sidebar reports only changes: a pending target belongs to the query it was picked under.
const handleSearchQueryChange = useCallback((query: string) => {
setChatSearchQuery(query);
setSearchMatchTarget(null);
}, []);
// A target still pending when another session opens must not jump when its own session reopens.
useEffect(() => {
setSearchMatchTarget((target) => (target && target.sessionId !== selectedSession?.id ? null : target));
}, [selectedSession?.id]);

const sidebarContent = (
<SessionSidebar
selectedSessionId={selectedSession?.id ?? null}
Expand All @@ -1851,6 +1867,8 @@
navigation={sidebarNavigation}
updateAvailable={Boolean(appUpdate?.updateAvailable) || ompUpdateAvailable}
onClose={isMobile ? handleSidebarToggle : undefined}
onSearchQueryChange={handleSearchQueryChange}
onOpenSearchMatch={setSearchMatchTarget}
/>
);

Expand Down Expand Up @@ -2578,6 +2596,9 @@
hideToolActivity={hideToolActivity}
expandThinkingByDefault={expandThinkingByDefault}
hideThinkingBlock={hideThinkingBlock}
searchQuery={chatSearchQuery}
searchTarget={searchMatchTarget && searchMatchTarget.sessionId === selectedSession?.id ? searchMatchTarget : null}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
onSearchTargetHandled={clearSearchMatchTarget}
/>
) : initialCwdStatus === "validating" ? (
<WorkspaceState
Expand Down
31 changes: 29 additions & 2 deletions components/ChatWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { CHAT_COLUMN_MAX_WIDTH, MINIMAP_WIDTH } from "@/lib/chat-layout";
import { WorkspaceState } from "./AppShell-layout";
import { useAgentSession, type AgentPhase, type NoticeItem, type SubagentInfo } from "@/hooks/useAgentSession";
import { useAudio } from "@/hooks/useAudio";
import { useChatSearchHighlights } from "@/hooks/useChatSearchHighlights";
import type { SearchMatchTarget } from "./SessionSearchMatches";
import { useSpeechSynthesis, SpeechSynthesisProvider } from "@/hooks/useSpeechSynthesis";
import { GithubRepoContext } from "@/lib/github-refs";
import { useDragDrop } from "@/hooks/useDragDrop";
Expand Down Expand Up @@ -77,6 +79,12 @@ interface Props {
onGenerationSpeedChange?: (speed: GenerationSpeedInfo | null) => void;
/** Open Settings → API Keys & Providers (from the model picker). */
onOpenProviders?: () => void;
/** The sidebar search query: its hits are highlighted ("" for none). */
searchQuery?: string;
/** A hit picked in the sidebar for this session: scrolled to and marked current. */
searchTarget?: SearchMatchTarget | null;
/** The target was used; the owner drops it so a later remount does not jump again. */
onSearchTargetHandled?: () => void;
}

function phaseLabel(phase: AgentPhase): string {
Expand Down Expand Up @@ -479,7 +487,7 @@ const CommittedTranscript = memo(function CommittedTranscript({
);
});

export function ChatWindow({ session, newSessionCwd, newSessionHostId, hostStatus: channelHostStatus, hostLabel, newSessionWorkspace, toolCallsDefaultCollapsed = true, hideToolActivity = true, expandThinkingByDefault = false, hideThinkingBlock = false, onAgentEnd, onSessionCreated, onSessionForked, onSessionMoved, modelsRefreshKey, chatInputRef, sessionInfoContainer, onBranchDataChange, onSystemPromptChange, onSystemPromptLoaderChange, onSessionStatsChange, onSessionStatsPanelOpen, onProviderUsageContextChange, onGenerationSpeedChange, onOpenFile, onOpenUrl, onOpenProviders }: Props) {
export function ChatWindow({ session, newSessionCwd, newSessionHostId, hostStatus: channelHostStatus, hostLabel, newSessionWorkspace, toolCallsDefaultCollapsed = true, hideToolActivity = true, expandThinkingByDefault = false, hideThinkingBlock = false, onAgentEnd, onSessionCreated, onSessionForked, onSessionMoved, modelsRefreshKey, chatInputRef, sessionInfoContainer, onBranchDataChange, onSystemPromptChange, onSystemPromptLoaderChange, onSessionStatsChange, onSessionStatsPanelOpen, onProviderUsageContextChange, onGenerationSpeedChange, onOpenFile, onOpenUrl, onOpenProviders, searchQuery = "", searchTarget = null, onSearchTargetHandled }: Props) {
const { t, tn } = useI18n();
const { playDoneSound, unlockAudio } = useAudio();
const isMobile = useIsMobile();
Expand Down Expand Up @@ -535,7 +543,7 @@ export function ChatWindow({ session, newSessionCwd, newSessionHostId, hostStatu
liveToolResults,
subagents, subagentEvents, subagentTranscriptVersions, activeSubagentCount, currentTodoPhase, todoPhases,
isNew, hostStatus: frameHostStatus,
sessionIdRef, messagesEndRef, scrollContainerRef,
sessionIdRef, messagesEndRef, scrollContainerRef, holdScrollPosition,
handleSend, handleAbort, handleFork, handleEdit, handleModelChange, retrySession,
handleSteer, handleFollowUp, handlePromptWithStreamingBehavior, handleAbortCompaction, handleCompact,
removeQueuedMessage, promoteQueuedToSteer,
Expand Down Expand Up @@ -701,6 +709,25 @@ export function ChatWindow({ session, newSessionCwd, newSessionHostId, hostStatu
// The empty new-session screen has its own scroller, so the conversation's
// scroller mounts after the first send without a remount or a load.
const isEmptyNew = isNew && messages.length === 0 && !streamState.isStreaming && !sessionBusy;
// Widen the lazy render window until it includes the message's transcript row.
const revealMessage = useCallback((messageIndex: number) => {
const rows = planTranscriptRows(messages, { hideThinking: hideThinkingBlock });
const rowIndex = rows.findIndex((row) => (row.kind === "message" ? row.index === messageIndex : messageIndex >= row.userIndex && messageIndex < row.endIndex));
const needed = rows.length - Math.max(0, rowIndex);
if (needed <= visibleCount) return true;
setVisibleCount(needed);
return false;
}, [messages, hideThinkingBlock, visibleCount]);
useChatSearchHighlights({
container: scrollContainerRef,
query: searchQuery,
target: searchTarget,
ready: !loading && !isEmptyNew,
entryIds,
revealMessage,
holdScrollPosition,
onTargetHandled: onSearchTargetHandled,
});
const remoteWorkspace = session ? remoteHostId(session.hostId) !== undefined : newSessionHostId !== undefined;
// The hosts channel is the source of truth; a frame only speaks before its first snapshot.
const currentHostStatus = channelHostStatus ?? frameHostStatus;
Expand Down
Loading
Loading