llm_meta_widget 0.6.0 → 0.6.1
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.
- checksums.yaml +4 -4
- data/app/views/llm_meta_widget/_chat_panel.html.erb +37 -6
- data/lib/llm_meta_widget/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eea94229b42018fa2725d28578dd49970e9d0d3b2bc9bf095b9ac8fced1dcf80
|
|
4
|
+
data.tar.gz: 1b3c95b8632aa46d0bb6e8b338fae6ae2166356912629294e68db480e9124abf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7b6a4f6ac17d8601544fdb3ca94396b3482e66e13f3d5ba765c6d5839b608b17e692af5d7df16b51008a39ad527229193a8ce8d44345eb92feb98c31550f96b5
|
|
7
|
+
data.tar.gz: d8785730a6294fbfe926353c07ed3737add9ea8577a81cfc55471d020cfef51c641fdc735d5297a6701ab9cefe4b5a295df74c75897c84bac0e5f2c30e92f6d9
|
|
@@ -505,23 +505,39 @@
|
|
|
505
505
|
var STORAGE_KEY_OPEN = "llm_meta_widget:open";
|
|
506
506
|
var STORAGE_KEY_SIZE = "llm_meta_widget:size"; // stored as "WxH" in px
|
|
507
507
|
|
|
508
|
+
// Floors matching the CSS min-width/min-height (24em / 16em). A panel
|
|
509
|
+
// measured mid-layout reports a few pixels; saving that produced a sliver
|
|
510
|
+
// anchored off the bottom of the window, and — worse — it was stored, so
|
|
511
|
+
// every later visit reopened at the sliver size. Sizes below the floor are
|
|
512
|
+
// neither saved nor honoured, which also heals a value already stored.
|
|
513
|
+
var MIN_SAVED_WIDTH = 320;
|
|
514
|
+
var MIN_SAVED_HEIGHT = 240;
|
|
515
|
+
|
|
516
|
+
function plausibleSize(w, h) {
|
|
517
|
+
return w >= MIN_SAVED_WIDTH && h >= MIN_SAVED_HEIGHT &&
|
|
518
|
+
w <= window.innerWidth * 2 && h <= window.innerHeight * 2;
|
|
519
|
+
}
|
|
520
|
+
|
|
508
521
|
function applyStoredSize() {
|
|
509
522
|
try {
|
|
510
523
|
var raw = localStorage.getItem(STORAGE_KEY_SIZE);
|
|
511
524
|
if (!raw) return;
|
|
512
525
|
var parts = raw.split("x");
|
|
513
526
|
var w = parseInt(parts[0], 10), h = parseInt(parts[1], 10);
|
|
514
|
-
if (w
|
|
515
|
-
|
|
516
|
-
|
|
527
|
+
if (!plausibleSize(w, h)) {
|
|
528
|
+
localStorage.removeItem(STORAGE_KEY_SIZE); // heal a bad value
|
|
529
|
+
return;
|
|
517
530
|
}
|
|
531
|
+
root.style.width = w + "px";
|
|
532
|
+
root.style.height = h + "px";
|
|
518
533
|
} catch (e) { /* noop */ }
|
|
519
534
|
}
|
|
520
535
|
function saveCurrentSize() {
|
|
521
536
|
try {
|
|
522
537
|
var rect = root.getBoundingClientRect();
|
|
523
|
-
|
|
524
|
-
|
|
538
|
+
var w = Math.round(rect.width), h = Math.round(rect.height);
|
|
539
|
+
if (!plausibleSize(w, h)) return; // layout noise, not a choice
|
|
540
|
+
localStorage.setItem(STORAGE_KEY_SIZE, w + "x" + h);
|
|
525
541
|
} catch (e) { /* noop */ }
|
|
526
542
|
}
|
|
527
543
|
|
|
@@ -529,13 +545,20 @@
|
|
|
529
545
|
// size it currently has. Uses top/left in pixels (required for CSS
|
|
530
546
|
// `resize: both` — a bottom/right-pinned element can't be dragged out
|
|
531
547
|
// past the viewport edge to grow).
|
|
532
|
-
function positionAtBottomRight() {
|
|
548
|
+
function positionAtBottomRight(attempt) {
|
|
533
549
|
var margin = 16; // ~1em from the viewport edges
|
|
534
550
|
var rect = root.getBoundingClientRect();
|
|
535
551
|
var top = Math.max(margin, window.innerHeight - rect.height - margin);
|
|
536
552
|
var left = Math.max(margin, window.innerWidth - rect.width - margin);
|
|
537
553
|
root.style.top = top + "px";
|
|
538
554
|
root.style.left = left + "px";
|
|
555
|
+
|
|
556
|
+
// Measured before layout settled: the panel reports a sliver and gets
|
|
557
|
+
// anchored to the very bottom of the window. Re-measure next frame.
|
|
558
|
+
var tries = attempt || 0;
|
|
559
|
+
if (rect.height < MIN_SAVED_HEIGHT && tries < 3 && typeof requestAnimationFrame === "function") {
|
|
560
|
+
requestAnimationFrame(function() { positionAtBottomRight(tries + 1); });
|
|
561
|
+
}
|
|
539
562
|
}
|
|
540
563
|
|
|
541
564
|
function setOpen(open) {
|
|
@@ -561,6 +584,9 @@
|
|
|
561
584
|
var initialOpen = false;
|
|
562
585
|
try { initialOpen = localStorage.getItem(STORAGE_KEY_OPEN) === "1"; } catch (e) { /* noop */ }
|
|
563
586
|
setOpen(initialOpen);
|
|
587
|
+
window.addEventListener("resize", function() {
|
|
588
|
+
if (!root.classList.contains("lmw-collapsed")) positionAtBottomRight();
|
|
589
|
+
});
|
|
564
590
|
|
|
565
591
|
toggleBtn.addEventListener("click", function() { setOpen(true); });
|
|
566
592
|
hideBtn.addEventListener("click", function() { setOpen(false); });
|
|
@@ -569,9 +595,14 @@
|
|
|
569
595
|
// continuously during a drag; save + reposition on each tick so the
|
|
570
596
|
// widget stays anchored to bottom-right as the user grows it.
|
|
571
597
|
if (typeof ResizeObserver === "function") {
|
|
598
|
+
var sawFirstResizeTick = false;
|
|
572
599
|
var ro = new ResizeObserver(function() {
|
|
573
600
|
if (root.classList.contains("lmw-collapsed")) return;
|
|
574
601
|
positionAtBottomRight();
|
|
602
|
+
// ResizeObserver always delivers an initial observation, and that
|
|
603
|
+
// one reports whatever the layout happened to be mid-boot. Only
|
|
604
|
+
// later ticks can be a user dragging the corner.
|
|
605
|
+
if (!sawFirstResizeTick) { sawFirstResizeTick = true; return; }
|
|
575
606
|
saveCurrentSize();
|
|
576
607
|
});
|
|
577
608
|
ro.observe(root);
|