clay-server 2.40.0-beta.2 → 2.40.0-beta.3

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.
@@ -440,6 +440,29 @@ function createXtermForTab(tab) {
440
440
  tab.bodyEl = bodyEl;
441
441
  }
442
442
 
443
+ // Rebuild a tab's WebGL glyph atlas, then force a full redraw.
444
+ //
445
+ // The WebGL renderer caches rasterized glyphs in a texture atlas keyed on
446
+ // the font (family + cell metrics). When the font changes or cell size
447
+ // shifts on resize, the atlas keeps glyphs rasterized from the old state,
448
+ // so text renders garbled until a full repaint rebuilds it. That repaint
449
+ // is exactly what "select all" triggers, which is why selecting everything
450
+ // appears to "fix" the corruption. clearTextureAtlas() forces the rebuild
451
+ // so glyphs re-rasterize at the new font/metrics immediately. Deferred one
452
+ // frame so any preceding fit() has settled. No-op on tabs that fell back to
453
+ // the DOM renderer. Mirrors the resize handler in session-tui-view.js.
454
+ function rebuildTabGlyphAtlas(tab) {
455
+ if (!tab) return;
456
+ requestAnimationFrame(function () {
457
+ if (tab._webglAddon && typeof tab._webglAddon.clearTextureAtlas === "function") {
458
+ try { tab._webglAddon.clearTextureAtlas(); } catch (e) {}
459
+ }
460
+ if (tab.xterm) {
461
+ try { tab.xterm.refresh(0, tab.xterm.rows - 1); } catch (e) {}
462
+ }
463
+ });
464
+ }
465
+
443
466
  // --- Fit active terminal ---
444
467
  var fitRafId = null;
445
468
 
@@ -462,6 +485,9 @@ function fitTerminal() {
462
485
  }));
463
486
  }
464
487
  } catch (e) {}
488
+ // Cell metrics shift on resize; rebuild the WebGL glyph atlas so glyphs
489
+ // don't render against stale cell dimensions.
490
+ rebuildTabGlyphAtlas(tab);
465
491
  });
466
492
  }
467
493
 
@@ -818,7 +844,23 @@ function applyFontToAllTabs(family, size) {
818
844
  if (family) tab.xterm.options.fontFamily = family;
819
845
  if (size) tab.xterm.options.fontSize = size;
820
846
  if (tab.fitAddon) tab.fitAddon.fit();
847
+ // A font-size change shifts cell metrics, so fit() recomputes
848
+ // cols/rows. Notify the PTY of the new size - otherwise the running
849
+ // program keeps drawing to the old dimensions and the output looks
850
+ // corrupted. (Font-family-only changes leave cols/rows unchanged,
851
+ // making this a harmless no-op.) Mirrors fitTerminal()'s resize msg.
852
+ if (ctx.ws && ctx.connected) {
853
+ ctx.ws.send(JSON.stringify({
854
+ type: "term_resize",
855
+ id: tab.id,
856
+ cols: tab.xterm.cols,
857
+ rows: tab.xterm.rows,
858
+ }));
859
+ }
821
860
  } catch (e) {}
861
+ // Changing the font invalidates the WebGL glyph atlas; rebuild it so
862
+ // the new font renders cleanly instead of stale, garbled cached glyphs.
863
+ rebuildTabGlyphAtlas(tab);
822
864
  }
823
865
  }
824
866
  onTerminalFontChange(applyFontToAllTabs);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clay-server",
3
- "version": "2.40.0-beta.2",
3
+ "version": "2.40.0-beta.3",
4
4
  "description": "Self-hosted team workspace for Claude Code and Codex. Multi-user, browser-based, with persistent AI mates.",
5
5
  "bin": {
6
6
  "clay-server": "./bin/cli.js",