@thebattlearena/battle-arena-hooks 0.5.3-beta.49 → 0.5.3-beta.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thebattlearena/battle-arena-hooks",
3
- "version": "0.5.3-beta.49",
3
+ "version": "0.5.3-beta.50",
4
4
  "description": "Battle Arena en Claude Code como el plugin `battlearena`: hooks de tracking, objetivo del turno, plan de batalla /battlearena:conquer y el Scorecard de tu día (zero-dependency).",
5
5
  "type": "module",
6
6
  "bin": {
@@ -14,6 +14,8 @@ import { COLORS, duration, points, pointTitle } from './format';
14
14
 
15
15
  /** El margen del panel, igual que en `pane.tsx` (2 + 1 de cada lado). */
16
16
  const GUTTER = 4;
17
+ /** La columna del bullet de cada punto: el bullet y el espacio que lo separa del título. */
18
+ const ICON_WIDTH = 2;
17
19
  const NAVY = '#1B2A4A';
18
20
  const NAVY_LABEL = '#AEB8CC';
19
21
  /** Dónde se responden los emergentes: la pregunta de @battlearena llega al chat de la Oficina. */
@@ -65,7 +67,7 @@ const Scoreboard = (el: Elements, closed: MyDay, columns: number) => {
65
67
  );
66
68
  };
67
69
 
68
- /** «TUS PUNTOS»: cada punto con su ícono y cómo terminó; sin plan ese día, lo trabajado. */
70
+ /** «TUS PUNTOS»: cada punto con su bullet de color y su tiempo, sin número; sin plan ese día, lo trabajado. */
69
71
  const Points = (el: Elements, closed: MyDay, columns: number) => {
70
72
  const { Box, Text } = el;
71
73
  const list = points(closed);
@@ -75,22 +77,29 @@ const Points = (el: Elements, closed: MyDay, columns: number) => {
75
77
  {`Sin plan ese día · trabajaste ${duration(workedMinutes(closed)) || '0m'}`}
76
78
  </Text>
77
79
  );
80
+ const rows = list.map((item) => ({
81
+ item,
82
+ outcome: pointOutcome(item),
83
+ }));
84
+ // La etiqueta nunca se encoge ni se parte: es una columna fija a la derecha y el título se recorta.
85
+ const labelWidth =
86
+ Math.max(...rows.map(({ outcome }) => outcome.label.length)) + 1;
78
87
  return (
79
88
  <Box flexDirection="column">
80
89
  <Text dimColor>TUS PUNTOS</Text>
81
- {list.map((item) => {
82
- const outcome = pointOutcome(closed, item);
83
- return (
84
- <Box key={`close-${item.id}`} width={columns - GUTTER}>
85
- <Box flexGrow={1} flexShrink={1} overflow="hidden">
86
- <Text wrap="truncate-end">
87
- {`${outcome.icon} ${item.pointIndex ?? ''} · ${pointTitle(item)}`}
88
- </Text>
89
- </Box>
90
- <Text color={outcome.color}>{` ${outcome.label}`}</Text>
90
+ {rows.map(({ item, outcome }) => (
91
+ <Box key={`close-${item.id}`} width={columns - GUTTER}>
92
+ <Box width={ICON_WIDTH} flexShrink={0}>
93
+ <Text color={outcome.color}>{outcome.icon}</Text>
91
94
  </Box>
92
- );
93
- })}
95
+ <Box flexGrow={1} flexShrink={1} overflow="hidden">
96
+ <Text wrap="truncate-end">{pointTitle(item)}</Text>
97
+ </Box>
98
+ <Box width={labelWidth} flexShrink={0} justifyContent="flex-end">
99
+ <Text color={outcome.color}>{outcome.label}</Text>
100
+ </Box>
101
+ </Box>
102
+ ))}
94
103
  </Box>
95
104
  );
96
105
  };
