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

Function createNextDefaultThreadTitle

src/core/bridge_session_service.ts:868–880  ·  view source on GitHub ↗
(titles: Array<string | null | undefined>)

Source from the content-addressed store, hash-verified

866}
867
868function createNextDefaultThreadTitle(titles: Array<string | null | undefined>): string {
869 let max = 0;
870 const pattern = new RegExp(`^${escapeRegExp(DEFAULT_THREAD_TITLE_PREFIX)}(\\d{5})$`, 'u');
871 for (const title of titles) {
872 const match = normalizeThreadTitle(title)?.match(pattern);
873 if (!match) {
874 continue;
875 }
876 max = Math.max(max, Number(match[1]));
877 }
878 const next = max >= 99999 ? 1 : max + 1;
879 return `${DEFAULT_THREAD_TITLE_PREFIX}${String(next).padStart(5, '0')}`;
880}
881
882function escapeRegExp(value: string): string {
883 return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');

Callers 1

Calls 2

normalizeThreadTitleFunction · 0.85
escapeRegExpFunction · 0.70

Tested by

no test coverage detected