diff --git a/frontend/src/lib/components/AIAgentLogViewer.svelte b/frontend/src/lib/components/AIAgentLogViewer.svelte index 2549fbb29f..e92ea4b3cb 100644 --- a/frontend/src/lib/components/AIAgentLogViewer.svelte +++ b/frontend/src/lib/components/AIAgentLogViewer.svelte @@ -7,11 +7,13 @@ type FlowStatusModule, type Job } from '$lib/gen' - import { workspaceStore } from '$lib/stores' import FlowLogViewerWrapper from './FlowLogViewerWrapper.svelte' import { z } from 'zod' import { untrack } from 'svelte' import type { AgentTool } from './flows/agentToolUtils' + import { useOperatingWorkspace } from '$lib/components/operatingWorkspace.svelte' + + const operatingWorkspace = useOperatingWorkspace() type AgentActionWithContent = NonNullable[number] & { content?: unknown @@ -81,7 +83,7 @@ if (!job || job.type !== 'CompletedJob') { job = await JobService.getJob({ id: toolCall.job_id, - workspace: workspaceId ?? $workspaceStore! + workspace: workspaceId ?? $operatingWorkspace! }) } states[idx.toString()] = { @@ -186,50 +188,49 @@ job = { ...agentJob, raw_flow: { - modules: agentActions - .map((toolCall, idx) => { - if (toolCall.type === 'message') { - return { - id: idx.toString(), - value: { - type: 'identity' as const - } + modules: agentActions.map((toolCall, idx) => { + if (toolCall.type === 'message') { + return { + id: idx.toString(), + value: { + type: 'identity' as const } - } else if (toolCall.type === 'mcp_tool_call') { - return { - id: idx.toString(), - value: { - type: 'identity' as const - }, - summary: toolCall.function_name, - arguments: toolCall.arguments - } - } else if (toolCall.type === 'web_search') { - return { - id: idx.toString(), - value: { - type: 'identity' as const - }, - summary: 'Web Search' - } - } else { - const module = tools.find((m) => m.summary === toolCall.function_name) - // A definition can be missing for a call that did run: the tool was renamed or - // removed since, or it belongs to a linked agent whose resource is no longer - // readable. Keep the recorded call — its args, logs and result come from the - // child job — rather than dropping it from the history. - return module - ? ({ - ...module, - id: idx.toString() - } as FlowModule) - : ({ - id: idx.toString(), - value: { type: 'identity' as const }, - summary: toolCall.function_name - } as FlowModule) } - }) + } else if (toolCall.type === 'mcp_tool_call') { + return { + id: idx.toString(), + value: { + type: 'identity' as const + }, + summary: toolCall.function_name, + arguments: toolCall.arguments + } + } else if (toolCall.type === 'web_search') { + return { + id: idx.toString(), + value: { + type: 'identity' as const + }, + summary: 'Web Search' + } + } else { + const module = tools.find((m) => m.summary === toolCall.function_name) + // A definition can be missing for a call that did run: the tool was renamed or + // removed since, or it belongs to a linked agent whose resource is no longer + // readable. Keep the recorded call — its args, logs and result come from the + // child job — rather than dropping it from the history. + return module + ? ({ + ...module, + id: idx.toString() + } as FlowModule) + : ({ + id: idx.toString(), + value: { type: 'identity' as const }, + summary: toolCall.function_name + } as FlowModule) + } + }) } } } diff --git a/frontend/src/lib/components/ApiConnectForm.svelte b/frontend/src/lib/components/ApiConnectForm.svelte index dedeee90e2..2255817c5e 100644 --- a/frontend/src/lib/components/ApiConnectForm.svelte +++ b/frontend/src/lib/components/ApiConnectForm.svelte @@ -1,7 +1,6 @@ @@ -20,7 +22,7 @@ Setup the wmill cli for this workspace & remote:
diff --git a/frontend/src/lib/components/DBManagerContent.svelte b/frontend/src/lib/components/DBManagerContent.svelte index b0ef2859df..3ee98538ba 100644 --- a/frontend/src/lib/components/DBManagerContent.svelte +++ b/frontend/src/lib/components/DBManagerContent.svelte @@ -1,5 +1,5 @@
@@ -46,9 +47,6 @@ {onClear} /> {#if showSchemaExplorer && value && assetCanBeExplored({ kind: 'ducklake', path: value })} - + {/if}
diff --git a/frontend/src/lib/components/Editor.svelte b/frontend/src/lib/components/Editor.svelte index 987aa937eb..6aabc30c2b 100644 --- a/frontend/src/lib/components/Editor.svelte +++ b/frontend/src/lib/components/Editor.svelte @@ -42,7 +42,6 @@ import { editorConfig, registerWebviewPaste, updateOptions } from '$lib/editorUtils' import { editorFontSize } from '$lib/editorFontSize.svelte' import { createHash as randomHash } from '$lib/editorLangUtils' - import { workspaceStore } from '$lib/stores' import DdlMigrationGuard from './DdlMigrationGuard.svelte' import { type Preview, @@ -120,6 +119,9 @@ import { rawAppLintStore, type MonacoLintError } from './raw_apps/lintStore' import { MarkerSeverity } from 'monaco-editor' import { resource, useDebounce, watch } from 'runed' + import { useOperatingWorkspace } from '$lib/components/operatingWorkspace.svelte' + + const operatingWorkspace = useOperatingWorkspace() // import EditorTheme from './EditorTheme.svelte' let divEl: HTMLDivElement | null = $state(null) @@ -684,7 +686,7 @@ // via a short-TTL cache — macros are late-bound, so mild staleness is fine. async function addWorkspaceMacroCompletions() { workspaceMacroCompletor?.dispose() - const workspace = $workspaceStore + const workspace = $operatingWorkspace if (!workspace) return let macros: Awaited> = [] try { @@ -739,7 +741,7 @@ provideCompletionItems: async function (model, position) { // Read the store per request, not at registration — the provider // outlives a workspace switch. - const workspace = $workspaceStore + const workspace = $operatingWorkspace if (!workspace) return { suggestions: [] } const before = model.getLineContent(position.lineNumber).slice(0, position.column - 1) if (!/^\s*(\/\/|--|#)\s*(column|data_test|on|materialize)\b/.test(before)) { @@ -780,7 +782,7 @@ $dbSchemas[resourcePath] = await getDbSchemas( lang === 'graphql' ? 'graphql' : (scriptLang ?? ''), resourcePath, - $workspaceStore, + $operatingWorkspace, (e) => console.error(`error getting ${lang} (${scriptLang}) db schema`, e), { customTag } ) @@ -1778,9 +1780,9 @@ let customTsTypesData = resource([() => lang], async () => { if (lang !== 'typescript') return undefined let datatables = ( - await WorkspaceService.listDataTables({ workspace: $workspaceStore ?? '' }) + await WorkspaceService.listDataTables({ workspace: $operatingWorkspace ?? '' }) ).map((d) => d.name) - let ducklakes = await WorkspaceService.listDucklakes({ workspace: $workspaceStore ?? '' }) + let ducklakes = await WorkspaceService.listDucklakes({ workspace: $operatingWorkspace ?? '' }) return { datatables, ducklakes } }) function setTypescriptCustomTypes() { @@ -1822,7 +1824,7 @@ scriptLang === 'nativets') ) { const resourceTypes = await ResourceService.listResourceType({ - workspace: $workspaceStore ?? '' + workspace: $operatingWorkspace ?? '' }) const namespace = formatResourceTypes( @@ -2023,7 +2025,7 @@ $lspTokenStore = newToken token = newToken } - let root = hostname + '/api/scripts_u/tokened_raw/' + $workspaceStore + '/' + token + let root = hostname + '/api/scripts_u/tokened_raw/' + $operatingWorkspace + '/' + token return root } @@ -2274,10 +2276,10 @@ -{#if datatableForMigrations && $workspaceStore} +{#if datatableForMigrations && $operatingWorkspace} {/if} diff --git a/frontend/src/lib/components/EditorBar.svelte b/frontend/src/lib/components/EditorBar.svelte index 91516843ab..81ef6c1c96 100644 --- a/frontend/src/lib/components/EditorBar.svelte +++ b/frontend/src/lib/components/EditorBar.svelte @@ -22,7 +22,6 @@ diff --git a/frontend/src/lib/components/FlowHistoryJobPicker.svelte b/frontend/src/lib/components/FlowHistoryJobPicker.svelte index 26fa41f1af..dfb4927af1 100644 --- a/frontend/src/lib/components/FlowHistoryJobPicker.svelte +++ b/frontend/src/lib/components/FlowHistoryJobPicker.svelte @@ -3,9 +3,11 @@ import { createEventDispatcher, untrack } from 'svelte' import PopoverV2 from '$lib/components/meltComponents/Popover.svelte' import HistoricInputs from './HistoricInputs.svelte' - import { workspaceStore } from '$lib/stores' import { JobService } from '$lib/gen' import { Button } from './common' + import { useOperatingWorkspace } from '$lib/components/operatingWorkspace.svelte' + + const operatingWorkspace = useOperatingWorkspace() interface Props { path: string @@ -27,7 +29,7 @@ async function loadInitial() { loading = true let jobs = await JobService.listJobs({ - workspace: $workspaceStore!, + workspace: $operatingWorkspace!, scriptPathExact: path, jobKinds: ['flow', 'flowpreview'].join(','), perPage: 1 @@ -43,7 +45,7 @@ } $effect(() => { - if ($workspaceStore && !newFlow) { + if ($operatingWorkspace && !newFlow) { untrack(() => loadInitial()) } }) diff --git a/frontend/src/lib/components/FlowLogViewer.svelte b/frontend/src/lib/components/FlowLogViewer.svelte index 385d028e7e..f4974c7de5 100644 --- a/frontend/src/lib/components/FlowLogViewer.svelte +++ b/frontend/src/lib/components/FlowLogViewer.svelte @@ -11,7 +11,6 @@ Keyboard } from 'lucide-svelte' import { base } from '$lib/base' - import { workspaceStore } from '$lib/stores' import ObjectViewer from './propertyPicker/ObjectViewer.svelte' import LogViewer from './LogViewer.svelte' import FlowLogViewer from './FlowLogViewer.svelte' @@ -26,6 +25,9 @@ import { Tooltip } from './meltComponents' import FlowTimelineBar from './FlowTimelineBar.svelte' import { getActiveReplay } from './recording/replay.svelte' + import { useOperatingWorkspace } from '$lib/components/operatingWorkspace.svelte' + + const operatingWorkspace = useOperatingWorkspace() type RootJobData = Partial @@ -98,7 +100,7 @@ function getJobLink(jobId: string | undefined): string { if (!jobId) return '' - return `${base}/run/${jobId}?workspace=${workspaceId ?? $workspaceStore}` + return `${base}/run/${jobId}?workspace=${workspaceId ?? $operatingWorkspace}` } function getStatusColor(status: FlowStatusModule['type'] | undefined): string { diff --git a/frontend/src/lib/components/FlowLoopIterationPreview.svelte b/frontend/src/lib/components/FlowLoopIterationPreview.svelte index 0a4f5c60ee..f136cbfe39 100644 --- a/frontend/src/lib/components/FlowLoopIterationPreview.svelte +++ b/frontend/src/lib/components/FlowLoopIterationPreview.svelte @@ -1,6 +1,5 @@ diff --git a/frontend/src/lib/components/JobLoader.svelte b/frontend/src/lib/components/JobLoader.svelte index 71bd2fbb51..324bdea6c7 100644 --- a/frontend/src/lib/components/JobLoader.svelte +++ b/frontend/src/lib/components/JobLoader.svelte @@ -14,7 +14,6 @@ type WorkflowStatus, type OpenFlow } from '$lib/gen' - import { workspaceStore } from '$lib/stores' import { getViewToken } from '$lib/viewToken' import { WM_LOGS_SKIPPED } from '$lib/consts' import { getContext, onDestroy, tick, untrack } from 'svelte' @@ -22,6 +21,9 @@ import { sendUserToast } from '$lib/toast' import { DynamicInput, isScriptPreview } from '$lib/utils' import { getActiveReplay, getReplayStartTime } from './recording/replay.svelte' + import { useOperatingWorkspace } from '$lib/components/operatingWorkspace.svelte' + + const operatingWorkspace = useOperatingWorkspace() // Will be set to number if job is not a flow @@ -75,7 +77,7 @@ children }: Props = $props() - let workspace = $derived(workspaceOverride ?? $workspaceStore) + let workspace = $derived(workspaceOverride ?? $operatingWorkspace) let syncIteration: number = 0 let errorIteration = 0 diff --git a/frontend/src/lib/components/JobOtelTraces.svelte b/frontend/src/lib/components/JobOtelTraces.svelte index d57a7158e1..9332abdff1 100644 --- a/frontend/src/lib/components/JobOtelTraces.svelte +++ b/frontend/src/lib/components/JobOtelTraces.svelte @@ -1,9 +1,11 @@