(metadata: MakaPiTranscriptMetadata, width: number)
| 1307 | } |
| 1308 | |
| 1309 | export function renderMakaPiStatusLine(metadata: MakaPiTranscriptMetadata, width: number): string { |
| 1310 | const safeWidth = Math.max(1, width); |
| 1311 | const sep = ansi.dim(' · '); |
| 1312 | const parts: string[] = [ |
| 1313 | ansi.bold(metadata.title), |
| 1314 | ansi.dim(permissionModeLabel(metadata.permissionMode)), |
| 1315 | ansi.dim(metadata.model), |
| 1316 | ]; |
| 1317 | // #1064: omit thinking:default — it is noise before the user explicitly |
| 1318 | // changes the level. Only a non-default, explicitly set level shows. |
| 1319 | if (metadata.thinkingLevel) { |
| 1320 | parts.push(ansi.dim(`thinking:${metadata.thinkingLevel}`)); |
| 1321 | } |
| 1322 | if (metadata.orchestrationMode === 'swarm') { |
| 1323 | parts.push(ansi.accent('swarm')); |
| 1324 | } else if (metadata.orchestrationMode === 'graph') { |
| 1325 | parts.push(ansi.accent('graph')); |
| 1326 | } |
| 1327 | const usage = metadata.usage; |
| 1328 | if (usage) { |
| 1329 | // ctx segment: only show when contextRemaining is available, since |
| 1330 | // token_usage.input is a billing-cumulative sum across tool-loop steps, |
| 1331 | // not the last request's context size. Using it as a proxy for "used" |
| 1332 | // would produce misleading percentages (potentially >100%). |
| 1333 | if (metadata.modelContextWindow !== undefined && usage.contextRemaining !== undefined) { |
| 1334 | const used = Math.max(0, metadata.modelContextWindow - usage.contextRemaining); |
| 1335 | const pct = Math.round((used / metadata.modelContextWindow) * 100); |
| 1336 | // #1064: color warning — yellow >80%, red >95%, dim otherwise. |
| 1337 | const ctxColor = pct > 95 ? ansi.red : pct > 80 ? ansi.yellow : ansi.dim; |
| 1338 | parts.push( |
| 1339 | ctxColor( |
| 1340 | `ctx ${formatTokenCount(used)}/${formatTokenCount(metadata.modelContextWindow)} ${pct}%`, |
| 1341 | ), |
| 1342 | ); |
| 1343 | } |
| 1344 | if (usage.costUsd > 0) { |
| 1345 | parts.push(ansi.dim(`$${formatCost(usage.costUsd)}`)); |
| 1346 | } |
| 1347 | const totalCache = usage.cacheHitInput + usage.cacheMissInput; |
| 1348 | if (totalCache > 0) { |
| 1349 | const hitRate = Math.round((usage.cacheHitInput / totalCache) * 100); |
| 1350 | parts.push(ansi.dim(`cache ${hitRate}%`)); |
| 1351 | } |
| 1352 | } |
| 1353 | parts.push(ansi.dim(metadata.connectionSlug)); |
| 1354 | // #1064: shorten cwd to ~-relative path instead of the full path. |
| 1355 | parts.push(ansi.dim(shortenCwd(metadata.cwd))); |
| 1356 | return fitLine(parts.join(sep), safeWidth); |
| 1357 | } |
| 1358 | |
| 1359 | /** |
| 1360 | * One-line activity strip shown between the transcript and the editor. |
no test coverage detected