fix(usage): preserve migrated Go credential discovery

Follow the stored credential selection order so imported keys without an active flag remain discoverable, including when a legacy file is retained.
This commit is contained in:
paseo-bot[bot]
2026-11-04 03:37:39 +00:00
parent 02168446fb
commit 965ee97e4a
2 changed files with 69 additions and 27 deletions
@@ -58,7 +58,8 @@ export function readDatabaseLogin(path: string): DatabaseLogin | null {
if (!tables.length) return null;
const [value] = db
.prepare(
"SELECT value FROM credential WHERE integration_id = ? AND active = 1 ORDER BY time_updated DESC, id DESC LIMIT 1",
// OpenCode also selects migrated rows with no active flag, ordered by creation time.
"SELECT value FROM credential WHERE integration_id = ? ORDER BY active DESC, time_created DESC, id DESC LIMIT 1",
)
.all("opencode-go");
const row = rowSchema.safeParse(value);