fix: address greptile follow-up
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -11,7 +11,7 @@ function nonEmpty(value: string | undefined): string | null {
|
|||||||
return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function pathExists(candidate: string): Promise<boolean> {
|
export async function pathExists(candidate: string): Promise<boolean> {
|
||||||
return fs.access(candidate).then(() => true).catch(() => false);
|
return fs.access(candidate).then(() => true).catch(() => false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import {
|
|||||||
runChildProcess,
|
runChildProcess,
|
||||||
} from "@paperclipai/adapter-utils/server-utils";
|
} from "@paperclipai/adapter-utils/server-utils";
|
||||||
import { parseCodexJsonl, isCodexUnknownSessionError } from "./parse.js";
|
import { parseCodexJsonl, isCodexUnknownSessionError } from "./parse.js";
|
||||||
import { prepareWorktreeCodexHome, resolveCodexHomeDir } from "./codex-home.js";
|
import { pathExists, prepareWorktreeCodexHome, resolveCodexHomeDir } from "./codex-home.js";
|
||||||
|
|
||||||
const __moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
const __moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
||||||
const CODEX_ROLLOUT_NOISE_RE =
|
const CODEX_ROLLOUT_NOISE_RE =
|
||||||
@@ -61,10 +61,6 @@ function resolveCodexBillingType(env: Record<string, string>): "api" | "subscrip
|
|||||||
return hasNonEmptyEnvValue(env, "OPENAI_API_KEY") ? "api" : "subscription";
|
return hasNonEmptyEnvValue(env, "OPENAI_API_KEY") ? "api" : "subscription";
|
||||||
}
|
}
|
||||||
|
|
||||||
async function pathExists(candidate: string): Promise<boolean> {
|
|
||||||
return fs.access(candidate).then(() => true).catch(() => false);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function isLikelyPaperclipRepoRoot(candidate: string): Promise<boolean> {
|
async function isLikelyPaperclipRepoRoot(candidate: string): Promise<boolean> {
|
||||||
const [hasWorkspace, hasPackageJson, hasServerDir, hasAdapterUtilsDir] = await Promise.all([
|
const [hasWorkspace, hasPackageJson, hasServerDir, hasAdapterUtilsDir] = await Promise.all([
|
||||||
pathExists(path.join(candidate, "pnpm-workspace.yaml")),
|
pathExists(path.join(candidate, "pnpm-workspace.yaml")),
|
||||||
|
|||||||
@@ -78,7 +78,10 @@ export const wakeAgentSchema = z.object({
|
|||||||
reason: z.string().optional().nullable(),
|
reason: z.string().optional().nullable(),
|
||||||
payload: z.record(z.unknown()).optional().nullable(),
|
payload: z.record(z.unknown()).optional().nullable(),
|
||||||
idempotencyKey: z.string().optional().nullable(),
|
idempotencyKey: z.string().optional().nullable(),
|
||||||
forceFreshSession: z.boolean().optional().default(false),
|
forceFreshSession: z.preprocess(
|
||||||
|
(value) => (value === null ? undefined : value),
|
||||||
|
z.boolean().optional().default(false),
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type WakeAgent = z.infer<typeof wakeAgentSchema>;
|
export type WakeAgent = z.infer<typeof wakeAgentSchema>;
|
||||||
|
|||||||
@@ -1115,26 +1115,28 @@ export function issueService(db: Db) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getCommentCursor: async (issueId: string) => {
|
getCommentCursor: async (issueId: string) => {
|
||||||
const latest = await db
|
const [latest, countRow] = await Promise.all([
|
||||||
.select({
|
db
|
||||||
latestCommentId: issueComments.id,
|
.select({
|
||||||
latestCommentAt: issueComments.createdAt,
|
latestCommentId: issueComments.id,
|
||||||
})
|
latestCommentAt: issueComments.createdAt,
|
||||||
.from(issueComments)
|
})
|
||||||
.where(eq(issueComments.issueId, issueId))
|
.from(issueComments)
|
||||||
.orderBy(desc(issueComments.createdAt), desc(issueComments.id))
|
.where(eq(issueComments.issueId, issueId))
|
||||||
.limit(1)
|
.orderBy(desc(issueComments.createdAt), desc(issueComments.id))
|
||||||
.then((rows) => rows[0] ?? null);
|
.limit(1)
|
||||||
|
.then((rows) => rows[0] ?? null),
|
||||||
const [{ totalComments }] = await db
|
db
|
||||||
.select({
|
.select({
|
||||||
totalComments: sql<number>`count(*)::int`,
|
totalComments: sql<number>`count(*)::int`,
|
||||||
})
|
})
|
||||||
.from(issueComments)
|
.from(issueComments)
|
||||||
.where(eq(issueComments.issueId, issueId));
|
.where(eq(issueComments.issueId, issueId))
|
||||||
|
.then((rows) => rows[0] ?? null),
|
||||||
|
]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
totalComments: Number(totalComments ?? 0),
|
totalComments: Number(countRow?.totalComments ?? 0),
|
||||||
latestCommentId: latest?.latestCommentId ?? null,
|
latestCommentId: latest?.latestCommentId ?? null,
|
||||||
latestCommentAt: latest?.latestCommentAt ?? null,
|
latestCommentAt: latest?.latestCommentAt ?? null,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user