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/package.json
CHANGED
package/src/client/board.js
CHANGED
|
@@ -146,6 +146,11 @@ export function createBoard({ host, adapter, approvals, t, onOpenSession }) {
|
|
|
146
146
|
canvas.setAttribute('aria-label', t('a11y.canvas'));
|
|
147
147
|
const world = el('div', 'iwb-world');
|
|
148
148
|
canvas.appendChild(world);
|
|
149
|
+
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
150
|
+
const linkLayer = document.createElementNS(SVG_NS, 'svg');
|
|
151
|
+
linkLayer.setAttribute('class', 'iwb-links');
|
|
152
|
+
linkLayer.setAttribute('aria-hidden', 'true');
|
|
153
|
+
world.appendChild(linkLayer);
|
|
149
154
|
|
|
150
155
|
const emptyState = el(
|
|
151
156
|
'div',
|
|
@@ -185,7 +190,7 @@ export function createBoard({ host, adapter, approvals, t, onOpenSession }) {
|
|
|
185
190
|
tools.closeRefPicker();
|
|
186
191
|
},
|
|
187
192
|
});
|
|
188
|
-
const arrangeMenu = createArrangeMenu({ t, state, canvas, fitView, saveSoon, toast, defaultSize: { w: DEFAULT_W, h: DEFAULT_H }, gap: GAP, anchor: btnArrange });
|
|
193
|
+
const arrangeMenu = createArrangeMenu({ t, state, canvas, fitView, saveSoon, toast, defaultSize: { w: DEFAULT_W, h: DEFAULT_H }, gap: GAP, anchor: btnArrange, afterArrange: () => schedulePipelines() });
|
|
189
194
|
const workspaceMenu = createWorkspaceMenu({
|
|
190
195
|
t,
|
|
191
196
|
adapter,
|
|
@@ -346,6 +351,7 @@ export function createBoard({ host, adapter, approvals, t, onOpenSession }) {
|
|
|
346
351
|
function layoutStack(stack) {
|
|
347
352
|
const cards = stackCards(stack);
|
|
348
353
|
if (!cards.length) return;
|
|
354
|
+
schedulePipelines();
|
|
349
355
|
state.zTop += cards.length + 1;
|
|
350
356
|
const base = state.zTop;
|
|
351
357
|
const inStack = cards.length > 1;
|
|
@@ -498,7 +504,6 @@ export function createBoard({ host, adapter, approvals, t, onOpenSession }) {
|
|
|
498
504
|
'<span class="iwb-stack-badge" hidden></span>' +
|
|
499
505
|
'<span class="iwb-pipe-badge" hidden></span>' +
|
|
500
506
|
'<span class="iwb-actions">' +
|
|
501
|
-
'<button type="button" data-act="pipe" title="' + t('pipe.title') + '" aria-label="' + t('pipe.title') + '">' + icon('flow') + '</button>' +
|
|
502
507
|
'<button type="button" data-act="outline" title="' + t('card.outline') + '" aria-label="' + t('card.outline') + '">' + icon('list') + '</button>' +
|
|
503
508
|
'<button type="button" data-act="search" title="' + t('card.search') + '" aria-label="' + t('card.search') + '">' + icon('search') + '</button>' +
|
|
504
509
|
'<button type="button" data-act="more" class="iwb-act-more" title="' + t('card.more') + '" aria-label="' + t('card.more') + '">' + icon('more') + '</button>' +
|
|
@@ -567,6 +572,7 @@ export function createBoard({ host, adapter, approvals, t, onOpenSession }) {
|
|
|
567
572
|
node.querySelector('[data-act="outline"]')?.remove();
|
|
568
573
|
node.querySelector('[data-act="pipe"]')?.remove();
|
|
569
574
|
node.querySelector('.iwb-pipe-badge')?.remove();
|
|
575
|
+
|
|
570
576
|
node.querySelector('.iwb-search')?.remove();
|
|
571
577
|
noteBody(card);
|
|
572
578
|
bindCard(card);
|
|
@@ -618,6 +624,7 @@ export function createBoard({ host, adapter, approvals, t, onOpenSession }) {
|
|
|
618
624
|
node.dataset.sessionId = sessionId;
|
|
619
625
|
card.el = node;
|
|
620
626
|
world.appendChild(node);
|
|
627
|
+
node.appendChild(el('span', 'iwb-port'));
|
|
621
628
|
node.querySelector('.iwb-card-title').textContent = card.title;
|
|
622
629
|
const bodyRegion = node.querySelector('.iwb-body');
|
|
623
630
|
bodyRegion.tabIndex = 0;
|
|
@@ -625,12 +632,14 @@ export function createBoard({ host, adapter, approvals, t, onOpenSession }) {
|
|
|
625
632
|
bodyRegion.setAttribute('aria-label', t('a11y.body'));
|
|
626
633
|
|
|
627
634
|
bindCard(card);
|
|
635
|
+
bindPort(card);
|
|
628
636
|
for (const [boardKey, value] of expandedTurns) {
|
|
629
637
|
if (!boardKey.startsWith(sessionId + ':')) continue;
|
|
630
638
|
card.toolOpen.set('turn:' + boardKey.slice(sessionId.length + 1), value);
|
|
631
639
|
}
|
|
632
640
|
renderFoot(card);
|
|
633
641
|
renderPipeBadge(card);
|
|
642
|
+
schedulePipelines();
|
|
634
643
|
state.cards.push(card);
|
|
635
644
|
updateCounts();
|
|
636
645
|
updateEmptyState();
|
|
@@ -1307,6 +1316,7 @@ export function createBoard({ host, adapter, approvals, t, onOpenSession }) {
|
|
|
1307
1316
|
});
|
|
1308
1317
|
saveSoon();
|
|
1309
1318
|
void fitView();
|
|
1319
|
+
schedulePipelines();
|
|
1310
1320
|
}
|
|
1311
1321
|
|
|
1312
1322
|
function exitKanban() {
|
|
@@ -1323,6 +1333,7 @@ export function createBoard({ host, adapter, approvals, t, onOpenSession }) {
|
|
|
1323
1333
|
state.board.saved.clear();
|
|
1324
1334
|
saveSoon();
|
|
1325
1335
|
void fitView();
|
|
1336
|
+
schedulePipelines();
|
|
1326
1337
|
btnBoard.classList.remove('iwb-btn-active');
|
|
1327
1338
|
}
|
|
1328
1339
|
|
|
@@ -1397,15 +1408,177 @@ export function createBoard({ host, adapter, approvals, t, onOpenSession }) {
|
|
|
1397
1408
|
return state.cards.find((card) => card.sessionId === sessionId) || null;
|
|
1398
1409
|
}
|
|
1399
1410
|
|
|
1411
|
+
// Pipelines may fan out: a card keeps a list of targets, and a target can be
|
|
1412
|
+
// another session card or a note card (the note just collects the result).
|
|
1413
|
+
function pipeTargets(card) {
|
|
1414
|
+
const pipeline = card.pipeline;
|
|
1415
|
+
if (!pipeline) return [];
|
|
1416
|
+
if (Array.isArray(pipeline.targets)) {
|
|
1417
|
+
return pipeline.targets.filter((target) => target && (target.id || target.targetSessionId));
|
|
1418
|
+
}
|
|
1419
|
+
if (pipeline.targetSessionId) {
|
|
1420
|
+
return [{ kind: 'session', id: pipeline.targetSessionId, mode: pipeline.mode === 'draft' ? 'draft' : 'send' }];
|
|
1421
|
+
}
|
|
1422
|
+
return [];
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
function setPipeTargets(card, targets) {
|
|
1426
|
+
card.pipeline = targets.length ? { targets } : null;
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
function cardOfPipeTarget(target) {
|
|
1430
|
+
if (!target) return null;
|
|
1431
|
+
if (target.kind === 'note') return state.cards.find((entry) => entry.kind === 'note' && entry.id === target.id) || null;
|
|
1432
|
+
return sessionCardOf(target.id);
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
function pipeTargetLabel(target) {
|
|
1436
|
+
const targetCard = cardOfPipeTarget(target);
|
|
1437
|
+
if (targetCard) return targetCard.title || t('untitled');
|
|
1438
|
+
return target?.id || '';
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
function addPipeTarget(card, targetCard) {
|
|
1442
|
+
const kind = targetCard.kind === 'note' ? 'note' : 'session';
|
|
1443
|
+
const id = kind === 'note' ? targetCard.id : targetCard.sessionId;
|
|
1444
|
+
if (!id || targetCard === card) return false;
|
|
1445
|
+
const targets = pipeTargets(card).filter((target) => !(target.kind === kind && target.id === id));
|
|
1446
|
+
const expanded = targets.length !== pipeTargets(card).length;
|
|
1447
|
+
targets.push({ kind, id, mode: 'send' });
|
|
1448
|
+
setPipeTargets(card, targets);
|
|
1449
|
+
return !expanded;
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
function portAnchor(card) {
|
|
1453
|
+
return { x: card.x + card.w, y: card.y + 30 };
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
function targetAnchor(card) {
|
|
1457
|
+
return { x: card.x, y: card.y + 30 };
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
function linkPath(from, to) {
|
|
1461
|
+
const dx = Math.max(40, Math.abs(to.x - from.x) * 0.45);
|
|
1462
|
+
return 'M ' + from.x + ' ' + from.y + ' C ' + (from.x + dx) + ' ' + from.y + ', ' + (to.x - dx) + ' ' + to.y + ', ' + to.x + ' ' + to.y;
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
/** Draw one curve per pipeline target, plus a fat invisible hit area each. */
|
|
1466
|
+
function renderPipelines() {
|
|
1467
|
+
while (linkLayer.firstChild) linkLayer.removeChild(linkLayer.firstChild);
|
|
1468
|
+
for (const card of state.cards) {
|
|
1469
|
+
for (const target of pipeTargets(card)) {
|
|
1470
|
+
const targetCard = cardOfPipeTarget(target);
|
|
1471
|
+
if (!targetCard || targetCard === card) continue;
|
|
1472
|
+
const d = linkPath(portAnchor(card), targetAnchor(targetCard));
|
|
1473
|
+
const hit = document.createElementNS(SVG_NS, 'path');
|
|
1474
|
+
hit.setAttribute('d', d);
|
|
1475
|
+
hit.setAttribute('class', 'iwb-link-hit');
|
|
1476
|
+
hit.addEventListener('pointerdown', (event) => {
|
|
1477
|
+
event.stopPropagation();
|
|
1478
|
+
openPipeMenu(card, target, event.currentTarget);
|
|
1479
|
+
});
|
|
1480
|
+
const path = document.createElementNS(SVG_NS, 'path');
|
|
1481
|
+
path.setAttribute('d', d);
|
|
1482
|
+
path.setAttribute('class', 'iwb-link');
|
|
1483
|
+
if (target.mode === 'draft') path.setAttribute('stroke-dasharray', '4 4');
|
|
1484
|
+
linkLayer.append(hit, path);
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
let pipelineFrame = 0;
|
|
1490
|
+
function schedulePipelines() {
|
|
1491
|
+
if (pipelineFrame) return;
|
|
1492
|
+
pipelineFrame = requestAnimationFrame(() => {
|
|
1493
|
+
pipelineFrame = 0;
|
|
1494
|
+
renderPipelines();
|
|
1495
|
+
});
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
/** Drag from a card's port to another card (session or note) to wire it up. */
|
|
1499
|
+
function bindPort(card) {
|
|
1500
|
+
const port = card.el.querySelector('.iwb-port');
|
|
1501
|
+
if (!port) return;
|
|
1502
|
+
port.setAttribute('title', t('pipe.port'));
|
|
1503
|
+
port.setAttribute('aria-label', t('pipe.port'));
|
|
1504
|
+
port.addEventListener('pointerdown', (event) => {
|
|
1505
|
+
event.preventDefault();
|
|
1506
|
+
event.stopPropagation();
|
|
1507
|
+
const canvasRect = canvas.getBoundingClientRect();
|
|
1508
|
+
const point = (clientX, clientY) => ({
|
|
1509
|
+
x: (clientX - canvasRect.left - state.pan.x) / state.zoom,
|
|
1510
|
+
y: (clientY - canvasRect.top - state.pan.y) / state.zoom,
|
|
1511
|
+
});
|
|
1512
|
+
const temp = document.createElementNS(SVG_NS, 'path');
|
|
1513
|
+
temp.setAttribute('class', 'iwb-link-temp');
|
|
1514
|
+
linkLayer.appendChild(temp);
|
|
1515
|
+
let hovered = null;
|
|
1516
|
+
const draw = (clientX, clientY) => {
|
|
1517
|
+
temp.setAttribute('d', linkPath(portAnchor(card), point(clientX, clientY)));
|
|
1518
|
+
};
|
|
1519
|
+
draw(event.clientX, event.clientY);
|
|
1520
|
+
try {
|
|
1521
|
+
port.setPointerCapture?.(event.pointerId);
|
|
1522
|
+
} catch {
|
|
1523
|
+
/* synthetic pointers (tests) have no active pointer id */
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
const onMove = (moveEvent) => {
|
|
1527
|
+
draw(moveEvent.clientX, moveEvent.clientY);
|
|
1528
|
+
const under = document.elementFromPoint(moveEvent.clientX, moveEvent.clientY);
|
|
1529
|
+
const candidate = under?.closest?.('.iwb-card');
|
|
1530
|
+
const targetCard = candidate ? state.cards.find((entry) => entry.el === candidate) : null;
|
|
1531
|
+
const usable = targetCard && targetCard !== card && (targetCard.sessionId || (targetCard.kind === 'note' && targetCard.id));
|
|
1532
|
+
if (hovered && hovered !== targetCard) hovered.el.classList.remove('iwb-link-target');
|
|
1533
|
+
hovered = usable ? targetCard : null;
|
|
1534
|
+
if (hovered) hovered.el.classList.add('iwb-link-target');
|
|
1535
|
+
};
|
|
1536
|
+
const finish = (upEvent) => {
|
|
1537
|
+
try {
|
|
1538
|
+
port.releasePointerCapture?.(event.pointerId);
|
|
1539
|
+
} catch {
|
|
1540
|
+
/* already released */
|
|
1541
|
+
}
|
|
1542
|
+
port.removeEventListener('pointermove', onMove);
|
|
1543
|
+
port.removeEventListener('pointerup', finish);
|
|
1544
|
+
port.removeEventListener('pointercancel', cancel);
|
|
1545
|
+
temp.remove();
|
|
1546
|
+
if (hovered) {
|
|
1547
|
+
hovered.el.classList.remove('iwb-link-target');
|
|
1548
|
+
const created = addPipeTarget(card, hovered);
|
|
1549
|
+
renderPipeBadge(card);
|
|
1550
|
+
schedulePipelines();
|
|
1551
|
+
saveSoon();
|
|
1552
|
+
toast(
|
|
1553
|
+
created
|
|
1554
|
+
? t('pipe.created').replace('{name}', hovered.title || t('untitled'))
|
|
1555
|
+
: t('pipe.already').replace('{name}', hovered.title || t('untitled'))
|
|
1556
|
+
);
|
|
1557
|
+
} else if (upEvent) {
|
|
1558
|
+
toast(t('pipe.needTarget'));
|
|
1559
|
+
}
|
|
1560
|
+
hovered = null;
|
|
1561
|
+
};
|
|
1562
|
+
const cancel = () => finish(null);
|
|
1563
|
+
port.addEventListener('pointermove', onMove);
|
|
1564
|
+
port.addEventListener('pointerup', finish);
|
|
1565
|
+
port.addEventListener('pointercancel', cancel);
|
|
1566
|
+
});
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1400
1569
|
function renderPipeBadge(card) {
|
|
1401
1570
|
const badge = card.el?.querySelector('.iwb-pipe-badge');
|
|
1402
1571
|
if (!badge) return;
|
|
1403
|
-
const
|
|
1404
|
-
badge.hidden = !
|
|
1405
|
-
if (
|
|
1406
|
-
|
|
1407
|
-
badge.
|
|
1572
|
+
const targets = pipeTargets(card).filter((target) => cardOfPipeTarget(target));
|
|
1573
|
+
badge.hidden = !targets.length;
|
|
1574
|
+
if (!targets.length) return;
|
|
1575
|
+
if (targets.length === 1) {
|
|
1576
|
+
badge.textContent = t('pipe.active').replace('{name}', pipeTargetLabel(targets[0]));
|
|
1577
|
+
badge.title = targets[0].mode === 'draft' ? t('pipe.draft') : t('pipe.send');
|
|
1578
|
+
return;
|
|
1408
1579
|
}
|
|
1580
|
+
badge.textContent = t('pipe.multi').replace('{n}', String(targets.length));
|
|
1581
|
+
badge.title = targets.map((target) => pipeTargetLabel(target)).join(' · ');
|
|
1409
1582
|
}
|
|
1410
1583
|
|
|
1411
1584
|
/** Last assistant message is what a downstream card normally wants. */
|
|
@@ -1464,112 +1637,138 @@ export function createBoard({ host, adapter, approvals, t, onOpenSession }) {
|
|
|
1464
1637
|
}
|
|
1465
1638
|
|
|
1466
1639
|
async function deliverPipeline(card) {
|
|
1467
|
-
const
|
|
1468
|
-
if (!
|
|
1469
|
-
const target = sessionCardOf(pipeline.targetSessionId);
|
|
1470
|
-
if (!target) return;
|
|
1640
|
+
const targets = pipeTargets(card);
|
|
1641
|
+
if (!targets.length) return;
|
|
1471
1642
|
const text = lastAssistantText(card);
|
|
1472
1643
|
if (!text) return;
|
|
1473
1644
|
const fingerprint = text.slice(0, 160);
|
|
1474
|
-
|
|
1645
|
+
card.pipedFingerprints = card.pipedFingerprints || {};
|
|
1475
1646
|
const depth = (card.pipeDepth || 0) + 1;
|
|
1476
1647
|
if (depth > 3) {
|
|
1477
1648
|
toast(t('pipe.tooLong'));
|
|
1478
1649
|
return;
|
|
1479
1650
|
}
|
|
1480
|
-
card.pipedFingerprint = fingerprint;
|
|
1481
1651
|
|
|
1482
|
-
|
|
1483
|
-
const
|
|
1484
|
-
if (
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1652
|
+
for (const target of targets) {
|
|
1653
|
+
const key = target.kind + ':' + target.id;
|
|
1654
|
+
if (card.pipedFingerprints[key] === fingerprint) continue;
|
|
1655
|
+
const targetCard = cardOfPipeTarget(target);
|
|
1656
|
+
|
|
1657
|
+
// A note downstream just collects the text, whatever its mode says.
|
|
1658
|
+
if (target.kind === 'note') {
|
|
1659
|
+
if (!targetCard) continue;
|
|
1660
|
+
const area = targetCard.el?.querySelector('.iwb-note-input');
|
|
1661
|
+
if (!area) continue;
|
|
1662
|
+
area.value = area.value ? area.value.replace(/\s*$/, '\n\n') + text : text;
|
|
1663
|
+
area.dispatchEvent(new Event('input', { bubbles: true }));
|
|
1664
|
+
targetCard.pipeDepth = depth;
|
|
1665
|
+
card.pipedFingerprints[key] = fingerprint;
|
|
1666
|
+
ensureVisible(targetCard);
|
|
1667
|
+
toast(t('pipe.noted').replace('{name}', targetCard.title || t('untitled')));
|
|
1668
|
+
continue;
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
if (target.mode === 'draft') {
|
|
1672
|
+
const field = targetCard?.el?.querySelector('.iwb-foot textarea');
|
|
1673
|
+
if (!field) continue;
|
|
1674
|
+
field.value = field.value ? field.value.replace(/\s*$/, '\n\n') + text : text;
|
|
1675
|
+
field.dispatchEvent(new Event('input', { bubbles: true }));
|
|
1676
|
+
ensureVisible(targetCard);
|
|
1677
|
+
targetCard.pipeDepth = depth;
|
|
1678
|
+
card.pipedFingerprints[key] = fingerprint;
|
|
1679
|
+
toast(t('pipe.drafted').replace('{name}', pipeTargetLabel(target)));
|
|
1680
|
+
continue;
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1490
1683
|
try {
|
|
1491
|
-
await adapter.prompt(target.
|
|
1492
|
-
|
|
1684
|
+
await adapter.prompt(target.id, text, 'queue');
|
|
1685
|
+
card.pipedFingerprints[key] = fingerprint;
|
|
1686
|
+
if (targetCard) targetCard.pipeDepth = depth;
|
|
1687
|
+
toast(t('pipe.sent').replace('{name}', pipeTargetLabel(target)));
|
|
1493
1688
|
} catch (error) {
|
|
1494
1689
|
toast(t('pipe.failed').replace('{error}', error?.message || ''));
|
|
1495
|
-
return;
|
|
1496
1690
|
}
|
|
1497
1691
|
}
|
|
1498
|
-
target.pipeDepth = depth;
|
|
1499
1692
|
}
|
|
1500
1693
|
|
|
1501
|
-
|
|
1694
|
+
/** Click a pipeline curve: switch that edge's mode or remove it. */
|
|
1695
|
+
function openPipeMenu(card, target, anchor) {
|
|
1502
1696
|
if (pipePop) {
|
|
1503
1697
|
closePipeMenu();
|
|
1504
1698
|
return;
|
|
1505
1699
|
}
|
|
1506
|
-
|
|
1507
|
-
const
|
|
1700
|
+
if (!target) return;
|
|
1701
|
+
const targetCard = cardOfPipeTarget(target);
|
|
1702
|
+
const label = pipeTargetLabel(target);
|
|
1703
|
+
const isNote = target.kind === 'note';
|
|
1704
|
+
const pop = el('div', 'iwb-popover iwb-link-menu');
|
|
1508
1705
|
pop.setAttribute('role', 'dialog');
|
|
1509
1706
|
pop.setAttribute('aria-label', t('pipe.title'));
|
|
1510
1707
|
const head = el('div', 'iwb-popover-head');
|
|
1511
|
-
head.textContent = t('pipe.title');
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
for (const target of targets) {
|
|
1535
|
-
addRow(
|
|
1536
|
-
target.title || t('untitled'),
|
|
1537
|
-
target.workspace || t('workspace.none'),
|
|
1538
|
-
() => {
|
|
1539
|
-
card.pipeline = { targetSessionId: target.sessionId, mode: card.pipeline?.mode || 'send' };
|
|
1708
|
+
head.textContent = isNote ? t('pipe.noteTarget') : t('pipe.title');
|
|
1709
|
+
const status = el('div', 'iwb-popover-note');
|
|
1710
|
+
status.textContent = t('pipe.linked').replace('{name}', label);
|
|
1711
|
+
pop.append(head, status);
|
|
1712
|
+
|
|
1713
|
+
if (!isNote) {
|
|
1714
|
+
const mode = target.mode === 'draft' ? 'draft' : 'send';
|
|
1715
|
+
const modes = [
|
|
1716
|
+
{ id: 'send', label: t('pipe.send'), hint: t('pipe.sendHint') },
|
|
1717
|
+
{ id: 'draft', label: t('pipe.draft'), hint: t('pipe.draftHint') },
|
|
1718
|
+
];
|
|
1719
|
+
for (const option of modes) {
|
|
1720
|
+
const row = el('button', 'iwb-model-row' + (mode === option.id ? ' current' : ''));
|
|
1721
|
+
row.type = 'button';
|
|
1722
|
+
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">✓</span>' : '');
|
|
1723
|
+
row.querySelector('.iwb-model-name').textContent = option.label;
|
|
1724
|
+
row.querySelector('.iwb-model-desc').textContent = option.hint;
|
|
1725
|
+
row.addEventListener('click', (event) => {
|
|
1726
|
+
event.stopPropagation();
|
|
1727
|
+
const targets = pipeTargets(card).map((entry) =>
|
|
1728
|
+
entry.kind === target.kind && entry.id === target.id ? { ...entry, mode: option.id } : entry
|
|
1729
|
+
);
|
|
1730
|
+
setPipeTargets(card, targets);
|
|
1540
1731
|
renderPipeBadge(card);
|
|
1732
|
+
schedulePipelines();
|
|
1541
1733
|
saveSoon();
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1734
|
+
closePipeMenu();
|
|
1735
|
+
toast(option.id === 'draft' ? t('pipe.modeDraft') : t('pipe.modeSend'));
|
|
1736
|
+
});
|
|
1737
|
+
pop.appendChild(row);
|
|
1738
|
+
}
|
|
1739
|
+
} else {
|
|
1740
|
+
const statusRow = el('div', 'iwb-popover-note');
|
|
1741
|
+
statusRow.textContent = t('pipe.noteHint');
|
|
1742
|
+
pop.appendChild(statusRow);
|
|
1546
1743
|
}
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1744
|
+
|
|
1745
|
+
const remove = el('button', 'iwb-model-row iwb-link-remove');
|
|
1746
|
+
remove.type = 'button';
|
|
1747
|
+
remove.innerHTML = '<span class="iwb-model-main"><span class="iwb-model-name"></span></span>';
|
|
1748
|
+
remove.querySelector('.iwb-model-name').textContent = isNote ? t('pipe.removeNote') : t('pipe.remove');
|
|
1749
|
+
remove.addEventListener('click', (event) => {
|
|
1750
|
+
event.stopPropagation();
|
|
1751
|
+
setPipeTargets(
|
|
1752
|
+
card,
|
|
1753
|
+
pipeTargets(card).filter((entry) => !(entry.kind === target.kind && entry.id === target.id))
|
|
1557
1754
|
);
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1755
|
+
renderPipeBadge(card);
|
|
1756
|
+
schedulePipelines();
|
|
1757
|
+
saveSoon();
|
|
1758
|
+
closePipeMenu();
|
|
1759
|
+
toast(t('pipe.removed'));
|
|
1760
|
+
if (targetCard) ensureVisible(targetCard);
|
|
1761
|
+
});
|
|
1762
|
+
pop.appendChild(remove);
|
|
1564
1763
|
|
|
1565
1764
|
const rect = anchor.getBoundingClientRect();
|
|
1566
|
-
pop.style.left = Math.round(Math.max(8, Math.min(rect.left -
|
|
1567
|
-
pop.style.top = Math.round(rect.
|
|
1765
|
+
pop.style.left = Math.round(Math.max(8, Math.min(rect.left + rect.width / 2 - 110, window.innerWidth - 240))) + 'px';
|
|
1766
|
+
pop.style.top = Math.round(rect.top + rect.height + 8) + 'px';
|
|
1568
1767
|
document.body.appendChild(pop);
|
|
1569
1768
|
pipePop = pop;
|
|
1570
1769
|
const measured = pop.getBoundingClientRect();
|
|
1571
1770
|
if (measured.bottom > window.innerHeight - 8) {
|
|
1572
|
-
pop.style.top = Math.max(8, Math.round(rect.top - measured.height -
|
|
1771
|
+
pop.style.top = Math.max(8, Math.round(rect.top - measured.height - 8)) + 'px';
|
|
1573
1772
|
}
|
|
1574
1773
|
}
|
|
1575
1774
|
|
|
@@ -1594,6 +1793,18 @@ export function createBoard({ host, adapter, approvals, t, onOpenSession }) {
|
|
|
1594
1793
|
/* the session scope may already be gone */
|
|
1595
1794
|
}
|
|
1596
1795
|
state.cards = state.cards.filter((c) => c !== card);
|
|
1796
|
+
// Drop pipeline edges that pointed at the card we just closed.
|
|
1797
|
+
const goneId = card.kind === 'note' ? card.id : card.sessionId;
|
|
1798
|
+
const goneKind = card.kind === 'note' ? 'note' : 'session';
|
|
1799
|
+
for (const other of state.cards) {
|
|
1800
|
+
const targets = pipeTargets(other);
|
|
1801
|
+
const kept = targets.filter((target) => !(target.kind === goneKind && target.id === goneId));
|
|
1802
|
+
if (kept.length !== targets.length) {
|
|
1803
|
+
setPipeTargets(other, kept);
|
|
1804
|
+
renderPipeBadge(other);
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
schedulePipelines();
|
|
1597
1808
|
if (state.selected.delete(card.id)) renderBatchBar();
|
|
1598
1809
|
if (state.focusedId === card.id) {
|
|
1599
1810
|
state.focusedId = null;
|
|
@@ -2298,6 +2509,7 @@ export function createBoard({ host, adapter, approvals, t, onOpenSession }) {
|
|
|
2298
2509
|
node.style.left = nx + 'px';
|
|
2299
2510
|
node.style.top = ny + 'px';
|
|
2300
2511
|
}
|
|
2512
|
+
schedulePipelines();
|
|
2301
2513
|
};
|
|
2302
2514
|
const up = () => {
|
|
2303
2515
|
interactionActive = false;
|
|
@@ -2436,7 +2648,7 @@ export function createBoard({ host, adapter, approvals, t, onOpenSession }) {
|
|
|
2436
2648
|
y: card.y,
|
|
2437
2649
|
w: card.w,
|
|
2438
2650
|
h: card.h,
|
|
2439
|
-
pipeline: card.
|
|
2651
|
+
pipeline: pipeTargets(card).length ? { targets: pipeTargets(card) } : null,
|
|
2440
2652
|
});
|
|
2441
2653
|
}
|
|
2442
2654
|
for (const stack of saved.stacks || []) {
|
|
@@ -2456,6 +2668,7 @@ export function createBoard({ host, adapter, approvals, t, onOpenSession }) {
|
|
|
2456
2668
|
updateEmptyState();
|
|
2457
2669
|
syncApprovalSessions();
|
|
2458
2670
|
updateTodoBar();
|
|
2671
|
+
schedulePipelines();
|
|
2459
2672
|
// The Host copy wins when it is newer (other window, other device, or a
|
|
2460
2673
|
// previous browser session whose site data was cleared). Drop the restore's
|
|
2461
2674
|
// pending write first: it must not fence off the initial remote read.
|
|
@@ -2475,13 +2688,14 @@ export function createBoard({ host, adapter, approvals, t, onOpenSession }) {
|
|
|
2475
2688
|
pan: state.pan,
|
|
2476
2689
|
settings: { ...state.settings },
|
|
2477
2690
|
cards: state.cards.map((card) => ({
|
|
2691
|
+
id: card.kind === 'note' ? card.id : undefined,
|
|
2478
2692
|
sessionId: card.sessionId,
|
|
2479
2693
|
title: card.title,
|
|
2480
2694
|
workspace: card.workspace || '',
|
|
2481
2695
|
kind: card.kind || 'session',
|
|
2482
2696
|
note: card.note || '',
|
|
2483
2697
|
pinned: Boolean(card.pinned),
|
|
2484
|
-
pipeline: card.
|
|
2698
|
+
pipeline: pipeTargets(card).length ? { targets: pipeTargets(card) } : null,
|
|
2485
2699
|
x: card.x,
|
|
2486
2700
|
y: card.y,
|
|
2487
2701
|
w: card.w,
|
package/src/client/icons.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
const ICONS = {
|
|
2
2
|
plus: '<path d="M12 5v14M5 12h14"/>',
|
|
3
|
+
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"/>',
|
|
4
|
+
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"/>',
|
|
5
|
+
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"/>',
|
|
6
|
+
quote: '<path d="M7 7h5v5a4 4 0 0 1-4 4H7"/><path d="M15 7h5v5a4 4 0 0 1-4 4h-1"/>',
|
|
7
|
+
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"/>',
|
|
3
8
|
arrange:
|
|
4
9
|
'<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"/>',
|
|
5
10
|
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"/>',
|
package/src/client/index.jsx
CHANGED
|
@@ -125,6 +125,21 @@ const zh = {
|
|
|
125
125
|
'pipe.linked': '流水线已指向「{name}」',
|
|
126
126
|
'pipe.modeSendHint': '当前:完成后自动发送',
|
|
127
127
|
'pipe.modeDraftHint': '当前:只填入草稿',
|
|
128
|
+
'pipe.already': '已经连过「{name}」了',
|
|
129
|
+
'pipe.multi': '→ {n} 个下游',
|
|
130
|
+
'pipe.noted': '结果已追加到便签「{name}」',
|
|
131
|
+
'pipe.noteTarget': '流水线 → 便签',
|
|
132
|
+
'pipe.noteHint': '下游是便签:跑完把结果追加进去,不发送',
|
|
133
|
+
'pipe.removeNote': '删除这条便签流水线',
|
|
134
|
+
'pipe.port': '拖这条线到另一张卡,建立流水线',
|
|
135
|
+
'pipe.created': '流水线已连到「{name}」',
|
|
136
|
+
'pipe.needTarget': '拖到另一张卡(会话卡或便签)上才算连线',
|
|
137
|
+
'pipe.remove': '删除这条流水线',
|
|
138
|
+
'pipe.removed': '流水线已删除',
|
|
139
|
+
'pipe.sendHint': '完成后自动把结果发过去',
|
|
140
|
+
'pipe.draftHint': '只填进下游输入框,等人确认',
|
|
141
|
+
'pipe.modeSend': '已切到:自动发送',
|
|
142
|
+
'pipe.modeDraft': '已切到:只填草稿',
|
|
128
143
|
'pipe.title': '流水线:完成后把结果送到下游卡',
|
|
129
144
|
'pipe.to': '下游卡片',
|
|
130
145
|
'pipe.send': '自动发送到下游',
|
|
@@ -402,6 +417,21 @@ const en = {
|
|
|
402
417
|
'pipe.linked': 'Pipeline points at “{name}”',
|
|
403
418
|
'pipe.modeSendHint': 'Currently: auto-send on completion',
|
|
404
419
|
'pipe.modeDraftHint': 'Currently: draft only',
|
|
420
|
+
'pipe.already': '“{name}” is already connected',
|
|
421
|
+
'pipe.multi': '→ {n} downstream',
|
|
422
|
+
'pipe.noted': 'Result appended to note “{name}”',
|
|
423
|
+
'pipe.noteTarget': 'Pipeline → note',
|
|
424
|
+
'pipe.noteHint': 'Note downstream: the result is appended, never sent',
|
|
425
|
+
'pipe.removeNote': 'Remove this note pipeline',
|
|
426
|
+
'pipe.port': 'Drag this line onto another card to wire a pipeline',
|
|
427
|
+
'pipe.created': 'Pipeline wired to “{name}”',
|
|
428
|
+
'pipe.needTarget': 'Drop it on another card (session or note) to connect',
|
|
429
|
+
'pipe.remove': 'Remove this pipeline',
|
|
430
|
+
'pipe.removed': 'Pipeline removed',
|
|
431
|
+
'pipe.sendHint': 'Send the result downstream when the turn finishes',
|
|
432
|
+
'pipe.draftHint': 'Only fill the downstream composer',
|
|
433
|
+
'pipe.modeSend': 'Mode: auto-send',
|
|
434
|
+
'pipe.modeDraft': 'Mode: draft only',
|
|
405
435
|
'pipe.title': 'Pipeline: forward this card\'s result downstream',
|
|
406
436
|
'pipe.to': 'Downstream card',
|
|
407
437
|
'pipe.send': 'Auto-send downstream',
|
package/src/client/popovers.js
CHANGED
|
@@ -213,6 +213,7 @@ export function createArrangeMenu(deps) {
|
|
|
213
213
|
defaultSize,
|
|
214
214
|
gap,
|
|
215
215
|
anchor,
|
|
216
|
+
afterArrange,
|
|
216
217
|
} = deps;
|
|
217
218
|
const el = makeEl;
|
|
218
219
|
const DEFAULT_W = defaultSize.w;
|
|
@@ -275,6 +276,7 @@ export function createArrangeMenu(deps) {
|
|
|
275
276
|
}
|
|
276
277
|
saveSoon();
|
|
277
278
|
void fitView();
|
|
279
|
+
afterArrange?.();
|
|
278
280
|
toast(t('arrange.done'));
|
|
279
281
|
}
|
|
280
282
|
|