Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,43 @@ var __getProtoOf = Object.getPrototypeOf;
var __defProp = Object.defineProperty;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
function __accessProp(key) {
return this[key];
}
var __toESMCache_node;
var __toESMCache_esm;
var __toESM = (mod, isNodeMode, target) => {
var canCache = mod != null && typeof mod === "object";
if (canCache) {
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
var cached = cache.get(mod);
if (cached)
return cached;
}
target = mod != null ? __create(__getProtoOf(mod)) : {};
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
for (let key of __getOwnPropNames(mod))
if (!__hasOwnProp.call(to, key))
__defProp(to, key, {
get: () => mod[key],
get: __accessProp.bind(mod, key),
enumerable: true
});
if (canCache)
cache.set(mod, to);
return to;
};
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
var __returnValue = (v) => v;
function __exportSetter(name, newValue) {
this[name] = __returnValue.bind(null, newValue);
}
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, {
get: all[name],
enumerable: true,
configurable: true,
set: (newValue) => all[name] = () => newValue
set: __exportSetter.bind(all, name)
});
};

Expand Down Expand Up @@ -3447,7 +3465,7 @@ var require_constants2 = __commonJS((exports2, module2) => {
}
})();
var channel;
var structuredClone = globalThis.structuredClone ?? function structuredClone(value, options = undefined) {
var structuredClone = globalThis.structuredClone ?? function structuredClone2(value, options = undefined) {
if (arguments.length === 0) {
throw new TypeError("missing argument");
}
Expand Down Expand Up @@ -16372,7 +16390,7 @@ var require_undici = __commonJS((exports2, module2) => {
module2.exports.getGlobalDispatcher = getGlobalDispatcher;
if (util.nodeMajor > 16 || util.nodeMajor === 16 && util.nodeMinor >= 8) {
let fetchImpl = null;
module2.exports.fetch = async function fetch(resource) {
module2.exports.fetch = async function fetch2(resource) {
if (!fetchImpl) {
fetchImpl = require_fetch().fetch;
}
Expand Down Expand Up @@ -26966,10 +26984,8 @@ class CoderTaskAction {
const existingTask = await this.coder.getTask(coderUsername, taskName);
if (existingTask) {
core.info(`Coder Task: already exists: ${existingTask.name} (id: ${existingTask.id} status: ${existingTask.status})`);
if (existingTask.status !== "active") {
core.info(`Coder Task: waiting for task ${existingTask.name} to become active...`);
await this.coder.waitForTaskActive(coderUsername, existingTask.id, core.debug, 1200000);
}
core.info(`Coder Task: waiting for task ${existingTask.name} to become active and idle...`);
await this.coder.waitForTaskActive(coderUsername, existingTask.id, core.debug, 1200000);
core.info("Coder Task: Sending prompt to existing task...");
await this.coder.sendTaskInput(coderUsername, existingTask.id, this.inputs.coderTaskPrompt);
core.info("Coder Task: Prompt sent successfully");
Expand Down
1 change: 1 addition & 0 deletions src/action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,7 @@ describe("CoderTaskAction", () => {
);
coderClient.mockGetTemplateVersionPresets.mockResolvedValue([]);
coderClient.mockSendTaskInput.mockResolvedValue(undefined);
coderClient.mockWaitForTaskActive.mockResolvedValue(undefined);
octokit.rest.issues.listComments.mockResolvedValue({
data: [],
} as ReturnType<typeof octokit.rest.issues.listComments>);
Expand Down
25 changes: 13 additions & 12 deletions src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,19 @@ export class CoderTaskAction {
`Coder Task: already exists: ${existingTask.name} (id: ${existingTask.id} status: ${existingTask.status})`,
);

// Wait for task to become active if it's not already
if (existingTask.status !== "active") {
core.info(
`Coder Task: waiting for task ${existingTask.name} to become active...`,
);
await this.coder.waitForTaskActive(
coderUsername,
existingTask.id,
core.debug,
1_200_000,
);
}
// Wait for task to become active and idle before sending
// input. The agent may be in "working" state even when the
// task status is "active", and sending input in that state
// causes 409/502 errors.
core.info(
`Coder Task: waiting for task ${existingTask.name} to become active and idle...`,
);
await this.coder.waitForTaskActive(
coderUsername,
existingTask.id,
core.debug,
1_200_000,
);

core.info("Coder Task: Sending prompt to existing task...");
// Send prompt to existing task using the task ID (UUID)
Expand Down
Loading