honeytree 1.2.6 → 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.6",
3
+ "version": "1.2.7",
4
4
  "description": "code with claude, and watch your forest grow! ",
5
5
  "type": "module",
6
6
  "bin": {
@@ -24,11 +24,12 @@ export default function StatsBar({ forest, viewportX, termWidth, rewards }) {
24
24
  if (stats.virtualWidth > stats.termWidth) {
25
25
  const mapWidth = 12;
26
26
  const viewFraction = stats.termWidth / stats.virtualWidth;
27
- 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)));
28
30
  const maxOffset = stats.virtualWidth - stats.termWidth;
29
- const thumbPos = maxOffset > 0
30
- ? Math.round((stats.viewportX / maxOffset) * (mapWidth - thumbWidth))
31
- : 0;
31
+ const ratio = maxOffset > 0 ? Math.min(1, Math.max(0, stats.viewportX / maxOffset)) : 0;
32
+ const thumbPos = Math.round(ratio * (mapWidth - thumbWidth));
32
33
  const mapBar =
33
34
  "─".repeat(thumbPos) +
34
35
  "═".repeat(thumbWidth) +
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) +