Harden read-only thread handling and refresh Android releases

This commit is contained in:
kris
2026-04-06 13:26:48 +08:00
parent 9d7d2f4d17
commit 3564aeaf2e
18 changed files with 346 additions and 27 deletions

View File

@@ -39,6 +39,21 @@ function trimToDefined(value) {
return trimmed ? trimmed : null;
}
function parseSandboxPolicyType(value) {
const raw = trimToDefined(value);
if (!raw) return null;
try {
const parsed = JSON.parse(raw);
return trimToDefined(parsed?.type) ?? raw;
} catch {
return raw;
}
}
function isReadOnlySandboxPolicy(value) {
return parseSandboxPolicyType(value) === "read-only";
}
function isPrimaryWorkspaceThread(thread) {
return !trimToDefined(thread.agentRole) && !trimToDefined(thread.agentNickname);
}
@@ -104,7 +119,7 @@ function loadThreadsFromStateDb(stateDbPath) {
try {
return db
.prepare(
"SELECT id, cwd, updated_at, archived, title, agent_nickname, agent_role FROM threads WHERE archived = 0 ORDER BY updated_at DESC",
"SELECT id, cwd, updated_at, archived, title, sandbox_policy, agent_nickname, agent_role FROM threads WHERE archived = 0 ORDER BY updated_at DESC",
)
.all()
.map((row) => ({
@@ -113,6 +128,7 @@ function loadThreadsFromStateDb(stateDbPath) {
updatedAtSeconds: Number(row.updated_at),
archived: Boolean(row.archived),
title: String(row.title ?? ""),
sandboxPolicy: typeof row.sandbox_policy === "string" ? row.sandbox_policy : "",
agentNickname: typeof row.agent_nickname === "string" ? row.agent_nickname : "",
agentRole: typeof row.agent_role === "string" ? row.agent_role : "",
}));
@@ -206,6 +222,9 @@ export async function discoverCodexProjectCandidates(options = {}) {
const groupedCandidates = new Map();
for (const thread of threads) {
if (!thread?.id || seenThreadIds.has(thread.id)) continue;
if (isReadOnlySandboxPolicy(thread.sandboxPolicy)) {
continue;
}
const latestActivitySeconds = latestLogByThread.get(thread.id) ?? thread.updatedAtSeconds;
if (!Number.isFinite(latestActivitySeconds) || latestActivitySeconds < cutoffSeconds) {
continue;