MCPcopy Create free account
hub / github.com/QuantaAlpha/claude-code / CollapseLabel

Function CollapseLabel

src/components/TokenWarning.tsx:21–86  ·  view source on GitHub ↗

* Live collapse progress: "x / y summarized". Sub-component so * useSyncExternalStore can subscribe to store mutations unconditionally * (hooks-in-conditionals would violate React rules). The parent only * renders this when feature('CONTEXT_COLLAPSE') + isContextCollapseEnabled().

(t0)

Source from the content-addressed store, hash-verified

19 * renders this when feature('CONTEXT_COLLAPSE') + isContextCollapseEnabled().
20 */
21function CollapseLabel(t0) {
22 const $ = _c(8);
23 const {
24 upgradeMessage
25 } = t0;
26 let t1;
27 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
28 t1 = require("../services/contextCollapse/index.js");
29 $[0] = t1;
30 } else {
31 t1 = $[0];
32 }
33 const {
34 getStats,
35 subscribe
36 } = t1 as typeof import('../services/contextCollapse/index.js');
37 let t2;
38 if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
39 t2 = () => {
40 const s = getStats();
41 const idleWarn = s.health.emptySpawnWarningEmitted ? 1 : 0;
42 return `${s.collapsedSpans}|${s.stagedSpans}|${s.health.totalErrors}|${s.health.totalEmptySpawns}|${idleWarn}`;
43 };
44 $[1] = t2;
45 } else {
46 t2 = $[1];
47 }
48 const snapshot = useSyncExternalStore(subscribe, t2);
49 let t3;
50 if ($[2] !== snapshot) {
51 t3 = snapshot.split("|").map(Number);
52 $[2] = snapshot;
53 $[3] = t3;
54 } else {
55 t3 = $[3];
56 }
57 const [collapsed, staged, errors, emptySpawns, idleWarn_0] = t3 as [number, number, number, number, number];
58 const total = collapsed + staged;
59 if (errors > 0 || idleWarn_0) {
60 const problem = errors > 0 ? `collapse errors: ${errors}` : `collapse idle (${emptySpawns} empty runs)`;
61 const t4 = total > 0 ? `${collapsed} / ${total} summarized \u00b7 ${problem}` : problem;
62 let t5;
63 if ($[4] !== t4) {
64 t5 = <Text color="warning" wrap="truncate">{t4}</Text>;
65 $[4] = t4;
66 $[5] = t5;
67 } else {
68 t5 = $[5];
69 }
70 return t5;
71 }
72 if (total === 0) {
73 return null;
74 }
75 const label = `${collapsed} / ${total} summarized`;
76 const t4 = upgradeMessage ? `${label} \u00b7 ${upgradeMessage}` : label;
77 let t5;
78 if ($[6] !== t4) {

Callers

nothing calls this directly

Calls 1

getStatsFunction · 0.85

Tested by

no test coverage detected