aglinxinyuan opened a new pull request, #7385:
URL: https://github.com/apache/texera/pull/7385
### What changes were proposed in this PR?
`TexeraAgent` had no spec, and it is the largest untested file in the
service. Most of the class is bookkeeping that `sendMessage` maintains but that
needs no model to exercise — the constructor only stores the model reference,
so a placeholder builds a real agent.
Adds 26 tests. The part worth the effort is that the ReAct step tree is a
real **tree**, not a list: each step carries a `parentId` and a `head` pointer
selects the active branch. Regenerating an answer leaves the abandoned branch
in `stepsById`, so the two readers disagree on purpose:
```
INITIAL ── a ── b head = b
└─ c
getVisibleReActSteps() -> [a, b] the conversation the user sees
getAllSteps() -> [a, b, c] everything retained
```
`getReActStepsByOperatorIds` then attributes each step to the operators it
touched by reading the tool results, gated on the tool's **name** agreeing with
its message — so a delete tool echoing "Added operator X" cannot claim X. The
structured-JSON path uses a stricter exact-name gate than the text path does;
that asymmetry is now pinned in both directions so narrowing or widening either
is a visible change.
Also covered: partial `updateSettings` (only `allowedOperatorTypes` triggers
a prompt rebuild), the defensive copy in `getSettings`, the disabled-tool flag
surfacing in `getSystemInfo`, and `clearHistory` / `stop` / `destroy` / the
step callback.
**Verified by mutation**, all reverted (production diff empty):
| Mutation | Result |
|---|---|
| build the ancestor path in reverse | red |
| ignore the explicit `stepId` argument | red |
| stop hiding the synthetic initial step | red |
| keep the initial step in `getAllSteps` | red |
| make an empty operator filter match nothing | red |
| stop skipping a failed tool result | red |
| drop the tool-name gate on the add path | red |
| drop the tool-name gate on the modify path | red |
| widen the JSON add path to any add-ish name | red |
| return settings by reference | red |
| stop rebuilding the prompt on an allowed-types change | red |
| ignore disabled tools in the system info | red |
| leave `head` dangling in `clearHistory` | red |
| leave the state unchanged on `stop` | red |
| drop the derived agent-name default | red |
The modify-gate mutation initially **survived** — the suite gated the add
path but not the symmetric modify path. Added the missing case.
The LLM loop in `sendMessage` is deliberately out of scope: it needs the AI
SDK stubbed and deserves its own pass rather than being half-covered here.
No production file is touched.
### Any related issues, documentation, discussions?
Closes #7382
### How was this PR tested?
```
bun test
```
```
228 pass
0 fail
Ran 228 tests across 16 files.
```
`bun run typecheck` and `bun run format:check` both pass.
### Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 5)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]