@@ -117,30 +117,28 @@ export const scoreBar = (
117
117
 
118
118
  export type PointOutcome = { icon: string; label: string; color: string };
119
119
 
120
- /** ¿El punto tiene una reunión ligada? (va con 📅 en el cierre). */
121
- const hasMeeting = (day: MyDay, item: DayItem): boolean =>
122
- (day.meetings ?? []).some(
123
- (m) => m.pointIndex != null && m.pointIndex === item.pointIndex,
124
- );
125
-
126
120
  /**
127
- * Cómo terminó un punto: entregado ✓, «pasó de Xh» si superó lo estimado, los minutos avanzados o
128
- * «sin tocar». El ícono: ✓ entregado, 📅 con reunión ligada, ◆ con avance, ○ sin tocar.
121
+ * Cómo terminó un punto. El bullet, de color, dice el final (✓ entregado, ● con avance, ○ sin
122
+ * tocar) y la etiqueta solo el tiempo, corta para que quepa en su columna: los minutos, «0m» sin
123
+ * tocar y «+35m» (ámbar) lo que se pasó de lo estimado.
129
124
  */
130
- export const pointOutcome = (day: MyDay, item: DayItem): PointOutcome => {
125
+ export const pointOutcome = (item: DayItem): PointOutcome => {
131
126
  const minutes = item.minutes ?? 0;
132
127
  const estimate = Math.round((item.estimateHours ?? 0) * 60);
133
- const icon = hasMeeting(day, item) ? '📅' : '◆';
134
128
  if (item.status === 'delivered')
135
- return { icon: '✓', label: 'entregado ✓', color: COLORS.delivered };
136
- if (!minutes) return { icon: '○', label: 'sin tocar', color: COLORS.coral };
129
+ return {
130
+ icon: '✓',
131
+ label: duration(minutes) || '0m',
132
+ color: COLORS.delivered,
133
+ };
134
+ if (!minutes) return { icon: '○', label: '0m', color: COLORS.coral };
137
135
  if (estimate && minutes > estimate)
138
136
  return {
139
- icon,
140
- label: `pasó de ${duration(estimate)}`,
137
+ icon: '●',
138
+ label: `+${duration(minutes - estimate)}`,
141
139
  color: COLORS.inProgress,
142
140
  };
143
- return { icon, label: duration(minutes), color: COLORS.delivered };
141
+ return { icon: '●', label: duration(minutes), color: COLORS.delivered };
144
142
  };
145
143
 
146
144
  /** Un emergente está justificado si se contestó con un motivo o como parte de un punto. */
@@ -225,7 +225,7 @@ export const demoDay = (date: string): MyDay => ({
225
225
 
226
226
  /**
227
227
  * El día de muestra ya cerrado: el punto 4 se quedó sin tocar (para ver los cuatro finales:
228
- * entregado, «pasó de 1h», 📅 con su reunión y «sin tocar») y un emergente sin responder.
228
+ * ✓ entregado, ● pasado de su hora «+10m», ● con avance y ○ sin tocar) y un emergente sin responder.
229
229
  */
230
230
  const demoClosedDay = (date: string): MyDay => {
231
231
  const day = demoDay(date);
@@ -482,7 +482,9 @@ const Point = (el: Elements, item: DayItem, m: PaneModel, columns: number) => {
482
482
  <Text wrap="truncate-end">{pointTitle(item)}</Text>
483
483
  </Button>
484
484
  </Box>
485
- <Text color={tone}>{` ${ratio(spent, committed)}`}</Text>
485
+ <Box flexShrink={0}>
486
+ <Text color={tone}>{` ${ratio(spent, committed)}`}</Text>
487
+ </Box>
486
488
  </Box>
487
489
  <Text>
488
490
  <Text color={tone}>{'━'.repeat(used)}</Text>
@@ -127,26 +127,26 @@ test('el marcador: en plan, fuera (emergentes y sin clasificar) y reuniones sin
127
127
  expect(scoreBar({ plan: 0, outside: 0, meetings: 0 }, 40)).toEqual([]);
128
128
  });
129
129
 
130
- test('cada punto con su final: entregado, pasó de Xh, 📅 con reunión y sin tocar', () => {
130
+ test('cada punto: el bullet dice el final y la etiqueta solo el tiempo (+exceso, 0m sin tocar)', () => {
131
131
  const [a, b, c, d] = DAY.items as [DayItem, DayItem, DayItem, DayItem];
132
- expect(pointOutcome(DAY, a)).toEqual({
132
+ expect(pointOutcome(a)).toEqual({
133
133
  icon: '✓',
134
- label: 'entregado ✓',
134
+ label: '3h20',
135
135
  color: COLORS.delivered,
136
136
  });
137
- expect(pointOutcome(DAY, b)).toEqual({
138
- icon: '◆',
139
- label: 'pasó de 3h',
137
+ expect(pointOutcome(b)).toEqual({
138
+ icon: '●',
139
+ label: '+20m',
140
140
  color: COLORS.inProgress,
141
141
  });
142
- expect(pointOutcome(DAY, c)).toEqual({
143
- icon: '📅',
142
+ expect(pointOutcome(c)).toEqual({
143
+ icon: '●',
144
144
  label: '52m',
145
145
  color: COLORS.delivered,
146
146
  });
147
- expect(pointOutcome(DAY, d)).toEqual({
147
+ expect(pointOutcome(d)).toEqual({
148
148
  icon: '○',
149
- label: 'sin tocar',
149
+ label: '0m',
150
150
  color: COLORS.coral,
151
151
  });
152
152
  });
@@ -484,9 +484,9 @@ test('desde las 16:00, sin plan del siguiente día: el modo cierre con el result
484
484
  // 90 + 70 + 0 en los puntos; el emergente justificado (80) va fuera de plan.
485
485
  expect(await ui.find({ type: 'Text', text: /^2h40$/ })).toBeTruthy();
486
486
  expect(await ui.find({ type: 'Text', text: /^1h20$/ })).toBeTruthy();
487
- expect(await ui.find({ type: 'Text', text: /entregado ✓/ })).toBeTruthy();
488
- expect(await ui.find({ type: 'Text', text: /pasó de 1h/ })).toBeFalsy();
489
- expect(await ui.find({ type: 'Text', text: /sin tocar/ })).toBeTruthy();
487
+ expect(await ui.find({ type: 'Text', text: /^✓$/ })).toBeTruthy();
488
+ expect(await ui.find({ type: 'Text', text: /^\+10m$/ })).toBeFalsy();
489
+ expect(await ui.find({ type: 'Text', text: /^0m$/ })).toBeTruthy();
490
490
  expect(
491
491
  await ui.find({ type: 'Text', text: /EMERGENTES · 1 DE 1 JUSTIFICADOS/ }),
492
492
  ).toBeTruthy();
@@ -526,9 +526,9 @@ test('/scorecard-demo cierre muestra la muestra en modo cierre', async ($, on) =
526
526
  expect(
527
527
  await ui.find({ type: 'Text', text: /RESULTADO · MIÉRCOLES 21/ }),
528
528
  ).toBeTruthy();
529
- expect(await ui.find({ type: 'Text', text: /pasó de 1h/ })).toBeTruthy();
530
- expect(await ui.find({ type: 'Text', text: /📅 3 · / })).toBeTruthy();
531
- expect(await ui.find({ type: 'Text', text: /sin tocar/ })).toBeTruthy();
529
+ expect(await ui.find({ type: 'Text', text: /^\+10m$/ })).toBeTruthy();
530
+ expect(await ui.find({ type: 'Text', text: /^●$/ })).toBeTruthy();
531
+ expect(await ui.find({ type: 'Text', text: /^0m$/ })).toBeTruthy();
532
532
  expect(
533
533
  await ui.find({ type: 'Text', text: /EMERGENTES · 1 DE 2 JUSTIFICADOS/ }),
534
534
  ).toBeTruthy();