The GitHub Actions job "Required Checks" on texera.git/gh-readonly-queue/main/pr-8637-39f0e027cb569dcaec633735c36411188b2fe3c7 has failed. Run started by GitHub user kunwp1 (triggered by kunwp1).
Head commit for run: f8c5e1a29838b9c74db0285df52a2d28eafe283b / Pedro Damián Reyes Alvarado <[email protected]> feat(frontend): add AI workflow fixer with LLM-powered diff panel (#8637) ### What changes were proposed in this PR? Adds an **AI Fix** tab to the result panel. When a Python UDF operator fails, the user clicks **Analyze with AI**; the tab sends the error, the operator's code, its input schemas and its configuration to an LLM through the existing LiteLLM proxy (`/api/chat/completions`), and shows the proposed fix as a diff with a confidence badge. **Apply and re-run** patches the operator through `setOperatorProperty` (so it is undoable) and re-executes the workflow; **Discard** drops it. It handles three error shapes and says so plainly for anything else ("This error type is not yet supported for automatic fixing."): | Error | Fix the model is asked for | | --- | --- | | `KeyError: 'col'` | closest column name from the input schema | | `TypeError: unsupported operand` | an explicit cast | | `ValueError: ... NaN` | `.dropna()` or a null guard | Python UDFs only, and one kind of fix: a change to `code`. An operator without code would cost a model call to reach a refusal, so the tab is not offered there — a JVM operator raising `NullPointerException` classifies, but has nothing Apply could patch. A configuration fix is not offered either: nothing in the repo raises an error one could repair, since the HuggingFace operator retries a 404 as a chat completion and writes "All inference providers failed" into its result rows rather than raising. Classification reads the exception **header**, which both sources already separate from the stack: `mkConsoleMessage` puts `err.toString` in `title`, the Python worker puts `format_exception[-1]` there, and a fatal error carries it in `message` with the frames in `details`. Nothing has to find the exception inside the joined text, which also means a chained traceback arrives already reduced to the one that stopped the worker. **What leaves the browser.** The error text, the operator's code and every input port's schema. Not the operator's configuration: no fix this panel writes reads it, and filtering it could never be made safe. `withoutSecrets` matched top-level field names, but a Python UDF's `uiParameters` is a list of attribute/value pairs, so the name says nothing about whether a value is an API key the user typed in — and the list went into the prompt whole. The block is gone rather than filtered harder, which takes the two sanitisers, the operator's JSON schema lookup and the `OperatorMetadataService` dependency with it. The model the panel asks for is the alias the deployment's LiteLLM proxy publishes, read from `GuiConfig` (`gui.workflow-workspace.ai-fix-model`, overridable by `GUI_WORKFLOW_WORKSPACE_AI_FIX_MODEL`), so a proxy serving a different alias does not need a rebuild to be reachable. **When the tab appears.** A Python UDF exception never becomes a `WorkflowFatalError`: the worker pauses and the traceback arrives as an ERROR `ConsoleMessage` while the execution stays `Running`. The tab is driven by the console stream for that reason, with its own subscription that adds or removes only that entry — a full panel rerender on every console update would reset the Console frame's filter, scroll and debug input and the Result table whenever any operator printed. That decision is made against the frame map itself rather than anything remembered between emissions, because `rerenderResultPanel` writes to the same map: a remembered key went stale the moment the rerender dropped the tab, and the next traceback was then read as "no change". The frame tabs are keyed by their config object, since `keyvalue` hands `*ngFor` a fresh pair per entry and `NgComponentOutlet` only recreates a component when its type changes. It tears itself down when the operator stops reporting an error, and the whole panel resets when a run ends — or, since a UDF that raises leaves the run `Running` and never reaches a terminal state, when a newer error arrives on the same operator. **What Apply guarantees.** - The operator is re-read from the graph first, and the write is refused if the code has moved on since the suggestion was generated. - A suggestion that cannot be applied never reaches the screen. Refused at the analysis, not at the click: a snippet the model invented (zero matches), one quoted from the middle of a line, one that begins a line but stops inside a longer one, and any reply that is not a code change. A quote may include its line's trailing newline or not — one is dropped from each snippet, so the verdict does not depend on where in the file the line sits. - Every occurrence of the snippet is replaced, since a re-run would otherwise fail again on the second one; the panel says how many places that is when it is more than one, and Apply refuses if the count has changed since — an edit in between would otherwise touch a different number of lines than the panel promised. - No indentation is inferred. The prompt requires whole lines carrying the indentation they should have, and a reply that does not is refused, so the replacement is a replacement and nothing has to guess which convention the model used. - The modification lock is cleared first. The traceback arrives while the execution is still `Running`, and Texera locks workflow modification for as long as a run is live, so the panel kills the paused execution — which also releases the computing unit it still held. It refuses instead of killing when a live run is not what holds the lock: a read-only workflow locks through a path `enableWorkflowModification()` cannot reopen, and running only needs write access to the computing unit, so a read-only user can reach a paused run. Every other refusal is checked before that kill as well as after it, so a fix that was never going to be written does not cost the user their run. - It asks `ExecuteWorkflowService` whether the re-run request was sent rather than predicting it, so it never reports "re-running" over a toast saying the run was refused. A deployment can still reject the request after it leaves the browser; that arrives on the execution state stream. - A refused write is reported with its real reason and keeps the suggestion on screen, instead of being reported as a failed analysis. Gated on `copilotEnabled`, the flag the LiteLLM proxy already checks. The model is called only on an explicit click, never on render. ### Screenshots Recorded on Chrome at a 1536x639 viewport, against the current code. The workflow is `TextInput` → Python UDF → `Filter` → `Sort`; the UDF reads `tuple_["lines"]` while `TextInput` emits `line`. The JSON is in the reproduction comment below. <img width="1536" height="639" alt="ai-fix-demo" src="https://github.com/user-attachments/assets/13df908c-3620-4429-a90c-dc09a07101ad" /> The recording runs the whole loop, untouched: **Run** starts the workflow, the traceback arrives while the execution is still `Running`, and the **AI Fix** tab appears beside **Console** on its own — the operator is already selected, so nothing but the console stream puts it there. **Analyze** returns the root cause and a diff with a confidence badge, quoting the whole line with its indentation. **Apply and re-run** stops the paused execution, writes the fix and re-runs; the pipeline then completes through all four operators and the tab removes itself, because the operator no longer reports an error. The same panel when the error falls outside the three patterns -- here a `ZeroDivisionError` from the same operator. It is reported without calling the model at all, because the classification runs client-side before the request: <img width="1536" height="639" alt="ai-fix-unsupported" src="https://github.com/user-attachments/assets/68b132bf-dfcd-4dc0-a7b2-fff423ebf953" /> ### Any related issues, documentation, discussions? Closes #8662 Hackathon submission for #8520 (Universidad Panamericana – Apache Texera Hackathon). ### How was this PR tested? - **Unit tests**: 295 across the result-panel specs — 57 for the service, 23 for the frame, 4 for the prompt builder, 69 for the result panel itself. Every fix in this PR was confirmed failing against the code before it, which caught eight tests of mine that passed either way and had to be rewritten or deleted. ``` cd frontend && yarn test --include="src/app/workspace/component/result-panel/**/*.spec.ts" ``` - **Whole frontend suite**: 7011 passing across 247 files (1 skipped). Everything CI runs on the frontend was run locally too: `yarn format:ci`, `yarn build:ci` (clean production AOT build), `yarn test:ci`, and `ng run gui:test-browser` (23 passing in Chromium). - **End to end on a local stack** (Windows, native services, LiteLLM + `claude-haiku-4.5`), as recorded above: the Python worker raised `KeyError: 'lines'` with the execution still `Running`; Analyze returned `- title = tuple_["lines"]` / `+ title = tuple_["line"]` with high confidence, correctly citing the input schema; Apply patched the operator and the re-run reached `Completed` with rows through both downstream operators. - The prompt's whole-lines rule was measured rather than assumed: 28 of 28 replies from `claude-haiku-4.5` were accepted across the three code-change shapes, against 11 of 12 for the previous prompt, whose single refusal is exactly the mid-line snippet the rule exists for. ### Was this PR authored or co-authored using generative AI tooling? Yes. Generated-by: Claude Code (Claude Opus 5) --------- Co-authored-by: Pedro <[email protected]> Co-authored-by: Claude Opus 5 <[email protected]> Report URL: https://github.com/apache/texera/actions/runs/40641891394 With regards, GitHub Actions via GitBox
