mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
chore(lint): rename shadowed bindings in server (no-shadow)
Rename inner bindings that shadow outer imports or function params: - Promise executor `resolve` -> `resolvePromise` (shadowed path `resolve`) - Method params `options` -> `input`/`target`/`update`/`runOptions`/`opts`/`killOptions` - Misc loop/destructure renames for `workspaceId`, `scriptNames`, `path`, `query`, `taskNotificationItem` Mechanical change only; no behavior change.
This commit is contained in:
@@ -816,10 +816,10 @@ export class AgentManager {
|
||||
try {
|
||||
return await Promise.race([
|
||||
operation,
|
||||
new Promise<TimeoutResult>((resolve) => {
|
||||
new Promise<TimeoutResult>((resolvePromise) => {
|
||||
timer = setTimeout(() => {
|
||||
didTimeOut = true;
|
||||
resolve("timed_out");
|
||||
resolvePromise("timed_out");
|
||||
}, options.timeoutMs);
|
||||
}),
|
||||
]);
|
||||
@@ -1261,8 +1261,8 @@ export class AgentManager {
|
||||
let queueResolve: (() => void) | null = null;
|
||||
let done = false;
|
||||
let resolveSettled!: () => void;
|
||||
const settledPromise = new Promise<void>((resolve) => {
|
||||
resolveSettled = resolve;
|
||||
const settledPromise = new Promise<void>((resolvePromise) => {
|
||||
resolveSettled = resolvePromise;
|
||||
});
|
||||
|
||||
waiter = {
|
||||
@@ -1294,8 +1294,8 @@ export class AgentManager {
|
||||
if (waiter.settled) {
|
||||
break;
|
||||
}
|
||||
await new Promise<void>((resolve) => {
|
||||
queueResolve = resolve;
|
||||
await new Promise<void>((resolvePromise) => {
|
||||
queueResolve = resolvePromise;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1417,7 +1417,7 @@ export class AgentManager {
|
||||
throw createAbortError(options.signal, "wait_for_agent_start aborted");
|
||||
}
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
await new Promise<void>((resolvePromise, reject) => {
|
||||
if (options?.signal?.aborted) {
|
||||
reject(createAbortError(options.signal, "wait_for_agent_start aborted"));
|
||||
return;
|
||||
@@ -1447,7 +1447,7 @@ export class AgentManager {
|
||||
|
||||
const finishOk = () => {
|
||||
cleanup();
|
||||
resolve();
|
||||
resolvePromise();
|
||||
};
|
||||
|
||||
const finishErr = (error: unknown) => {
|
||||
@@ -1559,12 +1559,12 @@ export class AgentManager {
|
||||
const waiter = Array.from(agent.foregroundTurnWaiters).find(
|
||||
(candidate) => candidate.turnId === foregroundTurnId,
|
||||
);
|
||||
const timeout = new Promise<void>((resolve) => setTimeout(resolve, 2000));
|
||||
const timeout = new Promise<void>((resolvePromise) => setTimeout(resolvePromise, 2000));
|
||||
if (waiter) {
|
||||
await Promise.race([waiter.settledPromise, timeout]);
|
||||
} else if (agent.activeForegroundTurnId === foregroundTurnId) {
|
||||
await Promise.race([
|
||||
new Promise<void>((resolve) => {
|
||||
new Promise<void>((resolvePromise) => {
|
||||
const unsubscribe = this.subscribe(
|
||||
(event) => {
|
||||
if (
|
||||
@@ -1573,7 +1573,7 @@ export class AgentManager {
|
||||
!event.agent.activeForegroundTurnId
|
||||
) {
|
||||
unsubscribe();
|
||||
resolve();
|
||||
resolvePromise();
|
||||
}
|
||||
},
|
||||
{ agentId, replayState: false },
|
||||
@@ -1590,7 +1590,7 @@ export class AgentManager {
|
||||
await Promise.race([pendingRun.settledPromise, timeout]);
|
||||
}
|
||||
} else if (pendingRun) {
|
||||
const timeout = new Promise<void>((resolve) => setTimeout(resolve, 2000));
|
||||
const timeout = new Promise<void>((resolvePromise) => setTimeout(resolvePromise, 2000));
|
||||
await Promise.race([pendingRun.settledPromise, timeout]);
|
||||
}
|
||||
|
||||
@@ -1820,7 +1820,7 @@ export class AgentManager {
|
||||
throw createAbortError(options.signal, "wait_for_agent aborted");
|
||||
}
|
||||
|
||||
return await new Promise<WaitForAgentResult>((resolve, reject) => {
|
||||
return await new Promise<WaitForAgentResult>((resolvePromise, reject) => {
|
||||
// Bug #1 Fix: Check abort signal AGAIN inside Promise constructor
|
||||
// to avoid race condition between pre-Promise check and abort listener registration
|
||||
if (options?.signal?.aborted) {
|
||||
@@ -1870,7 +1870,7 @@ export class AgentManager {
|
||||
cleanup();
|
||||
void this.getLastAssistantMessage(agentId)
|
||||
.then((lastMessage) => {
|
||||
resolve({
|
||||
resolvePromise({
|
||||
status: currentStatus,
|
||||
permission,
|
||||
lastMessage,
|
||||
@@ -2177,8 +2177,8 @@ export class AgentManager {
|
||||
|
||||
private createPendingForegroundRun(): PendingForegroundRun {
|
||||
let resolveSettled!: () => void;
|
||||
const settledPromise = new Promise<void>((resolve) => {
|
||||
resolveSettled = resolve;
|
||||
const settledPromise = new Promise<void>((resolvePromise) => {
|
||||
resolveSettled = resolvePromise;
|
||||
});
|
||||
return {
|
||||
token: randomUUID(),
|
||||
|
||||
@@ -307,7 +307,7 @@ export async function createAgentMcpServer(options: AgentMcpServerOptions): Prom
|
||||
return parentAgent;
|
||||
};
|
||||
|
||||
const resolveScopedCwd = (requestedCwd?: string, options?: { required?: boolean }): string => {
|
||||
const resolveScopedCwd = (requestedCwd?: string, opts?: { required?: boolean }): string => {
|
||||
const callerAgent = resolveCallerAgent();
|
||||
if (callerAgent) {
|
||||
return resolveChildAgentCwd({
|
||||
@@ -320,7 +320,7 @@ export async function createAgentMcpServer(options: AgentMcpServerOptions): Prom
|
||||
|
||||
const trimmedCwd = requestedCwd?.trim();
|
||||
if (!trimmedCwd) {
|
||||
if (options?.required) {
|
||||
if (opts?.required) {
|
||||
throw new Error("cwd is required");
|
||||
}
|
||||
throw new Error("cwd is required when no caller agent is available");
|
||||
|
||||
@@ -1132,13 +1132,13 @@ describe("ProviderSnapshotManager", () => {
|
||||
});
|
||||
|
||||
function deferred<T>(): Deferred<T> {
|
||||
let resolve!: (value: T) => void;
|
||||
let resolvePromise!: (value: T) => void;
|
||||
let reject!: (reason?: unknown) => void;
|
||||
const promise = new Promise<T>((res, rej) => {
|
||||
resolve = res;
|
||||
resolvePromise = res;
|
||||
reject = rej;
|
||||
});
|
||||
return { promise, resolve, reject };
|
||||
return { promise, resolve: resolvePromise, reject };
|
||||
}
|
||||
|
||||
function createRegistry(handles: MockProviderHandle[]): {
|
||||
|
||||
@@ -1729,8 +1729,8 @@ class ClaudeAgentSession implements AgentSession {
|
||||
|
||||
const normalized = isPermissionMode(modeId) ? modeId : "default";
|
||||
const previousMode = this.currentMode;
|
||||
const query = await this.ensureQuery();
|
||||
await query.setPermissionMode(normalized);
|
||||
const activeQuery = await this.ensureQuery();
|
||||
await activeQuery.setPermissionMode(normalized);
|
||||
if (normalized === "plan") {
|
||||
if (previousMode !== "plan") {
|
||||
this.planResumeMode = previousMode;
|
||||
@@ -1744,8 +1744,8 @@ class ClaudeAgentSession implements AgentSession {
|
||||
async setModel(modelId: string | null): Promise<void> {
|
||||
const normalizedModelId =
|
||||
typeof modelId === "string" && modelId.trim().length > 0 ? modelId : null;
|
||||
const query = await this.ensureQuery();
|
||||
await query.setModel(normalizedModelId ?? undefined);
|
||||
const activeQuery = await this.ensureQuery();
|
||||
await activeQuery.setModel(normalizedModelId ?? undefined);
|
||||
this.config.model = normalizedModelId ?? undefined;
|
||||
this.lastOptionsModel = normalizedModelId ?? this.lastOptionsModel;
|
||||
this.lastRuntimeModel = null;
|
||||
@@ -2020,8 +2020,8 @@ class ClaudeAgentSession implements AgentSession {
|
||||
deletions?: number;
|
||||
}> {
|
||||
try {
|
||||
const query = await this.ensureFreshQuery();
|
||||
return await query.rewindFiles(messageId, { dryRun: false });
|
||||
const activeQuery = await this.ensureFreshQuery();
|
||||
return await activeQuery.rewindFiles(messageId, { dryRun: false });
|
||||
} catch (error) {
|
||||
// The Claude SDK transport can close after a rewind call.
|
||||
// If that happens, mark the query stale so a follow-up attempt uses a fresh query.
|
||||
@@ -2732,7 +2732,7 @@ class ClaudeAgentSession implements AgentSession {
|
||||
|
||||
private async handleMissingResumedConversation(
|
||||
message: SDKMessage,
|
||||
query: Query,
|
||||
activeQuery: Query,
|
||||
): Promise<boolean> {
|
||||
const staleResumeError = this.readMissingResumedConversationError(message);
|
||||
if (!staleResumeError) {
|
||||
@@ -2750,10 +2750,10 @@ class ClaudeAgentSession implements AgentSession {
|
||||
this.failActiveTurns(staleResumeError);
|
||||
this.input?.end();
|
||||
await this.awaitWithTimeout(
|
||||
query.return?.(),
|
||||
activeQuery.return?.(),
|
||||
"query pump return on missing resumed conversation",
|
||||
);
|
||||
if (this.query === query) {
|
||||
if (this.query === activeQuery) {
|
||||
this.query = null;
|
||||
this.input = null;
|
||||
}
|
||||
@@ -4017,12 +4017,12 @@ export function convertClaudeHistoryEntry(
|
||||
: null;
|
||||
|
||||
if (entry.type === "user") {
|
||||
const taskNotificationItem = mapTaskNotificationUserContentToToolCall({
|
||||
const userTaskNotificationItem = mapTaskNotificationUserContentToToolCall({
|
||||
content,
|
||||
messageId: userMessageId,
|
||||
});
|
||||
if (taskNotificationItem) {
|
||||
return [taskNotificationItem];
|
||||
if (userTaskNotificationItem) {
|
||||
return [userTaskNotificationItem];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -166,9 +166,11 @@ function isObjectSchemaNode(schema: Record<string, unknown>): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
function normalizeCodexOutputSchemaNode(schema: unknown, path: string): unknown {
|
||||
function normalizeCodexOutputSchemaNode(schema: unknown, schemaPath: string): unknown {
|
||||
if (Array.isArray(schema)) {
|
||||
return schema.map((entry, index) => normalizeCodexOutputSchemaNode(entry, `${path}[${index}]`));
|
||||
return schema.map((entry, index) =>
|
||||
normalizeCodexOutputSchemaNode(entry, `${schemaPath}[${index}]`),
|
||||
);
|
||||
}
|
||||
if (!isSchemaRecord(schema)) {
|
||||
return schema;
|
||||
@@ -176,7 +178,7 @@ function normalizeCodexOutputSchemaNode(schema: unknown, path: string): unknown
|
||||
|
||||
const normalized: Record<string, unknown> = {};
|
||||
for (const [key, value] of Object.entries(schema)) {
|
||||
normalized[key] = normalizeCodexOutputSchemaNode(value, `${path}.${key}`);
|
||||
normalized[key] = normalizeCodexOutputSchemaNode(value, `${schemaPath}.${key}`);
|
||||
}
|
||||
|
||||
if (!isObjectSchemaNode(normalized)) {
|
||||
@@ -187,7 +189,7 @@ function normalizeCodexOutputSchemaNode(schema: unknown, path: string): unknown
|
||||
normalized.additionalProperties = false;
|
||||
} else if (normalized.additionalProperties !== false) {
|
||||
throw new Error(
|
||||
`Codex structured outputs require ${path} to set additionalProperties to false for object schemas.`,
|
||||
`Codex structured outputs require ${schemaPath} to set additionalProperties to false for object schemas.`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1264,8 +1266,8 @@ function parseCodexPatchChanges(changes: unknown): CodexPatchFileChange[] {
|
||||
}
|
||||
|
||||
return Object.entries(recordChanges)
|
||||
.map(([path, value]): CodexPatchFileChange | null => {
|
||||
const normalizedPath = path.trim();
|
||||
.map(([entryPath, value]): CodexPatchFileChange | null => {
|
||||
const normalizedPath = entryPath.trim();
|
||||
if (!normalizedPath) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -284,8 +284,8 @@ export function startRelayTransport({
|
||||
}
|
||||
if (msg.type === "pong") return;
|
||||
if (msg.type === "sync") {
|
||||
for (const connectionId of msg.connectionIds) {
|
||||
ensureClientDataSocket(connectionId);
|
||||
for (const clientConnectionId of msg.connectionIds) {
|
||||
ensureClientDataSocket(clientConnectionId);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -403,8 +403,8 @@ describe("script-status-projection", () => {
|
||||
routeStore,
|
||||
runtimeStore,
|
||||
daemonPort: 6767,
|
||||
resolveWorkspaceDirectory: async (workspaceId) =>
|
||||
workspaceId === "workspace-emitter" ? workspace.repoDir : null,
|
||||
resolveWorkspaceDirectory: async (requestedWorkspaceId) =>
|
||||
requestedWorkspaceId === "workspace-emitter" ? workspace.repoDir : null,
|
||||
});
|
||||
|
||||
try {
|
||||
|
||||
@@ -108,9 +108,9 @@ export function assertNoServiceEnvNameCollisions(scriptNames: readonly string[])
|
||||
}
|
||||
|
||||
const collisions: string[] = [];
|
||||
for (const [envName, scriptNames] of scriptNamesByEnvName) {
|
||||
if (scriptNames.length > 1) {
|
||||
collisions.push(`Service env name collision for ${envName}: ${scriptNames.join(", ")}`);
|
||||
for (const [envName, names] of scriptNamesByEnvName) {
|
||||
if (names.length > 1) {
|
||||
collisions.push(`Service env name collision for ${envName}: ${names.join(", ")}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -542,8 +542,8 @@ describe("runWorktreeSetupInBackground", () => {
|
||||
{
|
||||
paseoHome,
|
||||
emitWorkspaceUpdateForCwd,
|
||||
cacheWorkspaceSetupSnapshot: (workspaceId, snapshot) =>
|
||||
snapshots.set(workspaceId, snapshot),
|
||||
cacheWorkspaceSetupSnapshot: (snapshotWorkspaceId, snapshot) =>
|
||||
snapshots.set(snapshotWorkspaceId, snapshot),
|
||||
emit: (message) => emitted.push(message),
|
||||
sessionLogger: logger,
|
||||
terminalManager: null,
|
||||
|
||||
@@ -643,46 +643,46 @@ export function createGitHubService(options: CreateGitHubServiceOptions = {}): G
|
||||
return request;
|
||||
}
|
||||
|
||||
async function run(args: string[], options: GitHubCommandRunnerOptions): Promise<string> {
|
||||
async function run(args: string[], runOptions: GitHubCommandRunnerOptions): Promise<string> {
|
||||
const ghPath = await deps.resolveGhPath();
|
||||
if (!ghPath) {
|
||||
throw new GitHubCliMissingError();
|
||||
}
|
||||
try {
|
||||
const result = await deps.runner(args, options);
|
||||
const result = await deps.runner(args, runOptions);
|
||||
return result.stdout.trim();
|
||||
} catch (error) {
|
||||
throw normalizeGitHubCommandError(error, {
|
||||
args,
|
||||
cwd: options.cwd,
|
||||
cwd: runOptions.cwd,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function getPollTargetKey(options: { cwd: string; headRef: string }): string {
|
||||
function getPollTargetKey(target: { cwd: string; headRef: string }): string {
|
||||
return buildCacheKey({
|
||||
cwd: options.cwd,
|
||||
cwd: target.cwd,
|
||||
method: "getCurrentPullRequestStatus",
|
||||
args: { headRef: options.headRef },
|
||||
args: { headRef: target.headRef },
|
||||
});
|
||||
}
|
||||
|
||||
function updatePollTargetAfterSuccess(options: {
|
||||
function updatePollTargetAfterSuccess(update: {
|
||||
cwd: string;
|
||||
headRef: string;
|
||||
status: GitHubCurrentPullRequestStatus | null;
|
||||
notify: boolean;
|
||||
}): void {
|
||||
const target = pollTargets.get(getPollTargetKey(options));
|
||||
const target = pollTargets.get(getPollTargetKey(update));
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
|
||||
target.latestStatus = options.status;
|
||||
target.latestStatus = update.status;
|
||||
target.consecutiveErrors = 0;
|
||||
if (options.notify) {
|
||||
if (update.notify) {
|
||||
for (const callback of target.callbacks) {
|
||||
callback(options.status);
|
||||
callback(update.status);
|
||||
}
|
||||
}
|
||||
scheduleGitHubPoll(target);
|
||||
@@ -740,91 +740,91 @@ export function createGitHubService(options: CreateGitHubServiceOptions = {}): G
|
||||
}
|
||||
|
||||
api = {
|
||||
listPullRequests(options) {
|
||||
listPullRequests(input) {
|
||||
return cached({
|
||||
cwd: options.cwd,
|
||||
cwd: input.cwd,
|
||||
method: "listPullRequests",
|
||||
args: { query: options.query ?? "", limit: options.limit ?? 20 },
|
||||
readOptions: options,
|
||||
args: { query: input.query ?? "", limit: input.limit ?? 20 },
|
||||
readOptions: input,
|
||||
load: async () => {
|
||||
const stdout = await run(
|
||||
[
|
||||
"pr",
|
||||
"list",
|
||||
"--search",
|
||||
options.query ?? "",
|
||||
input.query ?? "",
|
||||
"--json",
|
||||
"number,title,url,state,body,labels,baseRefName,headRefName,updatedAt",
|
||||
"--limit",
|
||||
String(options.limit ?? 20),
|
||||
String(input.limit ?? 20),
|
||||
],
|
||||
{ cwd: options.cwd },
|
||||
{ cwd: input.cwd },
|
||||
);
|
||||
return parsePullRequestSummaries(stdout);
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
listIssues(options) {
|
||||
listIssues(input) {
|
||||
return cached({
|
||||
cwd: options.cwd,
|
||||
cwd: input.cwd,
|
||||
method: "listIssues",
|
||||
args: { query: options.query ?? "", limit: options.limit ?? 20 },
|
||||
readOptions: options,
|
||||
args: { query: input.query ?? "", limit: input.limit ?? 20 },
|
||||
readOptions: input,
|
||||
load: async () => {
|
||||
const stdout = await run(
|
||||
[
|
||||
"issue",
|
||||
"list",
|
||||
"--search",
|
||||
options.query ?? "",
|
||||
input.query ?? "",
|
||||
"--json",
|
||||
"number,title,url,state,body,labels,updatedAt",
|
||||
"--limit",
|
||||
String(options.limit ?? 20),
|
||||
String(input.limit ?? 20),
|
||||
],
|
||||
{ cwd: options.cwd },
|
||||
{ cwd: input.cwd },
|
||||
);
|
||||
return parseIssueSummaries(stdout);
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
getPullRequest(options) {
|
||||
getPullRequest(input) {
|
||||
return cached({
|
||||
cwd: options.cwd,
|
||||
cwd: input.cwd,
|
||||
method: "getPullRequest",
|
||||
args: { number: options.number },
|
||||
readOptions: options,
|
||||
args: { number: input.number },
|
||||
readOptions: input,
|
||||
load: async () => {
|
||||
const stdout = await run(
|
||||
[
|
||||
"pr",
|
||||
"view",
|
||||
String(options.number),
|
||||
String(input.number),
|
||||
"--json",
|
||||
"number,title,url,state,body,labels,baseRefName,headRefName,updatedAt",
|
||||
],
|
||||
{ cwd: options.cwd },
|
||||
{ cwd: input.cwd },
|
||||
);
|
||||
return parsePullRequestSummary(stdout);
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
async getPullRequestHeadRef(options) {
|
||||
const pullRequest = await this.getPullRequest(options);
|
||||
async getPullRequestHeadRef(input) {
|
||||
const pullRequest = await this.getPullRequest(input);
|
||||
return pullRequest.headRefName;
|
||||
},
|
||||
|
||||
getPullRequestCheckoutTarget(options) {
|
||||
getPullRequestCheckoutTarget(input) {
|
||||
return cached({
|
||||
cwd: options.cwd,
|
||||
cwd: input.cwd,
|
||||
method: "getPullRequestCheckoutTarget",
|
||||
args: { number: options.number },
|
||||
readOptions: options,
|
||||
args: { number: input.number },
|
||||
readOptions: input,
|
||||
load: async () => {
|
||||
const repo = await getGitHubRepoView({ cwd: options.cwd, run });
|
||||
const repo = await getGitHubRepoView({ cwd: input.cwd, run });
|
||||
const owner = repo?.owner?.login;
|
||||
const name = repo?.name;
|
||||
if (!owner || !name) {
|
||||
@@ -842,49 +842,49 @@ export function createGitHubService(options: CreateGitHubServiceOptions = {}): G
|
||||
"-F",
|
||||
`name=${name}`,
|
||||
"-F",
|
||||
`number=${options.number}`,
|
||||
`number=${input.number}`,
|
||||
],
|
||||
{ cwd: options.cwd },
|
||||
{ cwd: input.cwd },
|
||||
);
|
||||
return parsePullRequestCheckoutTarget(stdout);
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
getCurrentPullRequestStatus(options) {
|
||||
getCurrentPullRequestStatus(input) {
|
||||
return cached({
|
||||
cwd: options.cwd,
|
||||
cwd: input.cwd,
|
||||
method: "getCurrentPullRequestStatus",
|
||||
args: {
|
||||
headRef: options.headRef,
|
||||
headRepositoryOwner: options.headRepositoryOwner,
|
||||
headRef: input.headRef,
|
||||
headRepositoryOwner: input.headRepositoryOwner,
|
||||
},
|
||||
readOptions: options,
|
||||
readOptions: input,
|
||||
load: async () => {
|
||||
return resolveCurrentPullRequestView({
|
||||
cwd: options.cwd,
|
||||
headRef: options.headRef,
|
||||
headRepositoryOwner: options.headRepositoryOwner,
|
||||
cwd: input.cwd,
|
||||
headRef: input.headRef,
|
||||
headRepositoryOwner: input.headRepositoryOwner,
|
||||
run,
|
||||
});
|
||||
},
|
||||
}).then((status) => {
|
||||
updatePollTargetAfterSuccess({
|
||||
cwd: options.cwd,
|
||||
headRef: options.headRef,
|
||||
cwd: input.cwd,
|
||||
headRef: input.headRef,
|
||||
status,
|
||||
notify: options.reason === "self-heal-github",
|
||||
notify: input.reason === "self-heal-github",
|
||||
});
|
||||
return status;
|
||||
});
|
||||
},
|
||||
|
||||
getPullRequestTimeline(options) {
|
||||
getPullRequestTimeline(input) {
|
||||
return cached({
|
||||
cwd: options.cwd,
|
||||
cwd: input.cwd,
|
||||
method: "getPullRequestTimeline",
|
||||
args: { prNumber: options.prNumber },
|
||||
readOptions: options,
|
||||
args: { prNumber: input.prNumber },
|
||||
readOptions: input,
|
||||
load: async () => {
|
||||
try {
|
||||
const stdout = await run(
|
||||
@@ -894,24 +894,24 @@ export function createGitHubService(options: CreateGitHubServiceOptions = {}): G
|
||||
"-f",
|
||||
`query=${PULL_REQUEST_TIMELINE_QUERY}`,
|
||||
"-F",
|
||||
`owner=${options.repoOwner}`,
|
||||
`owner=${input.repoOwner}`,
|
||||
"-F",
|
||||
`name=${options.repoName}`,
|
||||
`name=${input.repoName}`,
|
||||
"-F",
|
||||
`number=${options.prNumber}`,
|
||||
`number=${input.prNumber}`,
|
||||
],
|
||||
{ cwd: options.cwd },
|
||||
{ cwd: input.cwd },
|
||||
);
|
||||
return parsePullRequestTimeline(stdout, {
|
||||
prNumber: options.prNumber,
|
||||
repoOwner: options.repoOwner,
|
||||
repoName: options.repoName,
|
||||
prNumber: input.prNumber,
|
||||
repoOwner: input.repoOwner,
|
||||
repoName: input.repoName,
|
||||
});
|
||||
} catch (error) {
|
||||
return {
|
||||
prNumber: options.prNumber,
|
||||
repoOwner: options.repoOwner,
|
||||
repoName: options.repoName,
|
||||
prNumber: input.prNumber,
|
||||
repoOwner: input.repoOwner,
|
||||
repoName: input.repoName,
|
||||
items: [],
|
||||
truncated: false,
|
||||
error: mapPullRequestTimelineError(error),
|
||||
@@ -921,31 +921,31 @@ export function createGitHubService(options: CreateGitHubServiceOptions = {}): G
|
||||
});
|
||||
},
|
||||
|
||||
async searchIssuesAndPrs(options) {
|
||||
if (options.force && !options.reason) {
|
||||
async searchIssuesAndPrs(input) {
|
||||
if (input.force && !input.reason) {
|
||||
throw new Error("GitHubService forced read requires a reason");
|
||||
}
|
||||
|
||||
const kinds = options.kinds ?? ["github-issue", "github-pr"];
|
||||
const kinds = input.kinds ?? ["github-issue", "github-pr"];
|
||||
const shouldFetchIssues = kinds.includes("github-issue");
|
||||
const shouldFetchPullRequests = kinds.includes("github-pr");
|
||||
const readOptions: GitHubReadOptions = options.force
|
||||
? { force: true, reason: options.reason }
|
||||
: { force: false, reason: options.reason };
|
||||
const readOptions: GitHubReadOptions = input.force
|
||||
? { force: true, reason: input.reason }
|
||||
: { force: false, reason: input.reason };
|
||||
const [issuesResult, prsResult] = await Promise.allSettled([
|
||||
shouldFetchIssues
|
||||
? this.listIssues({
|
||||
cwd: options.cwd,
|
||||
query: options.query,
|
||||
limit: options.limit,
|
||||
cwd: input.cwd,
|
||||
query: input.query,
|
||||
limit: input.limit,
|
||||
...readOptions,
|
||||
})
|
||||
: Promise.resolve(null),
|
||||
shouldFetchPullRequests
|
||||
? this.listPullRequests({
|
||||
cwd: options.cwd,
|
||||
query: options.query,
|
||||
limit: options.limit,
|
||||
cwd: input.cwd,
|
||||
query: input.query,
|
||||
limit: input.limit,
|
||||
...readOptions,
|
||||
})
|
||||
: Promise.resolve(null),
|
||||
@@ -1011,21 +1011,14 @@ export function createGitHubService(options: CreateGitHubServiceOptions = {}): G
|
||||
return { items, githubFeaturesEnabled: true };
|
||||
},
|
||||
|
||||
async createPullRequest(options) {
|
||||
const args = [
|
||||
"api",
|
||||
"-X",
|
||||
"POST",
|
||||
`repos/${options.repo}/pulls`,
|
||||
"-f",
|
||||
`title=${options.title}`,
|
||||
];
|
||||
args.push("-f", `head=${options.head}`);
|
||||
args.push("-f", `base=${options.base}`);
|
||||
if (options.body) {
|
||||
args.push("-f", `body=${options.body}`);
|
||||
async createPullRequest(input) {
|
||||
const args = ["api", "-X", "POST", `repos/${input.repo}/pulls`, "-f", `title=${input.title}`];
|
||||
args.push("-f", `head=${input.head}`);
|
||||
args.push("-f", `base=${input.base}`);
|
||||
if (input.body) {
|
||||
args.push("-f", `body=${input.body}`);
|
||||
}
|
||||
const stdout = await run(args, { cwd: options.cwd });
|
||||
const stdout = await run(args, { cwd: input.cwd });
|
||||
const parsed = z
|
||||
.object({
|
||||
url: z.string(),
|
||||
@@ -1035,15 +1028,15 @@ export function createGitHubService(options: CreateGitHubServiceOptions = {}): G
|
||||
return parsed;
|
||||
},
|
||||
|
||||
isAuthenticated(options) {
|
||||
isAuthenticated(input) {
|
||||
return cached({
|
||||
cwd: options.cwd,
|
||||
cwd: input.cwd,
|
||||
method: "isAuthenticated",
|
||||
args: {},
|
||||
readOptions: options,
|
||||
readOptions: input,
|
||||
load: async () => {
|
||||
try {
|
||||
await run(["auth", "status"], { cwd: options.cwd });
|
||||
await run(["auth", "status"], { cwd: input.cwd });
|
||||
return true;
|
||||
} catch (error) {
|
||||
if (isGitHubAuthenticationError(error)) {
|
||||
@@ -1058,13 +1051,13 @@ export function createGitHubService(options: CreateGitHubServiceOptions = {}): G
|
||||
});
|
||||
},
|
||||
|
||||
retainCurrentPullRequestStatusPoll(options) {
|
||||
const key = getPollTargetKey(options);
|
||||
retainCurrentPullRequestStatusPoll(input) {
|
||||
const key = getPollTargetKey(input);
|
||||
let target = pollTargets.get(key);
|
||||
if (!target) {
|
||||
target = {
|
||||
cwd: options.cwd,
|
||||
headRef: options.headRef,
|
||||
cwd: input.cwd,
|
||||
headRef: input.headRef,
|
||||
retainCount: 0,
|
||||
timer: null,
|
||||
latestStatus: null,
|
||||
@@ -1077,11 +1070,11 @@ export function createGitHubService(options: CreateGitHubServiceOptions = {}): G
|
||||
|
||||
const isNewlyRetained = target.retainCount === 0;
|
||||
target.retainCount += 1;
|
||||
if (options.onStatus) {
|
||||
target.callbacks.add(options.onStatus);
|
||||
if (input.onStatus) {
|
||||
target.callbacks.add(input.onStatus);
|
||||
}
|
||||
if (options.onError) {
|
||||
target.errorCallbacks.add(options.onError);
|
||||
if (input.onError) {
|
||||
target.errorCallbacks.add(input.onError);
|
||||
}
|
||||
if (isNewlyRetained) {
|
||||
scheduleImmediateGitHubPoll(target);
|
||||
@@ -1096,11 +1089,11 @@ export function createGitHubService(options: CreateGitHubServiceOptions = {}): G
|
||||
return;
|
||||
}
|
||||
unsubscribed = true;
|
||||
if (options.onStatus) {
|
||||
target.callbacks.delete(options.onStatus);
|
||||
if (input.onStatus) {
|
||||
target.callbacks.delete(input.onStatus);
|
||||
}
|
||||
if (options.onError) {
|
||||
target.errorCallbacks.delete(options.onError);
|
||||
if (input.onError) {
|
||||
target.errorCallbacks.delete(input.onError);
|
||||
}
|
||||
target.retainCount -= 1;
|
||||
if (target.retainCount > 0) {
|
||||
@@ -1112,16 +1105,16 @@ export function createGitHubService(options: CreateGitHubServiceOptions = {}): G
|
||||
};
|
||||
},
|
||||
|
||||
invalidate(options) {
|
||||
invalidate(input) {
|
||||
// Local checkout mutations that can alter the current PR identity or PR status
|
||||
// must call this with the affected cwd before broadcasting fresh git state.
|
||||
for (const [key, entry] of cache.entries()) {
|
||||
if (entry.cwd === options.cwd) {
|
||||
if (entry.cwd === input.cwd) {
|
||||
cache.delete(key);
|
||||
}
|
||||
}
|
||||
for (const [key, entry] of inFlight.entries()) {
|
||||
if (entry.cwd === options.cwd) {
|
||||
if (entry.cwd === input.cwd) {
|
||||
inFlight.delete(key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -906,12 +906,12 @@ export async function createTerminal(options: CreateTerminalOptions): Promise<Te
|
||||
});
|
||||
}
|
||||
|
||||
async function killAndWait(options?: {
|
||||
async function killAndWait(killOptions?: {
|
||||
gracefulTimeoutMs?: number;
|
||||
forceTimeoutMs?: number;
|
||||
}): Promise<void> {
|
||||
const gracefulTimeoutMs = options?.gracefulTimeoutMs ?? 2000;
|
||||
const forceTimeoutMs = options?.forceTimeoutMs ?? 1000;
|
||||
const gracefulTimeoutMs = killOptions?.gracefulTimeoutMs ?? 2000;
|
||||
const forceTimeoutMs = killOptions?.forceTimeoutMs ?? 1000;
|
||||
|
||||
if (processExited) {
|
||||
kill();
|
||||
|
||||
@@ -399,7 +399,7 @@ async function execSetupCommandStreamed(options: {
|
||||
total: number;
|
||||
onEvent?: (event: WorktreeSetupCommandProgressEvent) => void;
|
||||
}): Promise<WorktreeSetupCommandResult> {
|
||||
return new Promise((resolve) => {
|
||||
return new Promise((resolvePromise) => {
|
||||
const startedAt = Date.now();
|
||||
const stdoutChunks: string[] = [];
|
||||
const stderrChunks: string[] = [];
|
||||
@@ -450,7 +450,7 @@ async function execSetupCommandStreamed(options: {
|
||||
stdout: result.stdout,
|
||||
stderr: result.stderr,
|
||||
});
|
||||
resolve(result);
|
||||
resolvePromise(result);
|
||||
};
|
||||
|
||||
options.onEvent?.({
|
||||
@@ -513,7 +513,7 @@ async function execSetupCommandStreamed(options: {
|
||||
}
|
||||
|
||||
async function getAvailablePort(): Promise<number> {
|
||||
return new Promise((resolve, reject) => {
|
||||
return new Promise((resolvePromise, reject) => {
|
||||
const server = net.createServer();
|
||||
server.once("error", reject);
|
||||
server.listen(0, () => {
|
||||
@@ -527,14 +527,14 @@ async function getAvailablePort(): Promise<number> {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
resolve(address.port);
|
||||
resolvePromise(address.port);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function assertPortAvailable(port: number): Promise<void> {
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
await new Promise<void>((resolvePromise, reject) => {
|
||||
const server = net.createServer();
|
||||
server.once("error", (error: NodeJS.ErrnoException) => {
|
||||
let message: string;
|
||||
@@ -553,7 +553,7 @@ async function assertPortAvailable(port: number): Promise<void> {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
resolve();
|
||||
resolvePromise();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1183,7 +1183,7 @@ async function removeDirectoryWithRetries(path: string): Promise<void> {
|
||||
let lastError: unknown = null;
|
||||
for (const delay of delaysMs) {
|
||||
if (delay > 0) {
|
||||
await new Promise((resolve) => setTimeout(resolve, delay));
|
||||
await new Promise((resolvePromise) => setTimeout(resolvePromise, delay));
|
||||
}
|
||||
try {
|
||||
await rm(path, { recursive: true, force: true });
|
||||
|
||||
Reference in New Issue
Block a user