feat: add get_app_runtime_logs tool to global chat#9502
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Deploying windmill with
|
| Latest commit: |
ccbb995
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e05f78a5.windmill.pages.dev |
| Branch Preview URL: | https://claude-runtime-logs-chat-too.windmill.pages.dev |
…hat-tool # Conflicts: # frontend/src/lib/components/sessions/RawAppEditorView.svelte # frontend/src/lib/components/sessions/sessionRuntime.svelte.ts
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Claude finished @centdix's task in 9m 53s —— View job cc @centdix Mergeable, but should ideally address nits: iframe-supplied FindingsFound 3 issues (all posted as inline comments):
Focus areas checked — no findings
Test coverageFrontend-only diff. The pure-logic tool plumbing in Manual verification still needed before merge: in an AI session, open a raw app preview, trigger console output and an uncaught error in the app, then ask the chat to read runtime logs —
|
Pi Reviewcc @centdix Should address issues before merging: broken P1 — Broken import:
|
Codex Reviewcc @centdix Found 1 issue:
Test coverage Frontend unit coverage was added for the global chat tool registration, session-only gating, defaults, and UI status plumbing. No Svelte component tests are expected here. Manual verification still needed before merge: in an AI session, open a raw app preview, emit console logs/errors from the live preview, call |
| requestId: string, | ||
| entries: RawAppRuntimeLogEntry[] | undefined | ||
| ) { | ||
| const pending = pendingRuntimeLogReqs[requestId] |
There was a problem hiding this comment.
[P2] pendingRuntimeLogReqs is a plain Record indexed by the iframe-supplied e.data.requestId. A lookup with an inherited key ('__proto__', 'constructor', 'toString') returns a truthy non-pending value, passes the if (!pending) return guard, and then throws pending.resolve is not a function inside the window message listener. The preview iframe runs arbitrary user app code and the listener explicitly treats it as spoofable. Use a Map<string, PendingRuntimeLogRequest> (or guard with Object.hasOwn) so only locally-generated UUID keys ever resolve.
| export function formatRuntimeLogsForChat(entries: RawAppRuntimeLogEntry[]): string { | ||
| const lines = entries.map((e) => { | ||
| const time = Number.isFinite(e.ts) ? new Date(e.ts).toISOString().slice(11, 23) : '--:--:--' | ||
| return `[${time}] ${e.level.toUpperCase()}: ${e.message}` |
There was a problem hiding this comment.
[P2] runtimeLogsResponse payloads are forwarded with only an Array.isArray check (RawAppEditor.svelte:1005), but this formatter calls e.level.toUpperCase() and new Date(e.ts).toISOString() — the latter throws RangeError for finite-but-out-of-range ts, so the Number.isFinite guard is insufficient. A malformed entry posted by preview app code makes get_app_runtime_logs throw instead of returning a result. Coerce/validate each entry's shape (string level/message, in-range ts) before formatting.
| custom_path?: string | ||
| } | ||
| | undefined | ||
| | { |
There was a problem hiding this comment.
[P2] ~60 lines of pure re-indentation churn unrelated to the feature: the rawApp/savedRawApp union types and the baseline/structuredClone block here, plus the genWmillTs template interpolations in raw_apps/utils.ts. The new indentation contradicts frontend/.prettierrc — running npm run format would revert these hunks — and it pollutes blame. Revert the non-functional hunks or run the repo prettier over the touched files.
Summary
Adds session-only global-chat diagnostics for raw app previews. The assistant can inspect the live preview's browser console with
get_app_runtime_logs, list backend runnable jobs triggered by that preview withlist_app_runs, and then useget_job_logson a returnedjob_idfor server-side debugging.The tool outputs are split deliberately: the model receives explicit, instructional next steps, while the UI only shows a short minimal status such as
Read 3 runtime logsorListed 2 app runs.The companion
windmill-code-ui-builderpreview-shell change has merged, and this PR now pins the frontend UI builder artifact to that merged build (ad76918) so the preview can answer runtime-log requests.Enregistrement.de.l.ecran.2026-06-10.a.17.52.54.mov
Changes
get_app_runtime_logsas a session-only global chat tool, including schema, prompt guidance, handler registration, and tests.list_app_runsas a session-only global chat tool so the assistant can find raw app backend runnable job IDs and chain toget_job_logs.SESSION_PREVIEW_TOOL_NAMES, keeping them out of the regular global side-panel chat.aiResultfor the model, terseuiMessagefor the visible tool status.RawAppEditorto the preview iframe with request IDs, timeout cleanup, and teardown cleanup.jobs/jobsByIdstate and exposes them through the session runtime.RawAppEditorViewand dispatches handlers by the calling session ID.raw_apps/utils.tswith explicit next-step instructions for the assistant.frontend/scripts/ui_builder_artifact.jsonto the merged preview-shell artifactad76918.Test plan
npm run test:unit -- --run src/lib/components/copilot/chat/global/core.test.ts— 67 tests passedgit diff --checknode ./scripts/untar_ui_builder.jsfromfrontend/— downloaded and checksum-verifiedui_builder-ad76918.tar.gzlocalhost:3080: log in, open workspacetest, open raw app editoru/admin/two_plus_two, verify editor and preview iframe mountnpm run check:fastcurrently blocked by unrelated existing errors inChatContextPicker.svelte:62andEditTokenScopesModal.svelte:73npm run checkcurrently blocked by existingEditTokenScopesModal.svelte:73error plus existing Svelte warningsget_app_runtime_logs, and confirm the assistant receives recent logs oldest-firstlist_app_runs, then callget_job_logswith the returnedjob_id