@ai-setting/roy-plugin-task-show 2.6.3 → 2.6.5
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/dist/server.js +1 -1
- package/package.json +1 -1
- package/public/app.js +101 -0
package/dist/server.js
CHANGED
|
@@ -1825,7 +1825,7 @@ export function renderTaskPage(session, opts = {}) {
|
|
|
1825
1825
|
|
|
1826
1826
|
<div class="task-v2-main">
|
|
1827
1827
|
<section class="panel panel-lifecycle" data-lifecycle-root data-task-id="${session.taskId}">
|
|
1828
|
-
<h2>Task lifecycle + tools <span class="lifecycle-hint">click any tool node to highlight its row below</span> <button type="button" class="collapse-toggle" data-lifecycle-toggle aria-expanded="true" aria-label="Collapse lifecycle diagram"><span class="toggle-icon">▼</span></button></h2>
|
|
1828
|
+
<h2>Task lifecycle + tools <span class="lifecycle-hint">click any tool node to highlight its row below · URL auto-updates as <code>?tool=N</code> for sharing</span> <button type="button" class="collapse-toggle" data-lifecycle-toggle aria-expanded="true" aria-label="Collapse lifecycle diagram"><span class="toggle-icon">▼</span></button></h2>
|
|
1829
1829
|
<div data-lifecycle-body><div class="mermaid" data-mermaid-lifecycle>${initialMermaid}</div></div>
|
|
1830
1830
|
</section>
|
|
1831
1831
|
|
package/package.json
CHANGED
package/public/app.js
CHANGED
|
@@ -741,12 +741,61 @@ if (typeof window !== "undefined") {
|
|
|
741
741
|
* 3. Scrolls the row into view (smooth, centered).
|
|
742
742
|
* 4. Adds the `highlight` class for 2 seconds so the user sees a
|
|
743
743
|
* yellow flash pointing at the row.
|
|
744
|
+
* 5. (v2.6.4 / Task #3190) Persists the current tool id to the URL
|
|
745
|
+
* via `history.replaceState` so the user can share / bookmark
|
|
746
|
+
* the link (`?tool=N` / `?tool_index=N`) and the page boots
|
|
747
|
+
* straight onto that row. The query-param name is `tool`
|
|
748
|
+
* (alias `tool_index` accepted for the user-task wording).
|
|
744
749
|
*
|
|
745
750
|
* If the page has no `table.toolcalls` (e.g. the index page), the
|
|
746
751
|
* function is a no-op. We also defensively no-op on invalid IDs so
|
|
747
752
|
* Mermaid can never break the page by firing a stale callback.
|
|
748
753
|
*/
|
|
749
754
|
(function attachToolClickBridge() {
|
|
755
|
+
// v2.6.4 (Task #3190): shared URL helpers. We keep them inside the
|
|
756
|
+
// IIFE so the global namespace stays clean, but `scrollAndHighlight`
|
|
757
|
+
// and `initFromUrl` both go through `setToolInUrl` so the param
|
|
758
|
+
// name + value format is in exactly one place.
|
|
759
|
+
const TOOL_PARAM = "tool";
|
|
760
|
+
const TOOL_INDEX_ALIAS = "tool_index";
|
|
761
|
+
|
|
762
|
+
function getCurrentToolIdFromUrl() {
|
|
763
|
+
try {
|
|
764
|
+
const sp = new URLSearchParams(window.location.search);
|
|
765
|
+
// Accept both `?tool=N` (canonical) and `?tool_index=N`
|
|
766
|
+
// (user-task wording). `tool_index` wins if both are present.
|
|
767
|
+
const raw = sp.get(TOOL_INDEX_ALIAS) || sp.get(TOOL_PARAM);
|
|
768
|
+
if (!raw) return "";
|
|
769
|
+
const trimmed = String(raw).trim();
|
|
770
|
+
// Accept only positive integers — defends against injection.
|
|
771
|
+
if (!/^[1-9][0-9]*$/.test(trimmed)) return "";
|
|
772
|
+
return trimmed;
|
|
773
|
+
} catch (_) {
|
|
774
|
+
return "";
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
function setToolInUrl(toolId) {
|
|
779
|
+
try {
|
|
780
|
+
const id = String(toolId ?? "").trim();
|
|
781
|
+
const url = new URL(window.location.href);
|
|
782
|
+
if (!/^[1-9][0-9]*$/.test(id)) {
|
|
783
|
+
url.searchParams.delete(TOOL_PARAM);
|
|
784
|
+
url.searchParams.delete(TOOL_INDEX_ALIAS);
|
|
785
|
+
} else {
|
|
786
|
+
url.searchParams.set(TOOL_PARAM, id);
|
|
787
|
+
// Keep both names in sync — `tool_index` mirrors `tool` so
|
|
788
|
+
// either spelling resolves when the page is reloaded.
|
|
789
|
+
url.searchParams.set(TOOL_INDEX_ALIAS, id);
|
|
790
|
+
}
|
|
791
|
+
// replaceState (not pushState) so the browser back button does
|
|
792
|
+
// not fill up with one history entry per mermaid click.
|
|
793
|
+
window.history.replaceState(null, "", url.toString());
|
|
794
|
+
} catch (_) {
|
|
795
|
+
// URL APIs unavailable — silently noop.
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
|
|
750
799
|
function scrollAndHighlight(toolId) {
|
|
751
800
|
const id = String(toolId ?? "").trim();
|
|
752
801
|
if (!id) return;
|
|
@@ -770,6 +819,9 @@ if (typeof window !== "undefined") {
|
|
|
770
819
|
setTimeout(() => {
|
|
771
820
|
row.classList.remove("highlight");
|
|
772
821
|
}, 2000);
|
|
822
|
+
// v2.6.4 (Task #3190): persist the chosen tool id in the URL so
|
|
823
|
+
// it survives reload + can be shared / bookmarked.
|
|
824
|
+
setToolInUrl(id);
|
|
773
825
|
}
|
|
774
826
|
|
|
775
827
|
// Expose the global callback. Mermaid emits `click t1 __toolClick("1")`,
|
|
@@ -785,6 +837,55 @@ if (typeof window !== "undefined") {
|
|
|
785
837
|
}
|
|
786
838
|
};
|
|
787
839
|
|
|
840
|
+
// v2.6.4 (Task #3190): boot-time hydration. If the URL carries a
|
|
841
|
+
// `?tool=N` (or `?tool_index=N`) query param we scroll + highlight
|
|
842
|
+
// the matching row on load. This makes mermaid click → share-link
|
|
843
|
+
// → page reload a round-trippable flow.
|
|
844
|
+
function initFromUrl() {
|
|
845
|
+
const toolId = getCurrentToolIdFromUrl();
|
|
846
|
+
if (!toolId) return;
|
|
847
|
+
// Defer to next frame so the table layout is settled and
|
|
848
|
+
// scrollIntoView measures correct coordinates. Without this the
|
|
849
|
+
// scroll can land on the wrong spot on slow browsers.
|
|
850
|
+
const run = () => {
|
|
851
|
+
try {
|
|
852
|
+
// Prefer calling window.__toolClick so any wrapper installed
|
|
853
|
+
// later by tool-call-detail.js (panel render + file-tree
|
|
854
|
+
// highlight) picks up the click for free. Fall back to the
|
|
855
|
+
// bare `scrollAndHighlight` if the global hasn't been wired
|
|
856
|
+
// yet — the wrapper is installed synchronously when this
|
|
857
|
+
// module loads, so this branch is mainly a safety net.
|
|
858
|
+
if (typeof window.__toolClick === "function") {
|
|
859
|
+
window.__toolClick(toolId);
|
|
860
|
+
} else {
|
|
861
|
+
scrollAndHighlight(toolId);
|
|
862
|
+
}
|
|
863
|
+
} catch (err) {
|
|
864
|
+
// eslint-disable-next-line no-console
|
|
865
|
+
console.warn("[task-show] initFromUrl failed:", err && err.message || err);
|
|
866
|
+
}
|
|
867
|
+
};
|
|
868
|
+
if (typeof window.requestAnimationFrame === "function") {
|
|
869
|
+
window.requestAnimationFrame(() => window.setTimeout(run, 0));
|
|
870
|
+
} else {
|
|
871
|
+
window.setTimeout(run, 0);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
// v2.6.4 (Task #3190): handle back/forward navigation — when the
|
|
876
|
+
// user pops to a previous tool id via the browser history we want
|
|
877
|
+
// the table to follow.
|
|
878
|
+
window.addEventListener("popstate", () => {
|
|
879
|
+
initFromUrl();
|
|
880
|
+
});
|
|
881
|
+
|
|
882
|
+
if (document.readyState === "loading") {
|
|
883
|
+
document.addEventListener("DOMContentLoaded", initFromUrl, { once: true });
|
|
884
|
+
} else {
|
|
885
|
+
// Script loaded after DOM is ready (rare for this page but safe).
|
|
886
|
+
initFromUrl();
|
|
887
|
+
}
|
|
888
|
+
|
|
788
889
|
/**
|
|
789
890
|
* v0.8.0+ Mermaid re-render hook. When `task-operations.js` finishes
|
|
790
891
|
* a fetch it fires `task-show:lifecycle-ops-loaded`. We re-build the
|