Merge branch 'main' into web-search
# Conflicts: # web/src/app.js # web/src/protocol.js # web/src/repository.js # web/styles.css # web/test/repository.test.mjs # web/test/ui-smoke.mjs
This commit is contained in:
@@ -93,4 +93,64 @@ export class PipelinesRepository {
|
||||
});
|
||||
return response.search_results ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Answers a run's waiting human stage with the chosen `option` and optional
|
||||
* `feedback` (mirrors PipelinesRepository.decideRun). The stage is sent only
|
||||
* when non-blank and the feedback is trimmed, exactly like the Android client;
|
||||
* a refused decision rejects with the server's own reason (a ProtocolError).
|
||||
*/
|
||||
async decideRun(id, { stage, option, feedback } = {}) {
|
||||
const request = { type: Protocol.DECIDE_RUN, run_id: id, option };
|
||||
if (stage != null && String(stage).trim() !== "") request.stage = stage;
|
||||
const trimmedFeedback = String(feedback ?? "").trim();
|
||||
if (trimmedFeedback !== "") request.feedback = trimmedFeedback;
|
||||
const response = await this.#client.call(request);
|
||||
if (!response.run_detail) {
|
||||
throw new ProtocolError("The server returned no run detail.");
|
||||
}
|
||||
return response.run_detail;
|
||||
}
|
||||
|
||||
/** Cancels a run; mirrors PipelinesRepository.cancelRun (exactly run_id). */
|
||||
async cancelRun(id) {
|
||||
const response = await this.#client.call({ type: Protocol.CANCEL_RUN, run_id: id });
|
||||
if (!response.run_detail) {
|
||||
throw new ProtocolError("The server returned no run detail.");
|
||||
}
|
||||
return response.run_detail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retries a terminal failed run. `request_key` is always sent (the retry is
|
||||
* its own idempotent run); `retry_mode` is sent only for an explicit
|
||||
* `restart`, so the server's default (resume) applies exactly as the Android
|
||||
* client's mode-less call.
|
||||
*/
|
||||
async retryRun(id, { mode = null, requestKey } = {}) {
|
||||
const request = {
|
||||
type: Protocol.RETRY_RUN,
|
||||
run_id: id,
|
||||
request_key: requestKey ?? "",
|
||||
};
|
||||
if (mode === "restart") request.retry_mode = "restart";
|
||||
const response = await this.#client.call(request);
|
||||
if (!response.run_detail) {
|
||||
throw new ProtocolError("The server returned no run detail.");
|
||||
}
|
||||
return response.run_detail;
|
||||
}
|
||||
|
||||
/** Renames a run's stored title; mirrors the set_run_title wire command. */
|
||||
async setRunTitle(id, title) {
|
||||
const response = await this.#client.call({
|
||||
type: Protocol.SET_RUN_TITLE,
|
||||
run_id: id,
|
||||
title,
|
||||
});
|
||||
if (!response.run_detail) {
|
||||
throw new ProtocolError("The server returned no run detail.");
|
||||
}
|
||||
return response.run_detail;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user