git-watchtower 2.3.0 → 2.3.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.
- package/bin/git-watchtower.js +7 -0
- package/package.json +1 -1
- package/src/server/web.js +19 -4
package/bin/git-watchtower.js
CHANGED
|
@@ -3407,6 +3407,13 @@ async function startWebDashboard(openBrowser) {
|
|
|
3407
3407
|
sessionStats: sessionStats.getStats(),
|
|
3408
3408
|
}),
|
|
3409
3409
|
onAction: handleWebAction,
|
|
3410
|
+
// Route actions for non-local project tabs through the coordinator so
|
|
3411
|
+
// the targeted worker handles them in its own process. Without this,
|
|
3412
|
+
// every action runs against the coordinator's repo regardless of which
|
|
3413
|
+
// tab the user clicked.
|
|
3414
|
+
sendCommand: (pId, action, payload) => {
|
|
3415
|
+
if (coordinator) coordinator.sendCommand(pId, action, payload);
|
|
3416
|
+
},
|
|
3410
3417
|
});
|
|
3411
3418
|
webDashboard.setLocalProjectId(projectId);
|
|
3412
3419
|
|
package/package.json
CHANGED
package/src/server/web.js
CHANGED
|
@@ -40,7 +40,10 @@ const SSE_KEEPALIVE_INTERVAL = 15000;
|
|
|
40
40
|
* @typedef {Object} WebDashboardOptions
|
|
41
41
|
* @property {number} [port=4000] - Port to listen on
|
|
42
42
|
* @property {import('../state/store').Store} store - State store instance
|
|
43
|
-
* @property {function} [onAction] - Callback for
|
|
43
|
+
* @property {function} [onAction] - Callback for actions targeting the local project
|
|
44
|
+
* @property {function} [sendCommand] - Routes (projectId, action, payload) to a remote
|
|
45
|
+
* project's worker. When omitted, every action is dispatched locally — preserves
|
|
46
|
+
* single-project behaviour for callers (and tests) that don't run a coordinator.
|
|
44
47
|
* @property {function} [getExtraState] - Returns additional state to merge
|
|
45
48
|
*/
|
|
46
49
|
|
|
@@ -56,6 +59,7 @@ class WebDashboardServer {
|
|
|
56
59
|
this.port = options.port || DEFAULT_WEB_PORT;
|
|
57
60
|
this.store = options.store;
|
|
58
61
|
this.onAction = options.onAction || (() => {});
|
|
62
|
+
this.sendCommand = options.sendCommand || null;
|
|
59
63
|
this.getExtraState = options.getExtraState || (() => ({}));
|
|
60
64
|
|
|
61
65
|
/** @type {Set<import('http').ServerResponse>} */
|
|
@@ -526,12 +530,23 @@ class WebDashboardServer {
|
|
|
526
530
|
return;
|
|
527
531
|
}
|
|
528
532
|
|
|
529
|
-
//
|
|
533
|
+
// Multi-project routing: when the request targets a project that is
|
|
534
|
+
// not the coordinator's own (the user is on a different tab in the
|
|
535
|
+
// dashboard), forward to that project's worker via sendCommand
|
|
536
|
+
// instead of running the action against the coordinator's repo.
|
|
530
537
|
const projectId = data.projectId || this.localProjectId;
|
|
531
538
|
payload._projectId = projectId;
|
|
532
539
|
|
|
533
|
-
|
|
534
|
-
|
|
540
|
+
if (
|
|
541
|
+
projectId &&
|
|
542
|
+
this.localProjectId &&
|
|
543
|
+
projectId !== this.localProjectId &&
|
|
544
|
+
typeof this.sendCommand === 'function'
|
|
545
|
+
) {
|
|
546
|
+
this.sendCommand(projectId, action, payload);
|
|
547
|
+
} else {
|
|
548
|
+
this.onAction(action, payload);
|
|
549
|
+
}
|
|
535
550
|
|
|
536
551
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
537
552
|
res.end(JSON.stringify({ ok: true }));
|