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:
+32
-6
@@ -78,6 +78,29 @@ const repo = new PipelinesRepository(client);
|
||||
// configured value and the draft start from storage.
|
||||
const initialWorkspace = readWorkspace(localStorage);
|
||||
|
||||
/** The three detail section choices are sticky and survive a reload. */
|
||||
const SECTION_STORAGE_KEYS = {
|
||||
pipelines: "pipelines.web.pipelineTab.v1",
|
||||
runs: "pipelines.web.runTab.v1",
|
||||
templates: "pipelines.web.templateTab.v1",
|
||||
};
|
||||
|
||||
function readSection(key, fallback) {
|
||||
try {
|
||||
return localStorage.getItem(SECTION_STORAGE_KEYS[key]) || fallback;
|
||||
} catch {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
function writeSection(key, value) {
|
||||
try {
|
||||
localStorage.setItem(SECTION_STORAGE_KEYS[key], value);
|
||||
} catch {
|
||||
// Storage may be unavailable; the in-memory choice still applies.
|
||||
}
|
||||
}
|
||||
|
||||
const state = {
|
||||
view: "pipelines",
|
||||
url: readServerUrl(localStorage) || defaultServerUrl(),
|
||||
@@ -127,7 +150,7 @@ const state = {
|
||||
pipelineFilters: { ...EMPTY_PIPELINE_FILTERS },
|
||||
pipelineSort: "server_order",
|
||||
pipelineMenu: null,
|
||||
pipelineTab: "summary",
|
||||
pipelineTab: readSection("pipelines", "summary"),
|
||||
// The mounted workflow graph (P6) and whether its panel is expanded. The
|
||||
// handle is dropped on every re-render so its listeners can never leak.
|
||||
pipelineGraph: null,
|
||||
@@ -145,7 +168,7 @@ const state = {
|
||||
// failed/absent validate stores null so the card/detail say "unavailable".
|
||||
templateGraphs: new Map(),
|
||||
selectedTemplateKey: null,
|
||||
templateTab: "summary",
|
||||
templateTab: readSection("templates", "summary"),
|
||||
// The create-from-template dialog (P5): whether it is open, the name being
|
||||
// typed, whether a validate+submit is in flight, the server's refusal text and
|
||||
// the created pipeline's name (null until a success, which is also what makes
|
||||
@@ -165,7 +188,7 @@ const state = {
|
||||
// expand/collapse choices for the input/output field sections and the summary
|
||||
// artifacts section. The stage pane is the timeline's per-visit panel; its
|
||||
// section expansion is reseeded each time a pane is opened.
|
||||
runTab: "summary",
|
||||
runTab: readSection("runs", "summary"),
|
||||
runSections: new Set(),
|
||||
runStagePane: null,
|
||||
runStageSections: new Set(),
|
||||
@@ -185,6 +208,8 @@ const state = {
|
||||
// changes, plus the pure debounce/stale-token sequencer. Opening or closing the
|
||||
// search leaves state.view, the selection and the loaded data untouched.
|
||||
searchOpen: false,
|
||||
// The keyboard-selected result (ArrowUp/Down) and the row Enter opens.
|
||||
searchActiveIndex: 0,
|
||||
searchQuery: "",
|
||||
searchKind: DEFAULT_SEARCH_KIND,
|
||||
searchSort: DEFAULT_SEARCH_SORT,
|
||||
@@ -683,6 +708,7 @@ function selectSection(key) {
|
||||
if (state.view === "pipelines") state.pipelineTab = key;
|
||||
else if (state.view === "runs") state.runTab = key;
|
||||
else if (state.view === "templates") state.templateTab = key;
|
||||
writeSection(state.view, key);
|
||||
renderContent();
|
||||
focusSectionTab(key);
|
||||
}
|
||||
@@ -1315,7 +1341,7 @@ async function applyRoute(route) {
|
||||
state.selectedPipelineId = r.id;
|
||||
state.pipelineRequestedVersion = version;
|
||||
state.pipelineDetail = null;
|
||||
state.pipelineTab = r.kind === "pipelineStage" ? "graph" : "summary";
|
||||
if (r.kind === "pipelineStage") state.pipelineTab = "graph";
|
||||
state.pipelineGraphSelection = r.kind === "pipelineStage" ? r.stageKey : null;
|
||||
renderContent();
|
||||
if (!connected()) return;
|
||||
@@ -1798,7 +1824,7 @@ function resetRunDetailState() {
|
||||
state.runGraph?.unmount();
|
||||
state.runGraph = null;
|
||||
state.runDetail = null;
|
||||
state.runTab = "summary";
|
||||
// The section stays put when the operator opens another run (sticky, persisted).
|
||||
state.runSections = new Set();
|
||||
state.runStagePane = null;
|
||||
state.runStageSections = new Set();
|
||||
@@ -1846,7 +1872,7 @@ async function missingRunFallback(err) {
|
||||
*/
|
||||
function resetPipelineDetailState() {
|
||||
state.pipelineDetail = null;
|
||||
state.pipelineTab = "summary";
|
||||
// The section stays put when the operator opens another pipeline.
|
||||
state.pipelineGraphSelection = null;
|
||||
state.versionsExpanded = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user