@devries-cameron20 / t3code Mirror · read-only / commits / e5ed5c5901
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 17:00 UTC

feat(infra): native client cache panels on the task cache dashboard

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 25, 2026 at 13:38 UTC e5ed5c59017b86aa28c79708c116625cca41bb15
1 file changed +101
infra/task-cache/src/observability.ts
+101
@@ -23,6 +23,19 @@ export const savingsQuery = (
23
24 const summaryRows = (dataset: string) => savingsQuery(dataset).split("\n").slice(0, -1).join("\n");
25
26 +// One row per native-client install report (scripts/mobile-native-client.ts), deduplicated by report id.
27 +const nativeInstalls = (dataset: string) =>
28 + [
29 + `['${dataset}']`,
30 + `| where name == 'TaskCache.task'`,
31 + `| extend a = ['attributes.custom']`,
32 + `| where tostring(a['task.package']) == '@t3tools/mobile' and tostring(a['task.name']) startswith 'native-client'`,
33 + `| extend event_id = tostring(a['cache.event_id']), task = tostring(a['task.name']), source = tostring(a['cache.source']), saved_ms = tolong(a['cache.saved_ms']), host = tostring(['attributes.host.name']), developer = tostring(a['developer.id'])`,
34 + `| summarize arg_max(_time, task, source, saved_ms, host, developer) by event_id`,
35 + ].join("\n");
36 +const nativeCounts =
37 + "local = countif(source == 'local'), remote = countif(source == 'remote'), built = countif(source == 'executed'), failed = countif(source == 'failed')";
38 +
39 export const Observability = Effect.gen(function* () {
40 const name = yield* cacheName;
41 const traces = yield* Axiom.Dataset("CacheTraces", {
@@ -149,6 +162,94 @@ export const Observability = Effect.gen(function* () {
162 query: (dataset: string) =>
163 `${savingsQuery(dataset, "ci", true)}\n| summarize saved_task_hours = sum(saved_task_hours) by environment = iff(ci, "CI", "Developer machines")`,
164 },
165 + {
166 + id: "native-hit-rate",
167 + name: "📱 Native client hit rate (%)",
168 + type: "Statistic",
169 + x: 0,
170 + y: 17,
171 + w: 3,
172 + h: 3,
173 + query: (dataset: string) =>
174 + `${nativeInstalls(dataset)}\n| summarize ${nativeCounts}\n| project hit_rate = round(100.0 * (local + remote) / (local + remote + built), 1)`,
175 + },
176 + {
177 + id: "native-saved",
178 + name: "📱 Native build hours saved",
179 + type: "Statistic",
180 + x: 3,
181 + y: 17,
182 + w: 3,
183 + h: 3,
184 + query: (dataset: string) =>
185 + `${nativeInstalls(dataset)}\n| summarize build_hours_saved = round(sum(saved_ms) / 3600000.0, 1)`,
186 + },
187 + {
188 + id: "native-builds",
189 + name: "📱 Native builds (cache misses)",
190 + type: "Statistic",
191 + x: 6,
192 + y: 17,
193 + w: 3,
194 + h: 3,
195 + query: (dataset: string) =>
196 + `${nativeInstalls(dataset)}\n| summarize builds = countif(source == 'executed')`,
197 + },
198 + {
199 + id: "native-failures",
200 + name: "📱 Native install failures",
201 + type: "Statistic",
202 + x: 9,
203 + y: 17,
204 + w: 3,
205 + h: 3,
206 + query: (dataset: string) =>
207 + `${nativeInstalls(dataset)}\n| summarize failures = countif(source == 'failed')`,
208 + },
209 + {
210 + id: "native-trend",
211 + name: "📱 Native installs: local, shared, built, failed",
212 + type: "TimeSeries",
213 + x: 0,
214 + y: 20,
215 + w: 8,
216 + h: 5,
217 + query: (dataset: string) =>
218 + `${nativeInstalls(dataset)}\n| summarize ${nativeCounts} by bin_auto(_time)`,
219 + },
220 + {
221 + id: "native-host",
222 + name: "📱 Native installs by machine",
223 + type: "Pie",
224 + x: 8,
225 + y: 20,
226 + w: 4,
227 + h: 5,
228 + query: (dataset: string) =>
229 + `${nativeInstalls(dataset)}\n| summarize installs = count() by host\n| order by installs desc`,
230 + },
231 + {
232 + id: "native-platforms",
233 + name: "📱 Native clients by platform",
234 + type: "Table",
235 + x: 0,
236 + y: 25,
237 + w: 8,
238 + h: 4,
239 + query: (dataset: string) =>
240 + `${nativeInstalls(dataset)}\n| summarize ${nativeCounts}, hours_saved = round(sum(saved_ms) / 3600000.0, 2) by task\n| extend hit_rate = round(100.0 * (local + remote) / (local + remote + built), 1)\n| order by local + remote + built desc`,
241 + },
242 + {
243 + id: "native-shared",
244 + name: "📱 Shared cache downloads: hit vs miss",
245 + type: "TimeSeries",
246 + x: 8,
247 + y: 25,
248 + w: 4,
249 + h: 4,
250 + query: (dataset: string) =>
251 + `['${dataset}']\n| where name == 'NativeClients.handle' and tostring(['attributes.custom']['native.operation']) == 'download'\n| extend result = tostring(['attributes.custom']['native.result'])\n| summarize hits = countif(result == 'hit'), misses = countif(result == 'miss') by bin_auto(_time)`,
252 + },
253 ] as const;
254 for (const chart of charts) {
255 yield* Axiom.View(`CacheSavings-${chart.id}`, {