@ai-setting/roy-plugin-task-show 2.5.11 → 2.5.12

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.
@@ -0,0 +1,137 @@
1
+ /* ------------------------------------------------------------------------- */
2
+ /* roy-plugin-task-show — Mermaid zoom-stage guardian (v2.5.12 / Task #2951)*/
3
+ /* ------------------------------------------------------------------------- */
4
+ /**
5
+ * Self-contained browser-side mirror of `src/mermaid-zoom-guardian.ts`.
6
+ *
7
+ * Why this exists
8
+ * ---------------
9
+ * Mermaid's library auto-runs `mermaid.run({nodes})` once
10
+ * `startOnLoad: true` is set in `mermaid.initialize`. The auto-runner
11
+ * fires roughly 1.5–3 s after page load (Playwright trace 2026-08-12)
12
+ * and replaces the contents of every `.mermaid` element with a
13
+ * freshly-rendered SVG — including the wrapper our
14
+ * `MermaidRenderer` controller had just attached. After the
15
+ * replacement, the `.mermaid-zoom-stage` wrapper is gone and the
16
+ * pan/zoom handlers stop working.
17
+ *
18
+ * The guardian installs a `MutationObserver` on every `.mermaid`
19
+ * container on the page and re-wraps the SVG whenever the children
20
+ * change. The work is idempotent and cheap (one `querySelector` +
21
+ * one `appendChild` per change).
22
+ *
23
+ * Public API (browser global `window.MermaidZoomGuardian`):
24
+ *
25
+ * ensureMermaidZoomStage(container) → HTMLElement | null
26
+ * new MermaidZoomGuardian(container)
27
+ * .start() // attach observer + wrap current children
28
+ * .stop() // detach observer
29
+ *
30
+ * Why two forms
31
+ * -------------
32
+ * - `ensureMermaidZoomStage` is a one-shot wrapper for the SSR
33
+ * template's `<noscript>` style fallback path.
34
+ * - `MermaidZoomGuardian` is a long-lived watcher for diagrams
35
+ * that survive past the initial paint.
36
+ *
37
+ * The logic mirrors `src/mermaid-zoom-guardian.ts` so SSR + browser
38
+ * agree on what "wrapped" means.
39
+ *
40
+ * Author: dongzhaokun <gddzhaokun@gmail.com>
41
+ */
42
+
43
+ (function (root, factory) {
44
+ const api = factory();
45
+ if (typeof module === "object" && module.exports) {
46
+ module.exports = api;
47
+ }
48
+ if (typeof root === "object" && root) {
49
+ root.MermaidZoomGuardian = api;
50
+ }
51
+ })(typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : this, function () {
52
+ "use strict";
53
+
54
+ var STAGE_CLASS = "mermaid-zoom-stage";
55
+
56
+ function ensureMermaidZoomStage(container) {
57
+ if (!container || typeof container.querySelector !== "function") return null;
58
+ var existing = container.querySelector("." + STAGE_CLASS);
59
+ if (existing) return existing;
60
+ var svg = container.querySelector("svg");
61
+ if (!svg) return null;
62
+
63
+ var doc = container.ownerDocument;
64
+ var stage = doc.createElement("div");
65
+ stage.className = STAGE_CLASS;
66
+ stage.setAttribute("data-mermaid-zoom-stage", "true");
67
+
68
+ var fragment = doc.createDocumentFragment ? doc.createDocumentFragment() : null;
69
+ if (fragment) {
70
+ while (container.firstChild) {
71
+ fragment.appendChild(container.firstChild);
72
+ }
73
+ stage.appendChild(fragment);
74
+ } else {
75
+ while (container.firstChild) {
76
+ stage.appendChild(container.firstChild);
77
+ }
78
+ }
79
+ container.appendChild(stage);
80
+ return stage;
81
+ }
82
+
83
+ function MermaidZoomGuardian(container) {
84
+ this.container = container;
85
+ this.observer = null;
86
+ this.scheduled = false;
87
+ }
88
+ MermaidZoomGuardian.prototype.start = function () {
89
+ if (this.observer) return;
90
+ ensureMermaidZoomStage(this.container);
91
+ var Observer = (typeof MutationObserver !== "undefined" && MutationObserver) ||
92
+ (this.container.ownerDocument && this.container.ownerDocument.defaultView && this.container.ownerDocument.defaultView.MutationObserver);
93
+ if (typeof Observer !== "function") return;
94
+ var self = this;
95
+ this.observer = new Observer(function (mutations) {
96
+ if (self.scheduled) return;
97
+ for (var i = 0; i < mutations.length; i++) {
98
+ var m = mutations[i];
99
+ if (m.type !== "childList") continue;
100
+ if (m.target !== self.container) continue;
101
+ if (m.addedNodes.length === 0 && m.removedNodes.length === 0) continue;
102
+ for (var j = 0; j < m.addedNodes.length; j++) {
103
+ var n = m.addedNodes[j];
104
+ if (n && n.nodeType === 1 && n.classList && n.classList.contains(STAGE_CLASS)) {
105
+ return;
106
+ }
107
+ }
108
+ self.scheduled = true;
109
+ if (typeof queueMicrotask === "function") {
110
+ queueMicrotask(function () {
111
+ self.scheduled = false;
112
+ ensureMermaidZoomStage(self.container);
113
+ });
114
+ } else {
115
+ setTimeout(function () {
116
+ self.scheduled = false;
117
+ ensureMermaidZoomStage(self.container);
118
+ }, 0);
119
+ }
120
+ return;
121
+ }
122
+ });
123
+ this.observer.observe(this.container, { childList: true });
124
+ };
125
+ MermaidZoomGuardian.prototype.stop = function () {
126
+ if (this.observer) {
127
+ this.observer.disconnect();
128
+ this.observer = null;
129
+ }
130
+ this.scheduled = false;
131
+ };
132
+
133
+ return {
134
+ ensureMermaidZoomStage: ensureMermaidZoomStage,
135
+ MermaidZoomGuardian: MermaidZoomGuardian,
136
+ };
137
+ });
package/public/style.css CHANGED
@@ -2359,3 +2359,112 @@ details summary {
2359
2359
  /* (no streaming-specific styles yet — appendChunk uses
2360
2360
  * innerHTML replacement + a tiny render-time debounce in
2361
2361
  * public/markdown-renderer.js, which is below flicker threshold.) */
2362
+
2363
+ /* ============================================================================
2364
+ * v2.5.12 (Task #2952): full-content file viewer for write_file / write /
2365
+ * create_file + unified-diff rendering for edit_file / multi_edit_file /
2366
+ * apply_patch.
2367
+ *
2368
+ * Contract: the right-hand tool-call detail panel MUST render the FULL
2369
+ * payload for write_file (no max-height truncation) and a git-style diff
2370
+ * for edit_file (no Monaco fallback). The classes below scope the styles
2371
+ * tightly so the legacy `.diff-body` rules (which still cap at 320px) are
2372
+ * unaffected for any pre-existing inline consumers.
2373
+ * ========================================================================== */
2374
+
2375
+ .file-viewer.write-file,
2376
+ .file-viewer.edit-file {
2377
+ font-family: ui-monospace, "SF Mono", Menlo, monospace;
2378
+ font-size: 12px;
2379
+ line-height: 1.55;
2380
+ margin: 6px 0 0;
2381
+ border: 1px solid var(--border, #e5e7eb);
2382
+ border-radius: 4px;
2383
+ background: #fafafa;
2384
+ }
2385
+
2386
+ .file-viewer .file-header {
2387
+ display: flex;
2388
+ align-items: baseline;
2389
+ gap: 8px;
2390
+ padding: 6px 10px;
2391
+ border-bottom: 1px solid var(--border, #e5e7eb);
2392
+ background: #f3f4f6;
2393
+ font-size: 11px;
2394
+ }
2395
+
2396
+ .file-viewer .file-icon {
2397
+ font-size: 13px;
2398
+ flex: 0 0 auto;
2399
+ }
2400
+
2401
+ .file-viewer .file-path {
2402
+ font-weight: 600;
2403
+ color: var(--fg, #0f172a);
2404
+ word-break: break-all;
2405
+ }
2406
+
2407
+ .file-viewer .file-meta {
2408
+ color: var(--fg-muted, #6b7280);
2409
+ margin-left: auto;
2410
+ flex: 0 0 auto;
2411
+ white-space: nowrap;
2412
+ }
2413
+
2414
+ .file-viewer .code-block {
2415
+ margin: 0;
2416
+ padding: 6px 0 6px 0;
2417
+ /* Task #2952: NO max-height — full content must be visible. */
2418
+ max-height: none !important;
2419
+ overflow-y: visible;
2420
+ background: transparent;
2421
+ }
2422
+
2423
+ .file-viewer .code-line,
2424
+ .file-viewer .diff-line {
2425
+ display: flex;
2426
+ white-space: pre;
2427
+ padding: 0 8px;
2428
+ min-height: 1.55em;
2429
+ }
2430
+
2431
+ .file-viewer .code-line .ln,
2432
+ .file-viewer .diff-line .ln {
2433
+ flex: 0 0 4ch;
2434
+ text-align: right;
2435
+ margin-right: 8px;
2436
+ color: var(--fg-muted, #9ca3af);
2437
+ user-select: none;
2438
+ }
2439
+
2440
+ .file-viewer .diff-line .marker {
2441
+ flex: 0 0 1ch;
2442
+ text-align: center;
2443
+ font-weight: 600;
2444
+ margin-right: 4px;
2445
+ }
2446
+
2447
+ .file-viewer .diff-line[data-kind="add"] {
2448
+ background: rgba(46, 160, 67, 0.12);
2449
+ }
2450
+ .file-viewer .diff-line[data-kind="add"] .marker {
2451
+ color: #2ea043;
2452
+ }
2453
+ .file-viewer .diff-line[data-kind="remove"] {
2454
+ background: rgba(248, 81, 73, 0.12);
2455
+ }
2456
+ .file-viewer .diff-line[data-kind="remove"] .marker {
2457
+ color: #f85149;
2458
+ }
2459
+ .file-viewer .diff-line[data-kind="context"] {
2460
+ opacity: 0.7;
2461
+ }
2462
+ .file-viewer .diff-line[data-kind="context"] .marker {
2463
+ color: var(--fg-muted, #9ca3af);
2464
+ }
2465
+
2466
+ .file-viewer .code-line .content,
2467
+ .file-viewer .diff-line .content {
2468
+ flex: 1 1 auto;
2469
+ white-space: pre;
2470
+ }