dsh-plugin-inspiration-workbench 0.2.0 → 0.4.0
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/README.md +9 -4
- package/lib/client.js +338 -84
- package/lib/client.js.map +2 -2
- package/package.json +1 -1
- package/src/client/board.js +296 -82
- package/src/client/icons.js +5 -0
- package/src/client/index.jsx +30 -0
- package/src/client/popovers.js +2 -0
- package/src/client/styles.css +32 -3
package/lib/client.js
CHANGED
|
@@ -242,7 +242,7 @@ var styles_default = `/* Inspiration workbench \u2014 scoped to .iwb-root; colou
|
|
|
242
242
|
font-size: 10px; line-height: 15px; padding: 0 4px; flex: 0 0 auto; color: var(--dsw-alias-label-secondary);
|
|
243
243
|
background: var(--dsw-alias-bg-layer-2); border: .5px solid var(--dsw-alias-border-l2); border-radius: 5px;
|
|
244
244
|
}
|
|
245
|
-
.iwb-actions { display: flex; gap: 0; flex: 0 0 auto; opacity: .
|
|
245
|
+
.iwb-actions { display: flex; gap: 0; flex: 0 0 auto; opacity: .92; transition: opacity .12s; }
|
|
246
246
|
.iwb-card:hover .iwb-actions,
|
|
247
247
|
.iwb-card:focus-within .iwb-actions,
|
|
248
248
|
.iwb-card.iwb-focus .iwb-actions { opacity: 1; }
|
|
@@ -252,10 +252,11 @@ var styles_default = `/* Inspiration workbench \u2014 scoped to .iwb-root; colou
|
|
|
252
252
|
.iwb-more .iwb-model-row { gap: 8px; }
|
|
253
253
|
.iwb-more-ico { display: inline-flex; color: var(--dsw-alias-label-tertiary); }
|
|
254
254
|
.iwb-actions button {
|
|
255
|
-
width:
|
|
256
|
-
color: var(--dsw-alias-label-
|
|
255
|
+
width: 23px; height: 23px; border-radius: 6px; display: grid; place-items: center;
|
|
256
|
+
color: var(--dsw-alias-label-secondary); background: none; border: 0; cursor: pointer;
|
|
257
257
|
}
|
|
258
258
|
.iwb-actions button:hover { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); }
|
|
259
|
+
.iwb-actions button:focus-visible { outline: 2px solid var(--dsw-alias-label-deep-diving); outline-offset: -1px; }
|
|
259
260
|
|
|
260
261
|
.iwb-body {
|
|
261
262
|
flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 12px 12px 4px;
|
|
@@ -494,6 +495,34 @@ var styles_default = `/* Inspiration workbench \u2014 scoped to .iwb-root; colou
|
|
|
494
495
|
}
|
|
495
496
|
.iwb-msg-attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
496
497
|
|
|
498
|
+
/* \u2500\u2500 pipeline edges \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
499
|
+
.iwb-links {
|
|
500
|
+
position: absolute; left: 0; top: 0; width: 1px; height: 1px;
|
|
501
|
+
overflow: visible; pointer-events: none; z-index: 1;
|
|
502
|
+
}
|
|
503
|
+
.iwb-links path.iwb-link {
|
|
504
|
+
fill: none; stroke: var(--dsw-alias-label-deep-diving); stroke-width: 1.6;
|
|
505
|
+
opacity: .55; pointer-events: stroke; cursor: pointer;
|
|
506
|
+
}
|
|
507
|
+
.iwb-links path.iwb-link:hover { opacity: .95; stroke-width: 2; }
|
|
508
|
+
.iwb-links path.iwb-link-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
|
|
509
|
+
.iwb-links path.iwb-link-temp { fill: none; stroke: var(--dsw-alias-label-deep-diving); stroke-width: 2; stroke-dasharray: 5 4; opacity: .9; }
|
|
510
|
+
.iwb-port {
|
|
511
|
+
position: absolute; right: -7px; top: 30px; width: 14px; height: 14px;
|
|
512
|
+
border-radius: 50%; border: 1.5px solid var(--dsw-alias-label-deep-diving);
|
|
513
|
+
background: var(--dsw-alias-bg-layer-1); cursor: crosshair;
|
|
514
|
+
opacity: .55; transition: opacity .12s, transform .12s; z-index: 3;
|
|
515
|
+
}
|
|
516
|
+
.iwb-card:hover .iwb-port, .iwb-card.iwb-focus .iwb-port, .iwb-port:hover { opacity: 1; }
|
|
517
|
+
.iwb-port::after {
|
|
518
|
+
content: "\u2192"; position: absolute; inset: 0; display: grid; place-items: center;
|
|
519
|
+
font-size: 9px; line-height: 1; color: var(--dsw-alias-label-deep-diving);
|
|
520
|
+
}
|
|
521
|
+
.iwb-card.iwb-link-target { outline: 2px dashed var(--dsw-alias-label-deep-diving); outline-offset: 3px; }
|
|
522
|
+
.iwb-card-note.iwb-link-target { outline-style: solid; }
|
|
523
|
+
.iwb-link-menu { min-width: 230px; }
|
|
524
|
+
.iwb-link-remove .iwb-model-name { color: var(--dsw-alias-state-error-primary); }
|
|
525
|
+
|
|
497
526
|
/* \u2500\u2500 pipeline \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
498
527
|
.iwb-pipe-badge {
|
|
499
528
|
flex: 0 0 auto; font-size: 10px; padding: 1px 5px; border-radius: 5px;
|
|
@@ -858,6 +887,11 @@ function el(tag, className, html) {
|
|
|
858
887
|
// src/client/icons.js
|
|
859
888
|
var ICONS = {
|
|
860
889
|
plus: '<path d="M12 5v14M5 12h14"/>',
|
|
890
|
+
flow: '<path d="M4 7h9l-2-2"/><path d="M13 7l-2 2"/><circle cx="18" cy="7" r="2.4"/><path d="M4 17h9l-2-2"/><path d="M13 17l-2 2"/><circle cx="18" cy="17" r="2.4"/>',
|
|
891
|
+
more: '<circle cx="5" cy="12" r="1.7"/><circle cx="12" cy="12" r="1.7"/><circle cx="19" cy="12" r="1.7"/>',
|
|
892
|
+
canvas: '<rect x="3" y="7" width="14" height="14" rx="2"/><path d="M7 7V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-2"/>',
|
|
893
|
+
quote: '<path d="M7 7h5v5a4 4 0 0 1-4 4H7"/><path d="M15 7h5v5a4 4 0 0 1-4 4h-1"/>',
|
|
894
|
+
board: '<rect x="3" y="4" width="5.5" height="16" rx="1.4"/><rect x="9.5" y="4" width="5.5" height="11" rx="1.4"/><rect x="16" y="4" width="5" height="7" rx="1.4"/>',
|
|
861
895
|
arrange: '<rect x="3" y="3" width="7" height="7" rx="1.6"/><rect x="14" y="3" width="7" height="7" rx="1.6"/><rect x="3" y="14" width="7" height="7" rx="1.6"/><rect x="14" y="14" width="7" height="7" rx="1.6"/>',
|
|
862
896
|
fit: '<path d="M8 3H5a2 2 0 0 0-2 2v3M16 3h3a2 2 0 0 1 2 2v3M8 21H5a2 2 0 0 1-2-2v-3M16 21h3a2 2 0 0 0 2-2v-3"/>',
|
|
863
897
|
open: '<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><path d="M15 3h6v6"/><path d="M10 14L21 3"/>',
|
|
@@ -2154,7 +2188,8 @@ function createArrangeMenu(deps) {
|
|
|
2154
2188
|
toast,
|
|
2155
2189
|
defaultSize,
|
|
2156
2190
|
gap,
|
|
2157
|
-
anchor
|
|
2191
|
+
anchor,
|
|
2192
|
+
afterArrange
|
|
2158
2193
|
} = deps;
|
|
2159
2194
|
const el2 = el;
|
|
2160
2195
|
const DEFAULT_W2 = defaultSize.w;
|
|
@@ -2209,6 +2244,7 @@ function createArrangeMenu(deps) {
|
|
|
2209
2244
|
}
|
|
2210
2245
|
saveSoon();
|
|
2211
2246
|
void fitView();
|
|
2247
|
+
afterArrange?.();
|
|
2212
2248
|
toast(t2("arrange.done"));
|
|
2213
2249
|
}
|
|
2214
2250
|
function openArrangeMenu() {
|
|
@@ -2610,6 +2646,11 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
2610
2646
|
canvas.setAttribute("aria-label", t2("a11y.canvas"));
|
|
2611
2647
|
const world = el("div", "iwb-world");
|
|
2612
2648
|
canvas.appendChild(world);
|
|
2649
|
+
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
2650
|
+
const linkLayer = document.createElementNS(SVG_NS, "svg");
|
|
2651
|
+
linkLayer.setAttribute("class", "iwb-links");
|
|
2652
|
+
linkLayer.setAttribute("aria-hidden", "true");
|
|
2653
|
+
world.appendChild(linkLayer);
|
|
2613
2654
|
const emptyState = el(
|
|
2614
2655
|
"div",
|
|
2615
2656
|
"iwb-empty",
|
|
@@ -2642,7 +2683,7 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
2642
2683
|
tools.closeRefPicker();
|
|
2643
2684
|
}
|
|
2644
2685
|
});
|
|
2645
|
-
const arrangeMenu = createArrangeMenu({ t: t2, state, canvas, fitView, saveSoon, toast, defaultSize: { w: DEFAULT_W, h: DEFAULT_H }, gap: GAP, anchor: btnArrange });
|
|
2686
|
+
const arrangeMenu = createArrangeMenu({ t: t2, state, canvas, fitView, saveSoon, toast, defaultSize: { w: DEFAULT_W, h: DEFAULT_H }, gap: GAP, anchor: btnArrange, afterArrange: () => schedulePipelines() });
|
|
2646
2687
|
const workspaceMenu = createWorkspaceMenu({
|
|
2647
2688
|
t: t2,
|
|
2648
2689
|
adapter,
|
|
@@ -2788,6 +2829,7 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
2788
2829
|
function layoutStack(stack) {
|
|
2789
2830
|
const cards = stackCards(stack);
|
|
2790
2831
|
if (!cards.length) return;
|
|
2832
|
+
schedulePipelines();
|
|
2791
2833
|
state.zTop += cards.length + 1;
|
|
2792
2834
|
const base = state.zTop;
|
|
2793
2835
|
const inStack = cards.length > 1;
|
|
@@ -2910,7 +2952,7 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
2910
2952
|
return { x: 0, y: (state.cards.length + 1) * (DEFAULT_H + GAP) };
|
|
2911
2953
|
}
|
|
2912
2954
|
function cardMarkup(card) {
|
|
2913
|
-
return '<div class="iwb-progress"></div><header class="iwb-head"><span class="iwb-dot" title="' + t2("state.idle") + '"></span><span class="iwb-card-title"></span><span class="iwb-card-workspace" hidden></span><span class="iwb-status" hidden></span><span class="iwb-unread" hidden></span><button type="button" class="iwb-meta"></button><span class="iwb-elapsed"></span><span class="iwb-stack-badge" hidden></span><span class="iwb-pipe-badge" hidden></span><span class="iwb-actions"><button type="button" data-act="
|
|
2955
|
+
return '<div class="iwb-progress"></div><header class="iwb-head"><span class="iwb-dot" title="' + t2("state.idle") + '"></span><span class="iwb-card-title"></span><span class="iwb-card-workspace" hidden></span><span class="iwb-status" hidden></span><span class="iwb-unread" hidden></span><button type="button" class="iwb-meta"></button><span class="iwb-elapsed"></span><span class="iwb-stack-badge" hidden></span><span class="iwb-pipe-badge" hidden></span><span class="iwb-actions"><button type="button" data-act="outline" title="' + t2("card.outline") + '" aria-label="' + t2("card.outline") + '">' + icon("list") + '</button><button type="button" data-act="search" title="' + t2("card.search") + '" aria-label="' + t2("card.search") + '">' + icon("search") + '</button><button type="button" data-act="more" class="iwb-act-more" title="' + t2("card.more") + '" aria-label="' + t2("card.more") + '">' + icon("more") + '</button><button type="button" data-act="close" title="' + t2("remove") + '" aria-label="' + t2("remove") + '">' + icon("close") + '</button><span class="iwb-acts-more" hidden><button type="button" data-act="pin" title="' + t2("card.pin") + '" aria-label="' + t2("card.pin") + '">' + icon("pin") + '</button><button type="button" data-act="copy" title="' + t2("card.copy") + '" aria-label="' + t2("card.copy") + '">' + icon("copy") + '</button><button type="button" data-act="detach" title="' + t2("detach") + '" aria-label="' + t2("detach") + '" style="display:none">' + icon("layers") + '</button><button type="button" data-act="open" title="' + t2("openNative") + '" aria-label="' + t2("openNative") + '">' + icon("open") + '</button></span></span></header><div class="iwb-search" hidden><input class="iwb-search-input" type="text" /><span class="iwb-search-count"></span></div><div class="iwb-body"></div><div class="iwb-queue" hidden></div><div class="iwb-foot"></div><div class="iwb-resize"></div>';
|
|
2914
2956
|
}
|
|
2915
2957
|
function noteBody(card) {
|
|
2916
2958
|
const body = card.el.querySelector(".iwb-body");
|
|
@@ -3007,18 +3049,21 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
3007
3049
|
node.dataset.sessionId = sessionId;
|
|
3008
3050
|
card.el = node;
|
|
3009
3051
|
world.appendChild(node);
|
|
3052
|
+
node.appendChild(el("span", "iwb-port"));
|
|
3010
3053
|
node.querySelector(".iwb-card-title").textContent = card.title;
|
|
3011
3054
|
const bodyRegion = node.querySelector(".iwb-body");
|
|
3012
3055
|
bodyRegion.tabIndex = 0;
|
|
3013
3056
|
bodyRegion.setAttribute("role", "log");
|
|
3014
3057
|
bodyRegion.setAttribute("aria-label", t2("a11y.body"));
|
|
3015
3058
|
bindCard(card);
|
|
3059
|
+
bindPort(card);
|
|
3016
3060
|
for (const [boardKey, value] of expandedTurns) {
|
|
3017
3061
|
if (!boardKey.startsWith(sessionId + ":")) continue;
|
|
3018
3062
|
card.toolOpen.set("turn:" + boardKey.slice(sessionId.length + 1), value);
|
|
3019
3063
|
}
|
|
3020
3064
|
renderFoot(card);
|
|
3021
3065
|
renderPipeBadge(card);
|
|
3066
|
+
schedulePipelines();
|
|
3022
3067
|
state.cards.push(card);
|
|
3023
3068
|
updateCounts();
|
|
3024
3069
|
updateEmptyState();
|
|
@@ -3617,6 +3662,7 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
3617
3662
|
});
|
|
3618
3663
|
saveSoon();
|
|
3619
3664
|
void fitView();
|
|
3665
|
+
schedulePipelines();
|
|
3620
3666
|
}
|
|
3621
3667
|
function exitKanban() {
|
|
3622
3668
|
state.board.active = false;
|
|
@@ -3632,6 +3678,7 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
3632
3678
|
state.board.saved.clear();
|
|
3633
3679
|
saveSoon();
|
|
3634
3680
|
void fitView();
|
|
3681
|
+
schedulePipelines();
|
|
3635
3682
|
btnBoard.classList.remove("iwb-btn-active");
|
|
3636
3683
|
}
|
|
3637
3684
|
function enterKanban(key, label) {
|
|
@@ -3699,15 +3746,157 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
3699
3746
|
function sessionCardOf(sessionId) {
|
|
3700
3747
|
return state.cards.find((card) => card.sessionId === sessionId) || null;
|
|
3701
3748
|
}
|
|
3749
|
+
function pipeTargets(card) {
|
|
3750
|
+
const pipeline = card.pipeline;
|
|
3751
|
+
if (!pipeline) return [];
|
|
3752
|
+
if (Array.isArray(pipeline.targets)) {
|
|
3753
|
+
return pipeline.targets.filter((target) => target && (target.id || target.targetSessionId));
|
|
3754
|
+
}
|
|
3755
|
+
if (pipeline.targetSessionId) {
|
|
3756
|
+
return [{ kind: "session", id: pipeline.targetSessionId, mode: pipeline.mode === "draft" ? "draft" : "send" }];
|
|
3757
|
+
}
|
|
3758
|
+
return [];
|
|
3759
|
+
}
|
|
3760
|
+
function setPipeTargets(card, targets) {
|
|
3761
|
+
card.pipeline = targets.length ? { targets } : null;
|
|
3762
|
+
}
|
|
3763
|
+
function cardOfPipeTarget(target) {
|
|
3764
|
+
if (!target) return null;
|
|
3765
|
+
if (target.kind === "note") return state.cards.find((entry) => entry.kind === "note" && entry.id === target.id) || null;
|
|
3766
|
+
return sessionCardOf(target.id);
|
|
3767
|
+
}
|
|
3768
|
+
function pipeTargetLabel(target) {
|
|
3769
|
+
const targetCard = cardOfPipeTarget(target);
|
|
3770
|
+
if (targetCard) return targetCard.title || t2("untitled");
|
|
3771
|
+
return target?.id || "";
|
|
3772
|
+
}
|
|
3773
|
+
function addPipeTarget(card, targetCard) {
|
|
3774
|
+
const kind = targetCard.kind === "note" ? "note" : "session";
|
|
3775
|
+
const id = kind === "note" ? targetCard.id : targetCard.sessionId;
|
|
3776
|
+
if (!id || targetCard === card) return false;
|
|
3777
|
+
const targets = pipeTargets(card).filter((target) => !(target.kind === kind && target.id === id));
|
|
3778
|
+
const expanded = targets.length !== pipeTargets(card).length;
|
|
3779
|
+
targets.push({ kind, id, mode: "send" });
|
|
3780
|
+
setPipeTargets(card, targets);
|
|
3781
|
+
return !expanded;
|
|
3782
|
+
}
|
|
3783
|
+
function portAnchor(card) {
|
|
3784
|
+
return { x: card.x + card.w, y: card.y + 30 };
|
|
3785
|
+
}
|
|
3786
|
+
function targetAnchor(card) {
|
|
3787
|
+
return { x: card.x, y: card.y + 30 };
|
|
3788
|
+
}
|
|
3789
|
+
function linkPath(from, to) {
|
|
3790
|
+
const dx = Math.max(40, Math.abs(to.x - from.x) * 0.45);
|
|
3791
|
+
return "M " + from.x + " " + from.y + " C " + (from.x + dx) + " " + from.y + ", " + (to.x - dx) + " " + to.y + ", " + to.x + " " + to.y;
|
|
3792
|
+
}
|
|
3793
|
+
function renderPipelines() {
|
|
3794
|
+
while (linkLayer.firstChild) linkLayer.removeChild(linkLayer.firstChild);
|
|
3795
|
+
for (const card of state.cards) {
|
|
3796
|
+
for (const target of pipeTargets(card)) {
|
|
3797
|
+
const targetCard = cardOfPipeTarget(target);
|
|
3798
|
+
if (!targetCard || targetCard === card) continue;
|
|
3799
|
+
const d = linkPath(portAnchor(card), targetAnchor(targetCard));
|
|
3800
|
+
const hit = document.createElementNS(SVG_NS, "path");
|
|
3801
|
+
hit.setAttribute("d", d);
|
|
3802
|
+
hit.setAttribute("class", "iwb-link-hit");
|
|
3803
|
+
hit.addEventListener("pointerdown", (event) => {
|
|
3804
|
+
event.stopPropagation();
|
|
3805
|
+
openPipeMenu(card, target, event.currentTarget);
|
|
3806
|
+
});
|
|
3807
|
+
const path = document.createElementNS(SVG_NS, "path");
|
|
3808
|
+
path.setAttribute("d", d);
|
|
3809
|
+
path.setAttribute("class", "iwb-link");
|
|
3810
|
+
if (target.mode === "draft") path.setAttribute("stroke-dasharray", "4 4");
|
|
3811
|
+
linkLayer.append(hit, path);
|
|
3812
|
+
}
|
|
3813
|
+
}
|
|
3814
|
+
}
|
|
3815
|
+
let pipelineFrame = 0;
|
|
3816
|
+
function schedulePipelines() {
|
|
3817
|
+
if (pipelineFrame) return;
|
|
3818
|
+
pipelineFrame = requestAnimationFrame(() => {
|
|
3819
|
+
pipelineFrame = 0;
|
|
3820
|
+
renderPipelines();
|
|
3821
|
+
});
|
|
3822
|
+
}
|
|
3823
|
+
function bindPort(card) {
|
|
3824
|
+
const port = card.el.querySelector(".iwb-port");
|
|
3825
|
+
if (!port) return;
|
|
3826
|
+
port.setAttribute("title", t2("pipe.port"));
|
|
3827
|
+
port.setAttribute("aria-label", t2("pipe.port"));
|
|
3828
|
+
port.addEventListener("pointerdown", (event) => {
|
|
3829
|
+
event.preventDefault();
|
|
3830
|
+
event.stopPropagation();
|
|
3831
|
+
const canvasRect = canvas.getBoundingClientRect();
|
|
3832
|
+
const point = (clientX, clientY) => ({
|
|
3833
|
+
x: (clientX - canvasRect.left - state.pan.x) / state.zoom,
|
|
3834
|
+
y: (clientY - canvasRect.top - state.pan.y) / state.zoom
|
|
3835
|
+
});
|
|
3836
|
+
const temp = document.createElementNS(SVG_NS, "path");
|
|
3837
|
+
temp.setAttribute("class", "iwb-link-temp");
|
|
3838
|
+
linkLayer.appendChild(temp);
|
|
3839
|
+
let hovered = null;
|
|
3840
|
+
const draw = (clientX, clientY) => {
|
|
3841
|
+
temp.setAttribute("d", linkPath(portAnchor(card), point(clientX, clientY)));
|
|
3842
|
+
};
|
|
3843
|
+
draw(event.clientX, event.clientY);
|
|
3844
|
+
try {
|
|
3845
|
+
port.setPointerCapture?.(event.pointerId);
|
|
3846
|
+
} catch {
|
|
3847
|
+
}
|
|
3848
|
+
const onMove = (moveEvent) => {
|
|
3849
|
+
draw(moveEvent.clientX, moveEvent.clientY);
|
|
3850
|
+
const under = document.elementFromPoint(moveEvent.clientX, moveEvent.clientY);
|
|
3851
|
+
const candidate = under?.closest?.(".iwb-card");
|
|
3852
|
+
const targetCard = candidate ? state.cards.find((entry) => entry.el === candidate) : null;
|
|
3853
|
+
const usable = targetCard && targetCard !== card && (targetCard.sessionId || targetCard.kind === "note" && targetCard.id);
|
|
3854
|
+
if (hovered && hovered !== targetCard) hovered.el.classList.remove("iwb-link-target");
|
|
3855
|
+
hovered = usable ? targetCard : null;
|
|
3856
|
+
if (hovered) hovered.el.classList.add("iwb-link-target");
|
|
3857
|
+
};
|
|
3858
|
+
const finish = (upEvent) => {
|
|
3859
|
+
try {
|
|
3860
|
+
port.releasePointerCapture?.(event.pointerId);
|
|
3861
|
+
} catch {
|
|
3862
|
+
}
|
|
3863
|
+
port.removeEventListener("pointermove", onMove);
|
|
3864
|
+
port.removeEventListener("pointerup", finish);
|
|
3865
|
+
port.removeEventListener("pointercancel", cancel);
|
|
3866
|
+
temp.remove();
|
|
3867
|
+
if (hovered) {
|
|
3868
|
+
hovered.el.classList.remove("iwb-link-target");
|
|
3869
|
+
const created = addPipeTarget(card, hovered);
|
|
3870
|
+
renderPipeBadge(card);
|
|
3871
|
+
schedulePipelines();
|
|
3872
|
+
saveSoon();
|
|
3873
|
+
toast(
|
|
3874
|
+
created ? t2("pipe.created").replace("{name}", hovered.title || t2("untitled")) : t2("pipe.already").replace("{name}", hovered.title || t2("untitled"))
|
|
3875
|
+
);
|
|
3876
|
+
} else if (upEvent) {
|
|
3877
|
+
toast(t2("pipe.needTarget"));
|
|
3878
|
+
}
|
|
3879
|
+
hovered = null;
|
|
3880
|
+
};
|
|
3881
|
+
const cancel = () => finish(null);
|
|
3882
|
+
port.addEventListener("pointermove", onMove);
|
|
3883
|
+
port.addEventListener("pointerup", finish);
|
|
3884
|
+
port.addEventListener("pointercancel", cancel);
|
|
3885
|
+
});
|
|
3886
|
+
}
|
|
3702
3887
|
function renderPipeBadge(card) {
|
|
3703
3888
|
const badge = card.el?.querySelector(".iwb-pipe-badge");
|
|
3704
3889
|
if (!badge) return;
|
|
3705
|
-
const
|
|
3706
|
-
badge.hidden = !
|
|
3707
|
-
if (
|
|
3708
|
-
|
|
3709
|
-
badge.
|
|
3890
|
+
const targets = pipeTargets(card).filter((target) => cardOfPipeTarget(target));
|
|
3891
|
+
badge.hidden = !targets.length;
|
|
3892
|
+
if (!targets.length) return;
|
|
3893
|
+
if (targets.length === 1) {
|
|
3894
|
+
badge.textContent = t2("pipe.active").replace("{name}", pipeTargetLabel(targets[0]));
|
|
3895
|
+
badge.title = targets[0].mode === "draft" ? t2("pipe.draft") : t2("pipe.send");
|
|
3896
|
+
return;
|
|
3710
3897
|
}
|
|
3898
|
+
badge.textContent = t2("pipe.multi").replace("{n}", String(targets.length));
|
|
3899
|
+
badge.title = targets.map((target) => pipeTargetLabel(target)).join(" \xB7 ");
|
|
3711
3900
|
}
|
|
3712
3901
|
function lastAssistantText(card) {
|
|
3713
3902
|
const items = card.view?.items || [];
|
|
@@ -3759,107 +3948,128 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
3759
3948
|
}
|
|
3760
3949
|
}
|
|
3761
3950
|
async function deliverPipeline(card) {
|
|
3762
|
-
const
|
|
3763
|
-
if (!
|
|
3764
|
-
const target = sessionCardOf(pipeline.targetSessionId);
|
|
3765
|
-
if (!target) return;
|
|
3951
|
+
const targets = pipeTargets(card);
|
|
3952
|
+
if (!targets.length) return;
|
|
3766
3953
|
const text = lastAssistantText(card);
|
|
3767
3954
|
if (!text) return;
|
|
3768
3955
|
const fingerprint = text.slice(0, 160);
|
|
3769
|
-
|
|
3956
|
+
card.pipedFingerprints = card.pipedFingerprints || {};
|
|
3770
3957
|
const depth = (card.pipeDepth || 0) + 1;
|
|
3771
3958
|
if (depth > 3) {
|
|
3772
3959
|
toast(t2("pipe.tooLong"));
|
|
3773
3960
|
return;
|
|
3774
3961
|
}
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3962
|
+
for (const target of targets) {
|
|
3963
|
+
const key = target.kind + ":" + target.id;
|
|
3964
|
+
if (card.pipedFingerprints[key] === fingerprint) continue;
|
|
3965
|
+
const targetCard = cardOfPipeTarget(target);
|
|
3966
|
+
if (target.kind === "note") {
|
|
3967
|
+
if (!targetCard) continue;
|
|
3968
|
+
const area = targetCard.el?.querySelector(".iwb-note-input");
|
|
3969
|
+
if (!area) continue;
|
|
3970
|
+
area.value = area.value ? area.value.replace(/\s*$/, "\n\n") + text : text;
|
|
3971
|
+
area.dispatchEvent(new Event("input", { bubbles: true }));
|
|
3972
|
+
targetCard.pipeDepth = depth;
|
|
3973
|
+
card.pipedFingerprints[key] = fingerprint;
|
|
3974
|
+
ensureVisible(targetCard);
|
|
3975
|
+
toast(t2("pipe.noted").replace("{name}", targetCard.title || t2("untitled")));
|
|
3976
|
+
continue;
|
|
3977
|
+
}
|
|
3978
|
+
if (target.mode === "draft") {
|
|
3979
|
+
const field = targetCard?.el?.querySelector(".iwb-foot textarea");
|
|
3980
|
+
if (!field) continue;
|
|
3981
|
+
field.value = field.value ? field.value.replace(/\s*$/, "\n\n") + text : text;
|
|
3982
|
+
field.dispatchEvent(new Event("input", { bubbles: true }));
|
|
3983
|
+
ensureVisible(targetCard);
|
|
3984
|
+
targetCard.pipeDepth = depth;
|
|
3985
|
+
card.pipedFingerprints[key] = fingerprint;
|
|
3986
|
+
toast(t2("pipe.drafted").replace("{name}", pipeTargetLabel(target)));
|
|
3987
|
+
continue;
|
|
3988
|
+
}
|
|
3784
3989
|
try {
|
|
3785
|
-
await adapter.prompt(target.
|
|
3786
|
-
|
|
3990
|
+
await adapter.prompt(target.id, text, "queue");
|
|
3991
|
+
card.pipedFingerprints[key] = fingerprint;
|
|
3992
|
+
if (targetCard) targetCard.pipeDepth = depth;
|
|
3993
|
+
toast(t2("pipe.sent").replace("{name}", pipeTargetLabel(target)));
|
|
3787
3994
|
} catch (error) {
|
|
3788
3995
|
toast(t2("pipe.failed").replace("{error}", error?.message || ""));
|
|
3789
|
-
return;
|
|
3790
3996
|
}
|
|
3791
3997
|
}
|
|
3792
|
-
target.pipeDepth = depth;
|
|
3793
3998
|
}
|
|
3794
|
-
function openPipeMenu(card, anchor) {
|
|
3999
|
+
function openPipeMenu(card, target, anchor) {
|
|
3795
4000
|
if (pipePop) {
|
|
3796
4001
|
closePipeMenu();
|
|
3797
4002
|
return;
|
|
3798
4003
|
}
|
|
3799
|
-
|
|
3800
|
-
const
|
|
4004
|
+
if (!target) return;
|
|
4005
|
+
const targetCard = cardOfPipeTarget(target);
|
|
4006
|
+
const label = pipeTargetLabel(target);
|
|
4007
|
+
const isNote = target.kind === "note";
|
|
4008
|
+
const pop = el("div", "iwb-popover iwb-link-menu");
|
|
3801
4009
|
pop.setAttribute("role", "dialog");
|
|
3802
4010
|
pop.setAttribute("aria-label", t2("pipe.title"));
|
|
3803
4011
|
const head = el("div", "iwb-popover-head");
|
|
3804
|
-
head.textContent = t2("pipe.title");
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
addRow(
|
|
3827
|
-
target.title || t2("untitled"),
|
|
3828
|
-
target.workspace || t2("workspace.none"),
|
|
3829
|
-
() => {
|
|
3830
|
-
card.pipeline = { targetSessionId: target.sessionId, mode: card.pipeline?.mode || "send" };
|
|
4012
|
+
head.textContent = isNote ? t2("pipe.noteTarget") : t2("pipe.title");
|
|
4013
|
+
const status = el("div", "iwb-popover-note");
|
|
4014
|
+
status.textContent = t2("pipe.linked").replace("{name}", label);
|
|
4015
|
+
pop.append(head, status);
|
|
4016
|
+
if (!isNote) {
|
|
4017
|
+
const mode = target.mode === "draft" ? "draft" : "send";
|
|
4018
|
+
const modes = [
|
|
4019
|
+
{ id: "send", label: t2("pipe.send"), hint: t2("pipe.sendHint") },
|
|
4020
|
+
{ id: "draft", label: t2("pipe.draft"), hint: t2("pipe.draftHint") }
|
|
4021
|
+
];
|
|
4022
|
+
for (const option of modes) {
|
|
4023
|
+
const row = el("button", "iwb-model-row" + (mode === option.id ? " current" : ""));
|
|
4024
|
+
row.type = "button";
|
|
4025
|
+
row.innerHTML = '<span class="iwb-model-main"><span class="iwb-model-name"></span><span class="iwb-model-desc"></span></span>' + (mode === option.id ? '<span class="iwb-check">\u2713</span>' : "");
|
|
4026
|
+
row.querySelector(".iwb-model-name").textContent = option.label;
|
|
4027
|
+
row.querySelector(".iwb-model-desc").textContent = option.hint;
|
|
4028
|
+
row.addEventListener("click", (event) => {
|
|
4029
|
+
event.stopPropagation();
|
|
4030
|
+
const targets = pipeTargets(card).map(
|
|
4031
|
+
(entry) => entry.kind === target.kind && entry.id === target.id ? { ...entry, mode: option.id } : entry
|
|
4032
|
+
);
|
|
4033
|
+
setPipeTargets(card, targets);
|
|
3831
4034
|
renderPipeBadge(card);
|
|
4035
|
+
schedulePipelines();
|
|
3832
4036
|
saveSoon();
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
4037
|
+
closePipeMenu();
|
|
4038
|
+
toast(option.id === "draft" ? t2("pipe.modeDraft") : t2("pipe.modeSend"));
|
|
4039
|
+
});
|
|
4040
|
+
pop.appendChild(row);
|
|
4041
|
+
}
|
|
4042
|
+
} else {
|
|
4043
|
+
const statusRow = el("div", "iwb-popover-note");
|
|
4044
|
+
statusRow.textContent = t2("pipe.noteHint");
|
|
4045
|
+
pop.appendChild(statusRow);
|
|
3837
4046
|
}
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
false
|
|
4047
|
+
const remove = el("button", "iwb-model-row iwb-link-remove");
|
|
4048
|
+
remove.type = "button";
|
|
4049
|
+
remove.innerHTML = '<span class="iwb-model-main"><span class="iwb-model-name"></span></span>';
|
|
4050
|
+
remove.querySelector(".iwb-model-name").textContent = isNote ? t2("pipe.removeNote") : t2("pipe.remove");
|
|
4051
|
+
remove.addEventListener("click", (event) => {
|
|
4052
|
+
event.stopPropagation();
|
|
4053
|
+
setPipeTargets(
|
|
4054
|
+
card,
|
|
4055
|
+
pipeTargets(card).filter((entry) => !(entry.kind === target.kind && entry.id === target.id))
|
|
3848
4056
|
);
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
4057
|
+
renderPipeBadge(card);
|
|
4058
|
+
schedulePipelines();
|
|
4059
|
+
saveSoon();
|
|
4060
|
+
closePipeMenu();
|
|
4061
|
+
toast(t2("pipe.removed"));
|
|
4062
|
+
if (targetCard) ensureVisible(targetCard);
|
|
4063
|
+
});
|
|
4064
|
+
pop.appendChild(remove);
|
|
3855
4065
|
const rect = anchor.getBoundingClientRect();
|
|
3856
|
-
pop.style.left = Math.round(Math.max(8, Math.min(rect.left -
|
|
3857
|
-
pop.style.top = Math.round(rect.
|
|
4066
|
+
pop.style.left = Math.round(Math.max(8, Math.min(rect.left + rect.width / 2 - 110, window.innerWidth - 240))) + "px";
|
|
4067
|
+
pop.style.top = Math.round(rect.top + rect.height + 8) + "px";
|
|
3858
4068
|
document.body.appendChild(pop);
|
|
3859
4069
|
pipePop = pop;
|
|
3860
4070
|
const measured = pop.getBoundingClientRect();
|
|
3861
4071
|
if (measured.bottom > window.innerHeight - 8) {
|
|
3862
|
-
pop.style.top = Math.max(8, Math.round(rect.top - measured.height -
|
|
4072
|
+
pop.style.top = Math.max(8, Math.round(rect.top - measured.height - 8)) + "px";
|
|
3863
4073
|
}
|
|
3864
4074
|
}
|
|
3865
4075
|
function syncApprovalSessions() {
|
|
@@ -3879,6 +4089,17 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
3879
4089
|
} catch {
|
|
3880
4090
|
}
|
|
3881
4091
|
state.cards = state.cards.filter((c) => c !== card);
|
|
4092
|
+
const goneId = card.kind === "note" ? card.id : card.sessionId;
|
|
4093
|
+
const goneKind = card.kind === "note" ? "note" : "session";
|
|
4094
|
+
for (const other of state.cards) {
|
|
4095
|
+
const targets = pipeTargets(other);
|
|
4096
|
+
const kept = targets.filter((target) => !(target.kind === goneKind && target.id === goneId));
|
|
4097
|
+
if (kept.length !== targets.length) {
|
|
4098
|
+
setPipeTargets(other, kept);
|
|
4099
|
+
renderPipeBadge(other);
|
|
4100
|
+
}
|
|
4101
|
+
}
|
|
4102
|
+
schedulePipelines();
|
|
3882
4103
|
if (state.selected.delete(card.id)) renderBatchBar();
|
|
3883
4104
|
if (state.focusedId === card.id) {
|
|
3884
4105
|
state.focusedId = null;
|
|
@@ -4510,6 +4731,7 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
4510
4731
|
node.style.left = nx + "px";
|
|
4511
4732
|
node.style.top = ny + "px";
|
|
4512
4733
|
}
|
|
4734
|
+
schedulePipelines();
|
|
4513
4735
|
};
|
|
4514
4736
|
const up = () => {
|
|
4515
4737
|
interactionActive = false;
|
|
@@ -4638,7 +4860,7 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
4638
4860
|
y: card.y,
|
|
4639
4861
|
w: card.w,
|
|
4640
4862
|
h: card.h,
|
|
4641
|
-
pipeline: card.
|
|
4863
|
+
pipeline: pipeTargets(card).length ? { targets: pipeTargets(card) } : null
|
|
4642
4864
|
});
|
|
4643
4865
|
}
|
|
4644
4866
|
for (const stack of saved.stacks || []) {
|
|
@@ -4656,6 +4878,7 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
4656
4878
|
updateEmptyState();
|
|
4657
4879
|
syncApprovalSessions();
|
|
4658
4880
|
updateTodoBar();
|
|
4881
|
+
schedulePipelines();
|
|
4659
4882
|
clearTimeout(saveTimer);
|
|
4660
4883
|
saveTimer = 0;
|
|
4661
4884
|
void syncFromRemote().then(() => startRemoteSync());
|
|
@@ -4671,13 +4894,14 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
4671
4894
|
pan: state.pan,
|
|
4672
4895
|
settings: { ...state.settings },
|
|
4673
4896
|
cards: state.cards.map((card) => ({
|
|
4897
|
+
id: card.kind === "note" ? card.id : void 0,
|
|
4674
4898
|
sessionId: card.sessionId,
|
|
4675
4899
|
title: card.title,
|
|
4676
4900
|
workspace: card.workspace || "",
|
|
4677
4901
|
kind: card.kind || "session",
|
|
4678
4902
|
note: card.note || "",
|
|
4679
4903
|
pinned: Boolean(card.pinned),
|
|
4680
|
-
pipeline: card.
|
|
4904
|
+
pipeline: pipeTargets(card).length ? { targets: pipeTargets(card) } : null,
|
|
4681
4905
|
x: card.x,
|
|
4682
4906
|
y: card.y,
|
|
4683
4907
|
w: card.w,
|
|
@@ -5992,6 +6216,21 @@ var zh = {
|
|
|
5992
6216
|
"pipe.linked": "\u6D41\u6C34\u7EBF\u5DF2\u6307\u5411\u300C{name}\u300D",
|
|
5993
6217
|
"pipe.modeSendHint": "\u5F53\u524D\uFF1A\u5B8C\u6210\u540E\u81EA\u52A8\u53D1\u9001",
|
|
5994
6218
|
"pipe.modeDraftHint": "\u5F53\u524D\uFF1A\u53EA\u586B\u5165\u8349\u7A3F",
|
|
6219
|
+
"pipe.already": "\u5DF2\u7ECF\u8FDE\u8FC7\u300C{name}\u300D\u4E86",
|
|
6220
|
+
"pipe.multi": "\u2192 {n} \u4E2A\u4E0B\u6E38",
|
|
6221
|
+
"pipe.noted": "\u7ED3\u679C\u5DF2\u8FFD\u52A0\u5230\u4FBF\u7B7E\u300C{name}\u300D",
|
|
6222
|
+
"pipe.noteTarget": "\u6D41\u6C34\u7EBF \u2192 \u4FBF\u7B7E",
|
|
6223
|
+
"pipe.noteHint": "\u4E0B\u6E38\u662F\u4FBF\u7B7E\uFF1A\u8DD1\u5B8C\u628A\u7ED3\u679C\u8FFD\u52A0\u8FDB\u53BB\uFF0C\u4E0D\u53D1\u9001",
|
|
6224
|
+
"pipe.removeNote": "\u5220\u9664\u8FD9\u6761\u4FBF\u7B7E\u6D41\u6C34\u7EBF",
|
|
6225
|
+
"pipe.port": "\u62D6\u8FD9\u6761\u7EBF\u5230\u53E6\u4E00\u5F20\u5361\uFF0C\u5EFA\u7ACB\u6D41\u6C34\u7EBF",
|
|
6226
|
+
"pipe.created": "\u6D41\u6C34\u7EBF\u5DF2\u8FDE\u5230\u300C{name}\u300D",
|
|
6227
|
+
"pipe.needTarget": "\u62D6\u5230\u53E6\u4E00\u5F20\u5361\uFF08\u4F1A\u8BDD\u5361\u6216\u4FBF\u7B7E\uFF09\u4E0A\u624D\u7B97\u8FDE\u7EBF",
|
|
6228
|
+
"pipe.remove": "\u5220\u9664\u8FD9\u6761\u6D41\u6C34\u7EBF",
|
|
6229
|
+
"pipe.removed": "\u6D41\u6C34\u7EBF\u5DF2\u5220\u9664",
|
|
6230
|
+
"pipe.sendHint": "\u5B8C\u6210\u540E\u81EA\u52A8\u628A\u7ED3\u679C\u53D1\u8FC7\u53BB",
|
|
6231
|
+
"pipe.draftHint": "\u53EA\u586B\u8FDB\u4E0B\u6E38\u8F93\u5165\u6846\uFF0C\u7B49\u4EBA\u786E\u8BA4",
|
|
6232
|
+
"pipe.modeSend": "\u5DF2\u5207\u5230\uFF1A\u81EA\u52A8\u53D1\u9001",
|
|
6233
|
+
"pipe.modeDraft": "\u5DF2\u5207\u5230\uFF1A\u53EA\u586B\u8349\u7A3F",
|
|
5995
6234
|
"pipe.title": "\u6D41\u6C34\u7EBF\uFF1A\u5B8C\u6210\u540E\u628A\u7ED3\u679C\u9001\u5230\u4E0B\u6E38\u5361",
|
|
5996
6235
|
"pipe.to": "\u4E0B\u6E38\u5361\u7247",
|
|
5997
6236
|
"pipe.send": "\u81EA\u52A8\u53D1\u9001\u5230\u4E0B\u6E38",
|
|
@@ -6268,6 +6507,21 @@ var en = {
|
|
|
6268
6507
|
"pipe.linked": "Pipeline points at \u201C{name}\u201D",
|
|
6269
6508
|
"pipe.modeSendHint": "Currently: auto-send on completion",
|
|
6270
6509
|
"pipe.modeDraftHint": "Currently: draft only",
|
|
6510
|
+
"pipe.already": "\u201C{name}\u201D is already connected",
|
|
6511
|
+
"pipe.multi": "\u2192 {n} downstream",
|
|
6512
|
+
"pipe.noted": "Result appended to note \u201C{name}\u201D",
|
|
6513
|
+
"pipe.noteTarget": "Pipeline \u2192 note",
|
|
6514
|
+
"pipe.noteHint": "Note downstream: the result is appended, never sent",
|
|
6515
|
+
"pipe.removeNote": "Remove this note pipeline",
|
|
6516
|
+
"pipe.port": "Drag this line onto another card to wire a pipeline",
|
|
6517
|
+
"pipe.created": "Pipeline wired to \u201C{name}\u201D",
|
|
6518
|
+
"pipe.needTarget": "Drop it on another card (session or note) to connect",
|
|
6519
|
+
"pipe.remove": "Remove this pipeline",
|
|
6520
|
+
"pipe.removed": "Pipeline removed",
|
|
6521
|
+
"pipe.sendHint": "Send the result downstream when the turn finishes",
|
|
6522
|
+
"pipe.draftHint": "Only fill the downstream composer",
|
|
6523
|
+
"pipe.modeSend": "Mode: auto-send",
|
|
6524
|
+
"pipe.modeDraft": "Mode: draft only",
|
|
6271
6525
|
"pipe.title": "Pipeline: forward this card's result downstream",
|
|
6272
6526
|
"pipe.to": "Downstream card",
|
|
6273
6527
|
"pipe.send": "Auto-send downstream",
|