MCPcopy Create free account
hub / github.com/Gan-Xing/CodexBridge / listWebCodexThreads

Function listWebCodexThreads

apps/web/lib/server/queries.ts:729–772  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

727}
728
729export async function listWebCodexThreads(): Promise<WebCodexThreadSummary[]> {
730 const codexSessionIndex = getStoredCodexSessionIndex();
731 const codexSessionMetaMap = getStoredCodexSessionMetaMap();
732 const providers = getStoredProviderProfiles();
733 const threadMetadata = getStoredThreadMetadata();
734 const folderMetadata = getStoredFolderMetadata();
735 const defaultNativeProviderIds = new Set(
736 providers.filter((provider) => provider.providerKind === 'openai-native').map((provider) => provider.id),
737 );
738 const metadataMap = new Map(
739 threadMetadata
740 .filter((metadata) => defaultNativeProviderIds.has(metadata.providerProfileId))
741 .map((metadata) => [metadata.threadId, metadata]),
742 );
743 const folderMetadataMap = new Map(
744 folderMetadata
745 .filter((entry) => typeof entry.cwd === 'string' && entry.cwd.trim())
746 .map((entry) => [entry.cwd.trim(), entry]),
747 );
748
749 const latestIndexMap = new Map<string, StoredCodexSessionIndexEntry>();
750 for (const entry of codexSessionIndex) {
751 const previous = latestIndexMap.get(entry.id);
752 if (!previous || parseMaybeDate(entry.updated_at) >= parseMaybeDate(previous.updated_at)) {
753 latestIndexMap.set(entry.id, entry);
754 }
755 }
756
757 return Array.from(latestIndexMap.values())
758 .filter((entry) => !metadataMap.get(entry.id)?.deletedAt)
759 .map((entry) => ({
760 entry,
761 summary: buildCodexThreadSummary(
762 entry,
763 codexSessionMetaMap.get(entry.id) ?? null,
764 metadataMap.get(entry.id) ?? null,
765 folderMetadataMap.get((codexSessionMetaMap.get(entry.id)?.cwd ?? '').trim()) ?? null,
766 [],
767 ),
768 }))
769 .filter(({ summary }) => !summary.folderRemoved)
770 .map(({ summary }) => summary)
771 .sort((left, right) => right.updatedAt - left.updatedAt);
772}
773
774export async function getWebCodexThreadDetail(threadId: string): Promise<WebCodexThreadDetail | null> {
775 const threadList = await listWebCodexThreads();

Callers 4

SessionsLayoutFunction · 0.90
POSTFunction · 0.90
GETFunction · 0.90
getWebCodexThreadDetailFunction · 0.85

Calls 9

getStoredThreadMetadataFunction · 0.85
getStoredFolderMetadataFunction · 0.85
parseMaybeDateFunction · 0.85
buildCodexThreadSummaryFunction · 0.85
hasMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected