perf(main): cache bootstrap transcript context checks
This commit is contained in:
parent
94c09727f1
commit
5a3e59f765
1 changed files with 50 additions and 2 deletions
|
|
@ -731,6 +731,8 @@ interface ParsedBootstrapTranscriptTailLine {
|
||||||
// this line's parse-cache entry (filePath + mtime + size); a file change re-parses
|
// this line's parse-cache entry (filePath + mtime + size); a file change re-parses
|
||||||
// into fresh line objects, so the memo cannot drift from the line's text.
|
// into fresh line objects, so the memo cannot drift from the line's text.
|
||||||
bootstrapFailureReason?: string | null;
|
bootstrapFailureReason?: string | null;
|
||||||
|
bootstrapContextCandidateByTeam?: Map<string, boolean>;
|
||||||
|
bootstrapContextMemberMatchByName?: Map<string, boolean>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ParsedBootstrapTranscriptTailCacheEntry {
|
interface ParsedBootstrapTranscriptTailCacheEntry {
|
||||||
|
|
@ -764,6 +766,50 @@ function isNormalizedBootstrapTranscriptContextMemberText(
|
||||||
return !!normalizedMemberName && normalizedText.includes(normalizedMemberName);
|
return !!normalizedMemberName && normalizedText.includes(normalizedMemberName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCachedBootstrapContextCandidateForLine(
|
||||||
|
line: ParsedBootstrapTranscriptTailLine,
|
||||||
|
normalizedText: string,
|
||||||
|
normalizedTeamName: string
|
||||||
|
): boolean {
|
||||||
|
let candidateByTeam = line.bootstrapContextCandidateByTeam;
|
||||||
|
if (!candidateByTeam) {
|
||||||
|
candidateByTeam = new Map<string, boolean>();
|
||||||
|
line.bootstrapContextCandidateByTeam = candidateByTeam;
|
||||||
|
}
|
||||||
|
const cached = candidateByTeam.get(normalizedTeamName);
|
||||||
|
if (cached !== undefined) {
|
||||||
|
return cached;
|
||||||
|
}
|
||||||
|
const value = isNormalizedBootstrapTranscriptContextCandidateText(
|
||||||
|
normalizedText,
|
||||||
|
normalizedTeamName
|
||||||
|
);
|
||||||
|
candidateByTeam.set(normalizedTeamName, value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCachedBootstrapContextMemberMatchForLine(
|
||||||
|
line: ParsedBootstrapTranscriptTailLine,
|
||||||
|
normalizedText: string,
|
||||||
|
normalizedMemberName: string
|
||||||
|
): boolean {
|
||||||
|
let matchByName = line.bootstrapContextMemberMatchByName;
|
||||||
|
if (!matchByName) {
|
||||||
|
matchByName = new Map<string, boolean>();
|
||||||
|
line.bootstrapContextMemberMatchByName = matchByName;
|
||||||
|
}
|
||||||
|
const cached = matchByName.get(normalizedMemberName);
|
||||||
|
if (cached !== undefined) {
|
||||||
|
return cached;
|
||||||
|
}
|
||||||
|
const value = isNormalizedBootstrapTranscriptContextMemberText(
|
||||||
|
normalizedText,
|
||||||
|
normalizedMemberName
|
||||||
|
);
|
||||||
|
matchByName.set(normalizedMemberName, value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
ActiveToolCall,
|
ActiveToolCall,
|
||||||
AgentActionMode,
|
AgentActionMode,
|
||||||
|
|
@ -30545,14 +30591,16 @@ export class TeamProvisioningService {
|
||||||
}
|
}
|
||||||
const lineNormalizedText = normalizedText ?? '';
|
const lineNormalizedText = normalizedText ?? '';
|
||||||
if (shouldCollectBootstrapContext) {
|
if (shouldCollectBootstrapContext) {
|
||||||
const isBootstrapContextLine = isNormalizedBootstrapTranscriptContextCandidateText(
|
const isBootstrapContextLine = getCachedBootstrapContextCandidateForLine(
|
||||||
|
parsedLine,
|
||||||
lineNormalizedText,
|
lineNormalizedText,
|
||||||
normalizedTeamName
|
normalizedTeamName
|
||||||
);
|
);
|
||||||
if (isBootstrapContextLine) {
|
if (isBootstrapContextLine) {
|
||||||
for (const contextMemberName of normalizedContextMemberNames) {
|
for (const contextMemberName of normalizedContextMemberNames) {
|
||||||
if (
|
if (
|
||||||
isNormalizedBootstrapTranscriptContextMemberText(
|
getCachedBootstrapContextMemberMatchForLine(
|
||||||
|
parsedLine,
|
||||||
lineNormalizedText,
|
lineNormalizedText,
|
||||||
contextMemberName
|
contextMemberName
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue