web: sticky sections, spotlight search, and live sync for other clients' prompts

- Sticky sections: a run/pipeline/template keeps the section you chose when you
  open another one, and the choice persists across reloads (localStorage per
  destination). A stage deep link still opens the Graph.
- Search is a Spotlight: a modal overlay opened with Ctrl+/ (Cmd+/ too), arrow keys
  move the selected result, Enter opens it, the query/kind/sort/selection resume on
  the next open, and an artifact result opens the artifact itself (media in the
  viewer, anything else in a tab) instead of the run's visit pane.
- Live sync: the server only emits a user frame for prompts sent through it, so a
  message typed in the OpenCode UI appeared only after a refresh. When a frame for
  an unknown turn arrives, the open conversation now reads the newest history once,
  which brings the user message in live.
This commit is contained in:
2026-10-19 20:45:39 +01:00
parent a7991077d2
commit ff45c0ec86
6 changed files with 261 additions and 35 deletions
+23
View File
@@ -576,8 +576,31 @@ function onChatEvent(frame) {
if (!sessionId || !state.chatThreads.has(sessionId)) return;
markBackgroundChatUnseen(sessionId);
const thread = state.chatThreads.get(sessionId);
const messageId = String(frame?.message_id ?? "");
// The user turn of a prompt sent from another client (the OpenCode UI, not this
// page) never reaches the broker, so no `user` frame exists for it: only the
// assistant's frames arrive. When the first frame of an unknown turn arrives,
// read the newest history once so the user message (and anything else the page
// missed) appears without a manual refresh.
const knownTurn = messageId !== "" && (thread.messages ?? []).some((m) => m?.id === messageId);
state.chatThreads.set(sessionId, applyChatEvent(thread, frame, Date.now()));
renderContent();
if (!knownTurn) scheduleHistorySync(sessionId, messageId);
}
/** At most one history read per unseen turn, and only for the open conversation. */
const historySyncTimers = new Map();
const historySyncedFor = new Map();
function scheduleHistorySync(sessionId, messageId) {
if (!messageId || sessionId !== state.chatActiveId) return;
if (historySyncedFor.get(sessionId) === messageId) return;
historySyncedFor.set(sessionId, messageId);
if (historySyncTimers.has(sessionId)) return;
const timer = setTimeout(() => {
historySyncTimers.delete(sessionId);
loadChatHistory(sessionId).catch(() => {});
}, 250);
historySyncTimers.set(sessionId, timer);
}
/**