History

fix(grok): improve skills, plans, usage, and turn reliability (#8358)

Theo Browne committed 2 months agov0.0.36-nightly.20260827.1204

Commit ead4ce51 parent d3c24a133 files · +3859 −145Browse files

Showing the changes to apps/server/src/usage/usageTranscriptReader.ts (1 of 33 files). Show all

Unified · Split

apps/server/src/usage/usageTranscriptReader.ts+18−1
@@ -22,6 +22,7 @@ import { · 21 unmodified lines
2222 mightCarryUsage,
2323 parseClaudeLine,
2424 parseCodexLine,
25+ parseGrokLine,
2526 type UsageRecord,
2627 } from "./usageTranscripts.ts";
2728
@@ -37,12 +38,18 @@ export interface TranscriptFile { · 9 unmodified lines
3738 * Errors on individual entries are swallowed: session files rotate and get
3839 * removed while the walk is in flight, and a partial listing is far better than
3940 * failing the page.
41+ *
42+ * `fileName` restricts the walk to a single basename (Grok's `updates.jsonl`).
43+ * Grok sessions also ship multi-megabyte `chat_history` and `events` logs that
44+ * never carry usage, so the basename filter keeps a cold scan off those files.
4045 */
4146 export async function listTranscriptFiles(
4247 root: string,
4348 sinceMs: number,
49+ options?: { readonly fileName?: string },
4450 ): Promise<readonly TranscriptFile[]> {
4551 const found: TranscriptFile[] = [];
52+ const fileName = options?.fileName;
4653
4754 const walk = async (dir: string): Promise<void> => {
4855 let entries;
@@ -57,7 +64,11 @@ export async function listTranscriptFiles( · 8 unmodified lines
5764 await walk(child);
5865 continue;
5966 }
60− if (!entry.name.endsWith(".jsonl")) continue;
67+ if (fileName !== undefined) {
68+ if (entry.name !== fileName) continue;
69+ } else if (!entry.name.endsWith(".jsonl")) {
70+ continue;
71+ }
6172 try {
6273 const stats = await NodeFSP.stat(child);
6374 if (stats.mtimeMs >= sinceMs) {
@@ -129,6 +140,12 @@ export async function readTranscriptRecords( · 65 unmodified lines
129140 continue;
130141 }
131142
143+ if (provider === "grok") {
144+ if (!mightCarryUsage(line, provider)) continue;
145+ for (const grokRecord of parseGrokLine(line)) records.push(grokRecord);
146+ continue;
147+ }
148+
132149 if (!mightCarryUsage(line, provider)) continue;
133150 const record = parseClaudeLine(line);
134151 if (record !== null) records.push(record);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t