honeytree 1.2.5 → 1.2.7

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": "honeytree",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "description": "code with claude, and watch your forest grow! ",
5
5
  "type": "module",
6
6
  "bin": {
@@ -11,7 +11,6 @@ const STATS_TEXT = "#8e8a84";
11
11
  const STATS_WARN = "#c4653a";
12
12
  const STREAK_COLOR = "#e8a33a";
13
13
  const BAR_FILL = "#6cb95e";
14
- const BAR_EMPTY = "#3d3d3d";
15
14
 
16
15
  export default function StatsBar({ forest, viewportX, termWidth, rewards }) {
17
16
  const vw = getVirtualWidth(forest.trees.length, termWidth);
@@ -20,19 +19,17 @@ export default function StatsBar({ forest, viewportX, termWidth, rewards }) {
20
19
  [forest, viewportX, vw, termWidth],
21
20
  );
22
21
 
23
- const barWidth = 12;
24
- const filledWidth = Math.max(0, Math.min(barWidth, Math.round(stats.progress * barWidth)));
25
-
26
22
  // Minimap
27
23
  let minimap = null;
28
24
  if (stats.virtualWidth > stats.termWidth) {
29
25
  const mapWidth = 12;
30
26
  const viewFraction = stats.termWidth / stats.virtualWidth;
31
- const thumbWidth = Math.max(1, Math.round(viewFraction * mapWidth));
27
+ // Clamp everything: viewportX can be stale (resize, forest re-layout) and
28
+ // rounding can overshoot — a negative .repeat() crashes the whole frame.
29
+ const thumbWidth = Math.max(1, Math.min(mapWidth, Math.round(viewFraction * mapWidth)));
32
30
  const maxOffset = stats.virtualWidth - stats.termWidth;
33
- const thumbPos = maxOffset > 0
34
- ? Math.round((stats.viewportX / maxOffset) * (mapWidth - thumbWidth))
35
- : 0;
31
+ const ratio = maxOffset > 0 ? Math.min(1, Math.max(0, stats.viewportX / maxOffset)) : 0;
32
+ const thumbPos = Math.round(ratio * (mapWidth - thumbWidth));
36
33
  const mapBar =
37
34
  "─".repeat(thumbPos) +
38
35
  "═".repeat(thumbWidth) +
@@ -55,11 +52,6 @@ export default function StatsBar({ forest, viewportX, termWidth, rewards }) {
55
52
  h(Text, { color: STATS_ACCENT }, " honeytree"),
56
53
  h(Text, { color: STATS_TEXT }, ` · ${stats.treeCount} tree${stats.treeCount === 1 ? "" : "s"} · `),
57
54
  streakSegment,
58
- h(Text, { color: STATS_TEXT }, " · "),
59
- h(Text, { color: BAR_FILL }, "█".repeat(filledWidth)),
60
- h(Text, { color: BAR_EMPTY }, "░".repeat(barWidth - filledWidth)),
61
- h(Text, { color: STATS_TEXT }, ` next: ${stats.nextTreeType}`),
62
- h(Text, { color: "#555555" }, ` [${stats.biomeName}]`),
63
55
  minimap,
64
56
  ),
65
57
  h(Box, null,
package/src/renderer.js CHANGED
@@ -274,11 +274,12 @@ function buildStatsLine(forest, biome, viewportX = 0, virtualWidth = 0, termWidt
274
274
  if (virtualWidth > termWidth) {
275
275
  const mapWidth = 12;
276
276
  const viewFraction = termWidth / virtualWidth;
277
- const thumbWidth = Math.max(1, Math.round(viewFraction * mapWidth));
277
+ // Clamp everything: viewportX can be stale (resize, forest re-layout) and
278
+ // rounding can overshoot — a negative .repeat() crashes the whole frame.
279
+ const thumbWidth = Math.max(1, Math.min(mapWidth, Math.round(viewFraction * mapWidth)));
278
280
  const maxOffset = virtualWidth - termWidth;
279
- const thumbPos = maxOffset > 0
280
- ? Math.round((viewportX / maxOffset) * (mapWidth - thumbWidth))
281
- : 0;
281
+ const ratio = maxOffset > 0 ? Math.min(1, Math.max(0, viewportX / maxOffset)) : 0;
282
+ const thumbPos = Math.round(ratio * (mapWidth - thumbWidth));
282
283
  const mapBar =
283
284
  "─".repeat(thumbPos) +
284
285
  "═".repeat(thumbWidth) +