Files
EasyCLIProxyAPI/src/services/codexSessionState.ts
T
lzt404 d0bd5a890a Dev (#162)
* chore(release): stop publishing legacy Windows update packages

* feat(agents): support OpenCode Desktop across platforms

Detect CLI and desktop installations on Windows, macOS, and Linux, and add separate launch and restart controls.

Closes #156

* fix(codex): align model display names and show total session count

- preserve runtime model identity in generated catalogs
- count distinct sessions across database and rollout sources
- update session count labels in all supported languages

* fix(codex): keep config and auth files in sync

- generate auth.json for API key configuration
- preserve and validate OAuth credentials
- include auth.json in transactional updates and rollback
- retain compatibility with legacy Codex configuration states

* fix(cpa-gui): update version to 0.2.59 in Cargo files
2026-08-23 16:19:03 +08:00

90 lines
2.1 KiB
TypeScript

export type CodexSessionSummary = {
id: string;
title: string;
cwd: string;
modelProvider: string;
archived: boolean;
updatedAtMs: number | null;
databasePath: string;
};
export type CodexSessionPage = {
codexHome: string;
databasePaths: string[];
sessions: CodexSessionSummary[];
totalCount: number;
offset: number;
limit: number;
hasMore: boolean;
warnings: string[];
};
export type CodexSessionDeleteResult = {
sessionId: string;
status: 'deleted' | 'partial' | 'notFound' | 'failed';
message: string;
backupPath: string | null;
};
export type CodexSessionDeleteBatchResult = {
results: CodexSessionDeleteResult[];
deletedCount: number;
failedCount: number;
};
export type CodexSessionRepairProgress = {
phase: 'scanning' | 'backingUp' | 'rewriting' | 'updatingDatabase' | 'complete';
percent: number;
processed: number;
total: number;
};
export type CodexSessionRepairResult = {
targetProvider: string;
changedRolloutFiles: number;
sqliteRowsUpdated: number;
skippedLockedFiles: string[];
backupPath: string | null;
encryptedContentWarning: string | null;
warnings: string[];
};
export type SessionIndexCleanupCandidate = {
id: string;
threadName: string;
updatedAt: string;
};
export type SessionIndexCleanupPreview = {
snapshotSha256: string;
candidates: SessionIndexCleanupCandidate[];
};
export type SessionIndexCleanupResult = {
prunedEntries: number;
backupPath: string | null;
};
export type CodexSessionPageCounts = {
active: number;
archived: number;
};
export function codexSessionPageCounts(
sessions: readonly Pick<CodexSessionSummary, 'archived'>[],
): CodexSessionPageCounts {
const archived = sessions.reduce(
(count, session) => count + Number(session.archived),
0,
);
return { active: sessions.length - archived, archived };
}
export function retainVisibleCodexSessionIds(
selectedIds: ReadonlySet<string>,
sessions: readonly Pick<CodexSessionSummary, 'id'>[],
): Set<string> {
const visibleIds = new Set(sessions.map((session) => session.id));
return new Set(Array.from(selectedIds).filter((id) => visibleIds.has(id)));
}