bobbai00 commented on code in PR #8753:
URL: https://github.com/apache/texera/pull/8753#discussion_r4384115956
##########
agent-service/src/server.ts:
##########
@@ -482,7 +482,8 @@ export function buildApp() {
switch (msg.type) {
case "WsClientStopCommand":
agent.stop();
- broadcastToAgentClients(agentId, new
WsServerStatusEvent(AgentState.STOPPING));
+ // Broadcast the resulting state: STOPPING mid-run, unchanged when
idle.
+ broadcastToAgentClients(agentId, new
WsServerStatusEvent(agent.getState()));
Review Comment:
**Advisory:**
The REST sibling still returns `{ status: "stopping" }` unconditionally
(`server.ts:306`), so stopping an idle agent over REST reports a stop that
never happened. `server.spec.ts:210` pins that value on an idle agent. Nothing
in-repo reads the body (`agent.service.ts:942-946`), hence advisory. I'd return
`{ status: agent.getState() }` like this handler and split that spec into idle
and mid-run cases.
##########
frontend/src/app/workspace/component/agent/agent-interaction/agent-interaction.component.ts:
##########
@@ -172,8 +180,13 @@ export class AgentInteractionComponent implements OnInit,
OnChanges {
}
}
+ public isSelectedAgentAvailable(): boolean {
+ if (!this.selectedAgentId) return false;
+ return this.agentService.getAgentStateSnapshot(this.selectedAgentId) ===
AgentState.AVAILABLE;
+ }
+
public canSend(): boolean {
- return !!this.selectedAgentId && !!this.feedbackMessage.trim();
+ return !!this.selectedAgentId && !!this.feedbackMessage.trim() &&
this.isSelectedAgentAvailable();
Review Comment:
**Advisory:**
The PR description predates c15d5a2. It doesn't mention this gate,
`getAgentStateSnapshot`, the idle `stop()` no-op, or the WS stop broadcast
change. It also still lists two tests and 312 passing (315 now). Disabling Send
mid-run is a visible UI change, so AGENTS.md asks for a before/after screenshot
or click path.
##########
frontend/src/app/workspace/service/agent/agent.service.ts:
##########
@@ -960,6 +960,13 @@ export class AgentService {
});
}
+ /**
+ * Get the latest known state of an agent synchronously, without creating
tracking.
+ */
+ public getAgentStateSnapshot(agentId: string): AgentState {
Review Comment:
**Advisory:**
`getAgentState` (line 953) already does this lookup, with the same
`UNAVAILABLE` fallback and no tracking side effect, just wrapped in
`defer`/`of`. Two copies of one rule can drift. I'd have `getAgentState` return
`defer(() => of(this.getAgentStateSnapshot(agentId)))` so the rule lives here
once.
--
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]