@dexhq/canvas 0.13.0 → 0.15.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/CHANGELOG.md +53 -0
- package/README.md +21 -18
- package/app/canvas/activity.tsx +8 -15
- package/app/canvas/anchoring.ts +3 -5
- package/app/canvas/canvas-input.ts +151 -14
- package/app/canvas/canvas-keys.ts +9 -0
- package/app/canvas/canvas-model.ts +5 -42
- package/app/canvas/canvas-panels.ts +1 -17
- package/app/canvas/canvas-scene.ts +7 -3
- package/app/canvas/canvas-ui.ts +2 -1
- package/app/canvas/canvas.css +61 -26
- package/app/canvas/change-notice.tsx +10 -1
- package/app/canvas/comment-layer.tsx +2 -1
- package/app/canvas/comments.tsx +204 -82
- package/app/canvas/element-picker.ts +200 -27
- package/app/canvas/engine/canvas-gestures.ts +72 -17
- package/app/canvas/engine/canvas-store.ts +17 -1
- package/app/canvas/engine/engine.css +6 -3
- package/app/canvas/find-bar.tsx +817 -0
- package/app/canvas/find-model.ts +135 -0
- package/app/canvas/flow-canvas.tsx +18 -2
- package/app/canvas/follow-pin.ts +26 -6
- package/app/canvas/frame-node.tsx +43 -26
- package/app/canvas/imported-reviews.tsx +12 -22
- package/app/canvas/layout.ts +27 -0
- package/app/canvas/live-page.ts +142 -19
- package/app/canvas/page-find.ts +220 -0
- package/app/canvas/page-style.ts +23 -0
- package/app/canvas/section-node.tsx +2 -0
- package/app/canvas/spec-threads.ts +24 -23
- package/app/canvas/thread-focus.tsx +14 -12
- package/app/canvas/tool-cursors.ts +16 -16
- package/app/canvas/use-activity.ts +0 -8
- package/app/canvas/use-agent-changes.tsx +34 -40
- package/app/canvas/use-canvas-clipboard.tsx +11 -14
- package/app/canvas/xray.ts +3 -12
- package/app/frame.tsx +5 -0
- package/app/i18n/locales/en/messages.po +114 -12
- package/app/i18n/locales/en/messages.ts +1 -1
- package/app/i18n/locales/pseudo/messages.po +114 -12
- package/app/i18n/locales/pseudo/messages.ts +1 -1
- package/app/icons/{sets/lucide.tsx → glyphs.tsx} +7 -5
- package/app/icons/index.tsx +3 -3
- package/app/icons/types.ts +3 -10
- package/app/index.html +3 -3
- package/app/main.tsx +3 -0
- package/app/pages/canvas-settings.tsx +35 -0
- package/app/pages/canvas.tsx +27 -8
- package/app/pages/commands-settings.tsx +16 -2
- package/app/shell/about.tsx +5 -4
- package/app/shell/feedback-details.ts +0 -3
- package/app/shell/feedback-form.tsx +10 -21
- package/app/shell/feedback-link.tsx +2 -1
- package/app/shell/instructions-editor.tsx +1 -1
- package/app/shell/presence-style.ts +59 -0
- package/app/shell/presence.tsx +6 -3
- package/app/shell/scaled-frame.tsx +21 -9
- package/app/shell/settings-sections.ts +12 -0
- package/app/shell/sidebar.tsx +1 -1
- package/app/studio-ui.d.ts +0 -9
- package/app/types.ts +21 -205
- package/app/ui/file-drop.ts +128 -0
- package/app/ui/prompt-editor.tsx +1 -1
- package/app/ui/shadcn/input-group.tsx +2 -2
- package/dist/cli/banner.d.mts +4 -2
- package/dist/cli/banner.mjs +34 -11
- package/dist/cli/commands/app.mjs +19 -11
- package/dist/cli/commands/create.d.mts +26 -14
- package/dist/cli/commands/create.mjs +13 -7
- package/dist/cli/commands/dev.mjs +2 -3
- package/dist/cli/commands/hook.mjs +2 -1
- package/dist/cli/commands/init.d.mts +11 -6
- package/dist/cli/help.d.mts +1 -1
- package/dist/cli/help.mjs +3 -3
- package/dist/cli/main.d.mts +22 -12
- package/dist/config/index.d.mts +6 -5
- package/dist/config/project-files.d.mts +6 -3
- package/dist/config/project-files.mjs +14 -5
- package/dist/config/renamed.d.mts +0 -2
- package/dist/config/renamed.mjs +1 -3
- package/dist/config/schema.d.mts +0 -5
- package/dist/config/schema.mjs +0 -5
- package/dist/content/capture.d.mts +2 -2
- package/dist/content/capture.mjs +2 -2
- package/dist/content/content.d.mts +3 -141
- package/dist/content/content.mjs +7 -65
- package/dist/content/flow-specs.mjs +1 -1
- package/dist/content/prototype-summary.d.mts +3 -39
- package/dist/content/prototype-summary.mjs +2 -3
- package/dist/content/prototypes.mjs +1 -1
- package/dist/content/snapshot-client.mjs +1 -1
- package/dist/content/text-replace.d.mts +30 -0
- package/dist/content/text-replace.mjs +309 -0
- package/dist/content/thread-module.mjs +1 -1
- package/dist/content/threads.mjs +1 -1
- package/dist/paths.d.mts +0 -2
- package/dist/paths.mjs +1 -3
- package/dist/server/agent-env.d.mts +5 -1
- package/dist/server/agent-env.mjs +7 -2
- package/dist/server/agent-session.d.mts +14 -1
- package/dist/server/agent-session.mjs +84 -19
- package/dist/server/brief.mjs +3 -3
- package/dist/server/build-pictures.mjs +1 -1
- package/dist/server/channel.d.mts +19 -24
- package/dist/server/channel.mjs +70 -37
- package/dist/server/claimed-presence.d.mts +18 -0
- package/dist/server/claimed-presence.mjs +58 -0
- package/dist/server/close-check.mjs +2 -2
- package/dist/server/comments/actions.d.mts +153 -0
- package/dist/server/comments/actions.mjs +154 -0
- package/dist/server/comments/routes.d.mts +25 -0
- package/dist/server/comments/routes.mjs +88 -0
- package/dist/server/comments/tools.d.mts +6 -0
- package/dist/server/comments/tools.mjs +154 -0
- package/dist/server/dev-server.mjs +36 -13
- package/dist/server/file-errors.d.mts +7 -2
- package/dist/server/file-errors.mjs +31 -8
- package/dist/server/file-lock.d.mts +2 -2
- package/dist/server/file-lock.mjs +130 -36
- package/dist/server/mcp.d.mts +0 -2
- package/dist/server/mcp.mjs +7 -8
- package/dist/server/me.d.mts +1 -1
- package/dist/server/open-page.d.mts +22 -0
- package/dist/server/open-page.mjs +20 -2
- package/dist/server/outcome.d.mts +22 -0
- package/dist/server/outcome.mjs +8 -0
- package/dist/server/own-copies.mjs +2 -2
- package/dist/server/people.d.mts +1 -1
- package/dist/server/port.d.mts +12 -0
- package/dist/server/port.mjs +66 -14
- package/dist/server/presence.d.mts +4 -1
- package/dist/server/presence.mjs +2 -2
- package/dist/server/requests.d.mts +5 -1
- package/dist/server/requests.mjs +32 -47
- package/dist/server/studio-for.d.mts +5 -0
- package/dist/server/studio-for.mjs +18 -4
- package/dist/server/sync-install.d.mts +8 -12
- package/dist/server/sync-install.mjs +12 -30
- package/dist/server/thread-source.mjs +2 -2
- package/dist/server/tools/describe.d.mts +1 -1
- package/dist/server/tools/describe.mjs +1 -1
- package/dist/server/tools/feedback.d.mts +1 -1
- package/dist/server/tools/reading.mjs +13 -4
- package/dist/server/tools/show.d.mts +1 -1
- package/dist/server/tools/snapshot.d.mts +1 -1
- package/dist/server/tools/thread-list.mjs +1 -1
- package/dist/server/tools/watch.mjs +5 -3
- package/dist/server/vite.mjs +28 -31
- package/dist/server/web-app.mjs +7 -10
- package/dist/server/work-groups.mjs +1 -1
- package/dist/setup/apply.mjs +8 -14
- package/dist/setup/create.d.mts +4 -2
- package/dist/setup/create.mjs +118 -36
- package/dist/setup/design-system-checks.mjs +3 -12
- package/dist/setup/desktop-app-script.mjs +4 -3
- package/dist/setup/desktop-app-start.d.mts +8 -2
- package/dist/setup/desktop-app-start.mjs +64 -29
- package/dist/setup/desktop-app.d.mts +8 -0
- package/dist/setup/desktop-app.mjs +20 -4
- package/dist/setup/detect.d.mts +14 -7
- package/dist/setup/detect.mjs +56 -10
- package/dist/setup/doctor.mjs +2 -4
- package/dist/setup/existing-setup.d.mts +1 -3
- package/dist/setup/existing-setup.mjs +10 -11
- package/dist/setup/migrate/row-titles.mjs +1 -1
- package/dist/setup/own-app.d.mts +1 -2
- package/dist/setup/own-app.mjs +4 -5
- package/dist/setup/plan.d.mts +8 -6
- package/dist/setup/plan.mjs +64 -48
- package/dist/setup/project.d.mts +6 -17
- package/dist/setup/project.mjs +17 -61
- package/dist/setup/prompts.d.mts +5 -5
- package/dist/setup/prompts.mjs +28 -61
- package/dist/setup/questions.d.mts +12 -4
- package/dist/setup/questions.mjs +10 -25
- package/dist/setup/starters.d.mts +2 -0
- package/dist/setup/starters.mjs +26 -9
- package/dist/setup/workspace-setup.d.mts +1 -2
- package/dist/setup/workspace-setup.mjs +4 -6
- package/dist/setup/write.d.mts +15 -5
- package/dist/setup/write.mjs +35 -9
- package/dist/shared/annotations-core.mjs +1 -1
- package/dist/shared/canvas-core.mjs +1 -1
- package/dist/shared/canvas-file.d.mts +201 -0
- package/dist/shared/canvas-file.mjs +1 -0
- package/dist/shared/comments/routes.d.mts +53 -0
- package/dist/shared/comments/routes.mjs +37 -0
- package/dist/shared/feedback.d.mts +8 -0
- package/dist/shared/feedback.mjs +10 -2
- package/dist/shared/page-review.d.mts +2 -11
- package/dist/shared/page-review.mjs +4 -13
- package/dist/shared/presence-core.d.mts +11 -0
- package/dist/shared/presence-core.mjs +11 -2
- package/dist/shared/review-file.d.mts +5 -0
- package/dist/shared/review-file.mjs +23 -13
- package/dist/shared/server-page.mjs +7 -1
- package/dist/shared/signup.d.mts +2 -5
- package/dist/shared/signup.mjs +2 -35
- package/dist/shared/studio-events.d.mts +0 -6
- package/dist/shared/studio-events.mjs +1 -5
- package/dist/shared/studio-files.d.mts +12 -0
- package/dist/shared/studio-files.mjs +6 -1
- package/dist/shared/studio-routes.d.mts +16 -62
- package/dist/shared/studio-routes.mjs +1 -69
- package/dist/shared/threads-core.d.mts +2 -2
- package/dist/shared/threads-core.mjs +1 -1
- package/extension/dist/feedback.js +148 -138
- package/extension/dist/manifest.json +1 -1
- package/extension/dist/picker.js +146 -136
- package/package.json +3 -20
- package/src/cli/banner.ts +45 -11
- package/src/cli/commands/app.ts +23 -8
- package/src/cli/commands/create.ts +17 -9
- package/src/cli/commands/dev.ts +0 -3
- package/src/cli/commands/hook.ts +4 -1
- package/src/cli/help.ts +3 -3
- package/src/config/index.ts +6 -5
- package/src/config/project-files.ts +21 -11
- package/src/config/renamed.ts +0 -3
- package/src/config/schema.ts +0 -1
- package/src/content/capture.ts +6 -12
- package/src/content/content.ts +7 -244
- package/src/content/flow-specs.ts +2 -1
- package/src/content/prototype-summary.ts +4 -44
- package/src/content/review-pages.ts +2 -1
- package/src/content/snapshot-client.ts +1 -1
- package/src/content/text-replace.ts +449 -0
- package/src/paths.ts +0 -8
- package/src/server/agent-env.ts +12 -2
- package/src/server/agent-session.ts +124 -34
- package/src/server/brief.ts +8 -3
- package/src/server/channel.ts +121 -52
- package/src/server/claimed-presence.ts +93 -0
- package/src/server/comments/actions.ts +352 -0
- package/src/server/comments/routes.ts +176 -0
- package/src/server/comments/tools.ts +317 -0
- package/src/server/dev-server.ts +49 -15
- package/src/server/file-errors.ts +47 -13
- package/src/server/file-lock.ts +205 -54
- package/src/server/mcp.ts +13 -14
- package/src/server/me.ts +2 -5
- package/src/server/open-page.ts +54 -4
- package/src/server/outcome.ts +26 -0
- package/src/server/people.ts +2 -1
- package/src/server/port.ts +94 -20
- package/src/server/presence.ts +11 -3
- package/src/server/requests.ts +60 -70
- package/src/server/studio-for.ts +27 -3
- package/src/server/sync-install.ts +35 -26
- package/src/server/thread-place.ts +2 -4
- package/src/server/tools/reading.ts +16 -3
- package/src/server/tools/watch.ts +7 -7
- package/src/server/vite.ts +37 -40
- package/src/server/web-app.ts +14 -12
- package/src/setup/apply.ts +10 -16
- package/src/setup/create.ts +143 -37
- package/src/setup/design-system-checks.ts +7 -15
- package/src/setup/desktop-app-script.ts +4 -3
- package/src/setup/desktop-app-start.ts +94 -26
- package/src/setup/desktop-app.ts +24 -3
- package/src/setup/detect.ts +56 -14
- package/src/setup/doctor.ts +4 -4
- package/src/setup/existing-setup.ts +10 -12
- package/src/setup/own-app.ts +2 -5
- package/src/setup/plan.ts +93 -84
- package/src/setup/project.ts +25 -118
- package/src/setup/prompts.ts +44 -127
- package/src/setup/questions.ts +27 -29
- package/src/setup/starters.ts +35 -10
- package/src/setup/workspace-setup.ts +8 -18
- package/src/setup/write.ts +52 -9
- package/src/shared/canvas-file.ts +205 -0
- package/src/shared/comments/routes.ts +79 -0
- package/src/shared/feedback.ts +14 -4
- package/src/shared/page-review.ts +11 -16
- package/src/shared/presence-core.ts +16 -2
- package/src/shared/review-file.ts +28 -12
- package/src/shared/server-page.ts +11 -1
- package/src/shared/signup.ts +4 -28
- package/src/shared/studio-events.ts +0 -13
- package/src/shared/studio-files.ts +14 -0
- package/src/shared/studio-routes.ts +21 -64
- package/src/shared/threads-core.ts +2 -2
- package/templates/methods/review.md +2 -2
- package/templates/rules/canvas-frames.md +104 -0
- package/templates/rules/canvas.md +8 -142
- package/templates/rules/prototypes.md +1 -1
- package/templates/rules/snapshots.md +52 -0
- package/templates/starters/standalone/README.md +7 -7
- package/templates/starters/standalone/components.json +1 -1
- package/templates/starters/standalone/package.json +1 -2
- package/templates/starters/turborepo/README.md +6 -6
- package/templates/starters/turborepo/apps/web/components.json +1 -1
- package/templates/starters/turborepo/apps/web/package.json +1 -2
- package/templates/starters/turborepo/apps/web/src/app.tsx +4 -5
- package/templates/starters/turborepo/packages/ui/components.json +1 -1
- package/templates/starters/turborepo/packages/ui/package.json +1 -2
- package/templates/starters/vite/README.md +7 -6
- package/templates/starters/vite/components.json +1 -1
- package/templates/starters/vite/package.json +1 -2
- package/templates/starters/vite/src/app.tsx +3 -4
- package/templates/starters/vite/src/components/ui/accordion.tsx +71 -0
- package/templates/starters/vite/src/components/ui/attachment.tsx +1 -1
- package/templates/starters/vite/src/components/ui/badge.tsx +2 -2
- package/templates/starters/vite/src/components/ui/button.tsx +17 -12
- package/templates/starters/vite/src/components/ui/card.tsx +1 -1
- package/templates/starters/vite/src/components/ui/checkbox.tsx +28 -0
- package/templates/starters/vite/src/components/ui/dialog.tsx +5 -5
- package/templates/starters/vite/src/components/ui/dropdown-menu.tsx +17 -14
- package/templates/starters/vite/src/components/ui/field.tsx +3 -1
- package/templates/starters/vite/src/components/ui/input-group.tsx +5 -3
- package/templates/starters/vite/src/components/ui/input.tsx +1 -1
- package/templates/starters/vite/src/components/ui/label.tsx +2 -0
- package/templates/starters/vite/src/components/ui/native-select.tsx +3 -4
- package/templates/starters/vite/src/components/ui/popover.tsx +1 -1
- package/templates/starters/vite/src/components/ui/separator.tsx +2 -0
- package/templates/starters/vite/src/components/ui/spinner.tsx +3 -7
- package/templates/starters/vite/src/components/ui/switch.tsx +1 -1
- package/templates/starters/vite/src/components/ui/textarea.tsx +1 -1
- package/templates/starters/vite/src/components/ui/toggle.tsx +4 -2
- package/templates/starters/vite/src/index.css +533 -111
- package/app/icons/sets/hugeicons.tsx +0 -259
- package/app/icons/sets/phosphor.tsx +0 -251
- package/dist/server/icon-set.d.mts +0 -15
- package/dist/server/icon-set.mjs +0 -31
- package/dist/server/tools/close-reply.d.mts +0 -6
- package/dist/server/tools/close-reply.mjs +0 -138
- package/dist/server/tools/comment.d.mts +0 -6
- package/dist/server/tools/comment.mjs +0 -49
- package/dist/shared/icon-sets.d.mts +0 -9
- package/dist/shared/icon-sets.mjs +0 -21
- package/src/server/icon-set.ts +0 -56
- package/src/server/tools/close-reply.ts +0 -271
- package/src/server/tools/comment.ts +0 -96
- package/src/shared/icon-sets.ts +0 -23
- /package/app/public/{sudio-192.png → dex-192.png} +0 -0
- /package/app/public/{sudio-512.png → dex-512.png} +0 -0
- /package/app/public/{apple-touch-icon.png → dex-apple-touch-icon.png} +0 -0
- /package/app/public/{favicon-32.png → dex-icon-32.png} +0 -0
- /package/app/public/{favicon.svg → dex-icon.svg} +0 -0
- /package/app/public/{sudio-maskable-512.png → dex-maskable-512.png} +0 -0
package/src/server/port.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
// Where `dex dev` listens. When the project's port is taken
|
|
2
|
-
// holds it: this project's own Dex (so
|
|
3
|
-
// it), another checkout's or project's,
|
|
4
|
-
// anything but this project's Dex, it
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
1
|
+
// Where `dex dev` listens. When the project's port is taken, on either
|
|
2
|
+
// address family, it finds what holds it: this project's own Dex (so
|
|
3
|
+
// there is nothing to do but open it), another checkout's or project's,
|
|
4
|
+
// or some other process. Held by anything but this project's Dex, it
|
|
5
|
+
// moves to the next free port, where agents still find it
|
|
6
|
+
// (studio-for.ts). Asked for one port (STUDIO_PORT, as the installed app
|
|
7
|
+
// asks for the address it opens), it keeps to that one and stops.
|
|
8
|
+
// cli/banner.ts says which.
|
|
8
9
|
|
|
9
10
|
import { execFile } from "node:child_process";
|
|
11
|
+
import { connect } from "node:net";
|
|
10
12
|
import { promisify } from "node:util";
|
|
11
13
|
import type { ViteDevServer } from "vite";
|
|
12
14
|
import {
|
|
@@ -20,6 +22,43 @@ const IN_USE_RE = /already in use/;
|
|
|
20
22
|
const ASK_TIMEOUT_MS = 1000;
|
|
21
23
|
const run = promisify(execFile);
|
|
22
24
|
|
|
25
|
+
/** Where `localhost` may reach a port: either family. */
|
|
26
|
+
const LOCALHOST_ADDRESSES = ["127.0.0.1", "::1"] as const;
|
|
27
|
+
/**
|
|
28
|
+
* How long a connection on loopback may take: one is made at once, but
|
|
29
|
+
* Windows takes seconds to refuse one.
|
|
30
|
+
*/
|
|
31
|
+
const CONNECT_TIMEOUT_MS = 250;
|
|
32
|
+
|
|
33
|
+
/** Whether anything accepts a connection on `port` at `host`. */
|
|
34
|
+
const accepts = (port: number, host: string): Promise<boolean> =>
|
|
35
|
+
new Promise((answer) => {
|
|
36
|
+
const socket = connect({ port, host });
|
|
37
|
+
const done = (listens: boolean) => {
|
|
38
|
+
socket.destroy();
|
|
39
|
+
answer(listens);
|
|
40
|
+
};
|
|
41
|
+
socket.once("connect", () => done(true));
|
|
42
|
+
socket.once("error", () => done(false));
|
|
43
|
+
// No answer in time counts as none, a turn later: after this process
|
|
44
|
+
// was busy, the timer runs before a connection already made is heard.
|
|
45
|
+
socket.setTimeout(CONNECT_TIMEOUT_MS, () =>
|
|
46
|
+
setImmediate(() => done(false))
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Whether anything listens on `port` where `localhost` may reach it, on
|
|
52
|
+
* either address family.
|
|
53
|
+
*/
|
|
54
|
+
export async function heldOnLocalhost(port: number): Promise<boolean> {
|
|
55
|
+
const held = await Promise.all(
|
|
56
|
+
// A port out of range is no one's: Vite's listen says it is wrong.
|
|
57
|
+
LOCALHOST_ADDRESSES.map((host) => accepts(port, host).catch(() => false))
|
|
58
|
+
);
|
|
59
|
+
return held.includes(true);
|
|
60
|
+
}
|
|
61
|
+
|
|
23
62
|
/** A web app answering on a port, as its manifest says. */
|
|
24
63
|
interface AppOnPort {
|
|
25
64
|
/** Its project, as a Dex names it in PROJECT_ID_HEADER. */
|
|
@@ -80,6 +119,9 @@ export async function lsofHolder(
|
|
|
80
119
|
}
|
|
81
120
|
}
|
|
82
121
|
|
|
122
|
+
/** A Dex on a port that isn't this project's, as a person is told of it. */
|
|
123
|
+
export const OTHER_DEX = "another checkout's Dex";
|
|
124
|
+
|
|
83
125
|
/** What holds a port `dex dev` wanted. */
|
|
84
126
|
export interface PortTaken {
|
|
85
127
|
/**
|
|
@@ -133,9 +175,47 @@ export interface ListenOptions {
|
|
|
133
175
|
root?: string;
|
|
134
176
|
}
|
|
135
177
|
|
|
178
|
+
/**
|
|
179
|
+
* The port `server` is served on, once it listens. listenOnPort may have
|
|
180
|
+
* moved it off the configured one.
|
|
181
|
+
*/
|
|
182
|
+
export function servedPort(server: ViteDevServer): number {
|
|
183
|
+
const address = server.httpServer?.address();
|
|
184
|
+
return typeof address === "object" && address
|
|
185
|
+
? address.port
|
|
186
|
+
: server.config.server.port;
|
|
187
|
+
}
|
|
188
|
+
|
|
136
189
|
/** How many ports past a taken one `dex dev` tries. */
|
|
137
190
|
export const MOVE_TRIES = 20;
|
|
138
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Listen on `port`: false when anything holds it. Vite's listen fails
|
|
194
|
+
* only for a holder of the very address it takes (the one `localhost`
|
|
195
|
+
* resolves to first, or STUDIO_HOST's). Yet a browser, and Dex itself,
|
|
196
|
+
* reach the studio at `localhost`, where a holder on the other family,
|
|
197
|
+
* or (on macOS) on a narrower or wider address, would answer instead:
|
|
198
|
+
* that is taken too. Any other failure closes the server and throws.
|
|
199
|
+
*/
|
|
200
|
+
async function listenIfFree(
|
|
201
|
+
server: ViteDevServer,
|
|
202
|
+
port: number
|
|
203
|
+
): Promise<boolean> {
|
|
204
|
+
if (await heldOnLocalhost(port)) {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
try {
|
|
208
|
+
await server.listen(port);
|
|
209
|
+
return true;
|
|
210
|
+
} catch (error) {
|
|
211
|
+
if (error instanceof Error && IN_USE_RE.test(error.message)) {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
await server.close();
|
|
215
|
+
throw error;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
139
219
|
/**
|
|
140
220
|
* Listen on the configured port, or, while anything but this project's
|
|
141
221
|
* Dex holds it, on the next free one: answers what held the port it moved
|
|
@@ -151,8 +231,7 @@ export async function listenOnPort(
|
|
|
151
231
|
let movedFrom: PortTaken | undefined;
|
|
152
232
|
for (let port = wanted; port < wanted + MOVE_TRIES; port += 1) {
|
|
153
233
|
server.config.server.port = port;
|
|
154
|
-
|
|
155
|
-
await server.listen(port);
|
|
234
|
+
if (await listenIfFree(server, port)) {
|
|
156
235
|
// Vite restarts itself from its inline config (a config change):
|
|
157
236
|
// there too, the port it took, never the taken one.
|
|
158
237
|
server.config.inlineConfig.server = {
|
|
@@ -160,18 +239,13 @@ export async function listenOnPort(
|
|
|
160
239
|
port,
|
|
161
240
|
};
|
|
162
241
|
return movedFrom;
|
|
163
|
-
} catch (error) {
|
|
164
|
-
if (!(error instanceof Error && IN_USE_RE.test(error.message))) {
|
|
165
|
-
await server.close();
|
|
166
|
-
throw error;
|
|
167
|
-
}
|
|
168
|
-
const taken = await whatHolds(port, id, holderOf);
|
|
169
|
-
if (keepPort || taken.sameProject) {
|
|
170
|
-
await server.close();
|
|
171
|
-
throw new PortInUseError(taken);
|
|
172
|
-
}
|
|
173
|
-
movedFrom ??= taken;
|
|
174
242
|
}
|
|
243
|
+
const taken = await whatHolds(port, id, holderOf);
|
|
244
|
+
if (keepPort || taken.sameProject) {
|
|
245
|
+
await server.close();
|
|
246
|
+
throw new PortInUseError(taken);
|
|
247
|
+
}
|
|
248
|
+
movedFrom ??= taken;
|
|
175
249
|
}
|
|
176
250
|
await server.close();
|
|
177
251
|
throw new PortInUseError(movedFrom as PortTaken);
|
package/src/server/presence.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
freshPresence,
|
|
18
18
|
type PresenceEntry,
|
|
19
19
|
type PresenceTarget,
|
|
20
|
+
underSession,
|
|
20
21
|
} from "../shared/presence-core.ts";
|
|
21
22
|
import { withLock } from "./file-lock.ts";
|
|
22
23
|
import { legacyState, prepareState, studioState } from "./state.ts";
|
|
@@ -24,7 +25,10 @@ import { legacyState, prepareState, studioState } from "./state.ts";
|
|
|
24
25
|
/** What to clear entries by: any field left out matches every entry. */
|
|
25
26
|
export type PresenceMatch = Partial<
|
|
26
27
|
Pick<PresenceEntry, "agent" | "session" | "slug" | "target">
|
|
27
|
-
|
|
28
|
+
> & {
|
|
29
|
+
/** A session: its own entries and its sub-agents' (workerSession). */
|
|
30
|
+
within?: string;
|
|
31
|
+
};
|
|
28
32
|
|
|
29
33
|
/** A View, Doc or Prototype marked as worked on, and by whom. */
|
|
30
34
|
export interface PresenceMark extends PresenceTarget {
|
|
@@ -47,8 +51,12 @@ export const isTeammate = fromRoom;
|
|
|
47
51
|
const sameSlot = (a: PresenceEntry, b: PresenceEntry): boolean =>
|
|
48
52
|
a.slug === b.slug && a.target === b.target && a.session === b.session;
|
|
49
53
|
|
|
50
|
-
const matches = (
|
|
51
|
-
|
|
54
|
+
const matches = (
|
|
55
|
+
entry: PresenceEntry,
|
|
56
|
+
{ within, ...fields }: PresenceMatch
|
|
57
|
+
): boolean =>
|
|
58
|
+
(within === undefined || underSession(entry.session, within)) &&
|
|
59
|
+
Object.entries(fields).every(
|
|
52
60
|
([key, value]) =>
|
|
53
61
|
value === undefined || entry[key as keyof PresenceEntry] === value
|
|
54
62
|
);
|
package/src/server/requests.ts
CHANGED
|
@@ -16,8 +16,6 @@ import {
|
|
|
16
16
|
saveCommand,
|
|
17
17
|
} from "../content/commands.ts";
|
|
18
18
|
import {
|
|
19
|
-
type Canvas,
|
|
20
|
-
type Contributor,
|
|
21
19
|
createPrototype,
|
|
22
20
|
createUntitledPrototype,
|
|
23
21
|
currentPerson,
|
|
@@ -59,6 +57,7 @@ import {
|
|
|
59
57
|
} from "../content/screenshot.ts";
|
|
60
58
|
import type { SnapshotBody } from "../content/snapshot-client.ts";
|
|
61
59
|
import { editText } from "../content/text-edit.ts";
|
|
60
|
+
import { replaceText, undoReplace } from "../content/text-replace.ts";
|
|
62
61
|
import type { ThreadModule } from "../content/thread-module.ts";
|
|
63
62
|
import {
|
|
64
63
|
dismissThreadsOn,
|
|
@@ -89,6 +88,7 @@ import {
|
|
|
89
88
|
type BuildSettings,
|
|
90
89
|
} from "../shared/build-settings.ts";
|
|
91
90
|
import type { Cell } from "../shared/canvas-core.ts";
|
|
91
|
+
import type { Canvas } from "../shared/canvas-file.ts";
|
|
92
92
|
import {
|
|
93
93
|
COMMAND_SWITCHES,
|
|
94
94
|
type CommandsAnswer,
|
|
@@ -126,8 +126,10 @@ import {
|
|
|
126
126
|
studioEvent,
|
|
127
127
|
} from "../shared/studio-events.ts";
|
|
128
128
|
import {
|
|
129
|
+
type Contributor,
|
|
129
130
|
guidelinesPerson,
|
|
130
131
|
isEditableMarkdown,
|
|
132
|
+
STUDIO_FILES,
|
|
131
133
|
} from "../shared/studio-files.ts";
|
|
132
134
|
import {
|
|
133
135
|
type DesktopAppAnswer,
|
|
@@ -172,6 +174,7 @@ import {
|
|
|
172
174
|
skillFolders,
|
|
173
175
|
writeCommandMenu,
|
|
174
176
|
} from "./command-settings.ts";
|
|
177
|
+
import { COMMENT_HANDLERS } from "./comments/routes.ts";
|
|
175
178
|
import { type Feature, features } from "./features.ts";
|
|
176
179
|
import {
|
|
177
180
|
branchPrototypes,
|
|
@@ -466,7 +469,8 @@ type StudioPages = ReturnType<typeof studioPages>;
|
|
|
466
469
|
|
|
467
470
|
interface RouteContext {
|
|
468
471
|
body: RequestBody | undefined;
|
|
469
|
-
desktop
|
|
472
|
+
/** Where this studio can make its app, asked as a desktop route answers. */
|
|
473
|
+
desktop: () => DesktopAppHost;
|
|
470
474
|
events: EventHub;
|
|
471
475
|
format: Formatter;
|
|
472
476
|
launcher: AgentLauncher;
|
|
@@ -573,26 +577,31 @@ const emptyTheTrash = async ({ project }: RouteContext) => {
|
|
|
573
577
|
return {};
|
|
574
578
|
};
|
|
575
579
|
|
|
576
|
-
const listConnectedAgents = async ({ project }: RouteContext) => ({
|
|
577
|
-
agents: await connectedAgents(project.content),
|
|
580
|
+
const listConnectedAgents = async ({ project, threads }: RouteContext) => ({
|
|
581
|
+
agents: await connectedAgents(project.content, { threads }),
|
|
578
582
|
});
|
|
579
583
|
|
|
580
584
|
/** Only on this machine, where that process runs. */
|
|
581
|
-
const stopOldAgent = async ({
|
|
585
|
+
const stopOldAgent = async ({
|
|
586
|
+
project,
|
|
587
|
+
body,
|
|
588
|
+
request,
|
|
589
|
+
threads,
|
|
590
|
+
}: RouteContext) => {
|
|
582
591
|
onlyFromThisMachine(request, "Stop agents from the machine Dex runs on.");
|
|
583
592
|
const pid = body?.pid;
|
|
584
593
|
if (!(typeof pid === "number" && Number.isInteger(pid))) {
|
|
585
594
|
throw new Problems(422, ["Say which agent to stop, by its process."]);
|
|
586
595
|
}
|
|
587
596
|
try {
|
|
588
|
-
await stopAgentServer(project.content, pid);
|
|
597
|
+
await stopAgentServer(project.content, pid, threads);
|
|
589
598
|
} catch (error) {
|
|
590
599
|
if (error instanceof NotAnOldSession) {
|
|
591
600
|
throw new Problems(409, [error.message]);
|
|
592
601
|
}
|
|
593
602
|
throw error;
|
|
594
603
|
}
|
|
595
|
-
return { agents: await connectedAgents(project.content) };
|
|
604
|
+
return { agents: await connectedAgents(project.content, { threads }) };
|
|
596
605
|
};
|
|
597
606
|
|
|
598
607
|
const listAgentSetups = async ({ project }: RouteContext) => ({
|
|
@@ -838,19 +847,20 @@ const desktopAnswer = async (
|
|
|
838
847
|
|
|
839
848
|
const loadDesktopApp = ({ request, desktop }: RouteContext) => {
|
|
840
849
|
fromThisMac(request, false);
|
|
841
|
-
return desktopAnswer(desktop);
|
|
850
|
+
return desktopAnswer(desktop());
|
|
842
851
|
};
|
|
843
852
|
|
|
844
853
|
async function changeDesktopApp({ request, desktop, body }: RouteContext) {
|
|
845
854
|
fromThisMac(request, true);
|
|
846
|
-
|
|
855
|
+
const host = desktop();
|
|
856
|
+
if ("unavailable" in host) {
|
|
847
857
|
throw new Problems(409, [
|
|
848
|
-
|
|
858
|
+
host.unavailable === "hosted"
|
|
849
859
|
? "A hosted studio can't install an app."
|
|
850
860
|
: "Installing outside the browser is macOS-only for now.",
|
|
851
861
|
]);
|
|
852
862
|
}
|
|
853
|
-
const { app, home, reveal, open, launchServices } =
|
|
863
|
+
const { app, home, reveal, open, launchServices } = host;
|
|
854
864
|
switch (body?.action) {
|
|
855
865
|
case "install": {
|
|
856
866
|
const path = await refusable(() =>
|
|
@@ -874,7 +884,7 @@ async function changeDesktopApp({ request, desktop, body }: RouteContext) {
|
|
|
874
884
|
'Send an action: "install", "open" or "remove".',
|
|
875
885
|
]);
|
|
876
886
|
}
|
|
877
|
-
return desktopAnswer(
|
|
887
|
+
return desktopAnswer(host);
|
|
878
888
|
}
|
|
879
889
|
|
|
880
890
|
const readWatch = async ({ project }: RouteContext) => ({
|
|
@@ -1026,6 +1036,35 @@ async function changeText({ project, body }: RouteContext) {
|
|
|
1026
1036
|
return result;
|
|
1027
1037
|
}
|
|
1028
1038
|
|
|
1039
|
+
/**
|
|
1040
|
+
* Find and replace on the canvas: { find, to, seen } changes the words in
|
|
1041
|
+
* the person's own folder of the file, where the frames showed them;
|
|
1042
|
+
* { undo } puts a replacement back.
|
|
1043
|
+
*/
|
|
1044
|
+
async function replaceOnCanvas({ project, body }: RouteContext) {
|
|
1045
|
+
const { folder } = prototypeNamed(project.content, body ?? {});
|
|
1046
|
+
const own = join(
|
|
1047
|
+
folder,
|
|
1048
|
+
STUDIO_FILES.people,
|
|
1049
|
+
await whoChanges(project.content)
|
|
1050
|
+
);
|
|
1051
|
+
if (typeof body?.undo === "string") {
|
|
1052
|
+
return await undoReplace(own, body.undo);
|
|
1053
|
+
}
|
|
1054
|
+
const { find, to, seen } = body ?? {};
|
|
1055
|
+
if (
|
|
1056
|
+
!(typeof find === "string" && typeof to === "string" && Array.isArray(seen))
|
|
1057
|
+
) {
|
|
1058
|
+
throw new Problems(400, ["Say what to find, and what to change it to."]);
|
|
1059
|
+
}
|
|
1060
|
+
return await replaceText(
|
|
1061
|
+
own,
|
|
1062
|
+
find,
|
|
1063
|
+
to,
|
|
1064
|
+
seen.filter((text): text is string => typeof text === "string")
|
|
1065
|
+
);
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1029
1068
|
const needsFeature = (name: Feature) => {
|
|
1030
1069
|
if (!features()[name]) {
|
|
1031
1070
|
throw new Problems(404, ["That is not on in this studio."]);
|
|
@@ -1204,60 +1243,6 @@ async function pictureOfView({
|
|
|
1204
1243
|
const threadsPrototype = (content: string, url: URL): string =>
|
|
1205
1244
|
prototypeOf(content, url).slug;
|
|
1206
1245
|
|
|
1207
|
-
const listThreads = ({ project, url, threads }: RouteContext) =>
|
|
1208
|
-
url.searchParams.has("slug")
|
|
1209
|
-
? threads.list({ prototype: threadsPrototype(project.content, url) })
|
|
1210
|
-
: threads.list();
|
|
1211
|
-
|
|
1212
|
-
/** A request for one prototype never changes another's thread. */
|
|
1213
|
-
const isThreadOf = async (
|
|
1214
|
-
threads: ThreadModule,
|
|
1215
|
-
id: string,
|
|
1216
|
-
prototype: string
|
|
1217
|
-
): Promise<boolean> => {
|
|
1218
|
-
const thread = await threads.find(id);
|
|
1219
|
-
return thread !== undefined && thread.slug === prototype;
|
|
1220
|
-
};
|
|
1221
|
-
|
|
1222
|
-
async function postThread({ project, url, body, threads }: RouteContext) {
|
|
1223
|
-
const prototype = threadsPrototype(project.content, url);
|
|
1224
|
-
if (!body) {
|
|
1225
|
-
throw new Problems(400, ["Send a thread to start, or a change to one."]);
|
|
1226
|
-
}
|
|
1227
|
-
// Who they are is the studio's to say, never the page's: a message is its
|
|
1228
|
-
// author's to edit by their slug, where names can be shared.
|
|
1229
|
-
const { name: author, slug: authorId } = await readAuthor(project.content);
|
|
1230
|
-
// The page's fields go to the thread module as they came: it finds no
|
|
1231
|
-
// thread for an id it never gave, and checks a new thread
|
|
1232
|
-
// (threadProblems) and a change (changeProblems) before keeping either.
|
|
1233
|
-
const id = body.id as string | undefined;
|
|
1234
|
-
if (id && !(await isThreadOf(threads, id, prototype))) {
|
|
1235
|
-
throw new Problems(404, ["That thread is gone."]);
|
|
1236
|
-
}
|
|
1237
|
-
const result = id
|
|
1238
|
-
? await threads.respond(id, {
|
|
1239
|
-
...body,
|
|
1240
|
-
author,
|
|
1241
|
-
authorId,
|
|
1242
|
-
} as Parameters<ThreadModule["respond"]>[1])
|
|
1243
|
-
: await threads.start({
|
|
1244
|
-
prototype,
|
|
1245
|
-
target: body.target,
|
|
1246
|
-
body: body.body,
|
|
1247
|
-
for: body.for,
|
|
1248
|
-
sketch: body.sketch,
|
|
1249
|
-
author,
|
|
1250
|
-
authorId,
|
|
1251
|
-
} as Parameters<ThreadModule["start"]>[0]);
|
|
1252
|
-
if (!result) {
|
|
1253
|
-
throw new Problems(404, ["That thread is gone."]);
|
|
1254
|
-
}
|
|
1255
|
-
if (result.problems) {
|
|
1256
|
-
throw new Problems(422, result.problems);
|
|
1257
|
-
}
|
|
1258
|
-
return result.thread;
|
|
1259
|
-
}
|
|
1260
|
-
|
|
1261
1246
|
const REVIEW_FILE_PROBLEMS: Record<ReviewFileProblem, string> = {
|
|
1262
1247
|
"not-a-review": "This is not a Dex review.",
|
|
1263
1248
|
newer: "This review is from a newer Dex: update to import it.",
|
|
@@ -2202,6 +2187,7 @@ type DeclaredRoute<Name extends StudioRouteName> =
|
|
|
2202
2187
|
| ({ prototype?: false } & DeclaredMethods<RouteContext, Name>);
|
|
2203
2188
|
|
|
2204
2189
|
const ROUTES: { [Name in StudioRouteName]: DeclaredRoute<Name> } = {
|
|
2190
|
+
...COMMENT_HANDLERS,
|
|
2205
2191
|
canvas: { prototype: true, GET: loadCanvas, PUT: saveCanvas },
|
|
2206
2192
|
annotations: {
|
|
2207
2193
|
prototype: true,
|
|
@@ -2219,7 +2205,6 @@ const ROUTES: { [Name in StudioRouteName]: DeclaredRoute<Name> } = {
|
|
|
2219
2205
|
POST: trashRemovedViews,
|
|
2220
2206
|
},
|
|
2221
2207
|
trash: { DELETE: emptyTheTrash },
|
|
2222
|
-
threads: { GET: listThreads, POST: postThread },
|
|
2223
2208
|
reviews: { limit: MAX_REVIEW_BYTES, POST: importReviews },
|
|
2224
2209
|
"spec-suggestion": { POST: acceptSpecSuggestion },
|
|
2225
2210
|
instructions: { GET: loadInstructions, PUT: saveInstructions },
|
|
@@ -2233,6 +2218,7 @@ const ROUTES: { [Name in StudioRouteName]: DeclaredRoute<Name> } = {
|
|
|
2233
2218
|
frame: { POST: addBlankFrame },
|
|
2234
2219
|
show: { POST: showOnCanvas },
|
|
2235
2220
|
text: { POST: changeText },
|
|
2221
|
+
replace: { POST: replaceOnCanvas },
|
|
2236
2222
|
props: { POST: changeProps },
|
|
2237
2223
|
insert: { POST: insertIntoView },
|
|
2238
2224
|
screenshot: { POST: screenshotView },
|
|
@@ -2308,7 +2294,11 @@ async function answer(
|
|
|
2308
2294
|
export interface StudioRequestOptions {
|
|
2309
2295
|
agents?: AgentTracker;
|
|
2310
2296
|
base?: string;
|
|
2311
|
-
|
|
2297
|
+
/**
|
|
2298
|
+
* Where the studio can make its app, asked each time: the dev server's
|
|
2299
|
+
* port is known only once it listens.
|
|
2300
|
+
*/
|
|
2301
|
+
desktop?: () => DesktopAppHost;
|
|
2312
2302
|
events: EventHub;
|
|
2313
2303
|
format?: Formatter;
|
|
2314
2304
|
launcher?: AgentLauncher;
|
|
@@ -2333,7 +2323,7 @@ export function studioRequests({
|
|
|
2333
2323
|
agents = trackAgents(project.content, { threads }),
|
|
2334
2324
|
server = {},
|
|
2335
2325
|
base = "/",
|
|
2336
|
-
desktop = { unavailable: "platform" },
|
|
2326
|
+
desktop = () => ({ unavailable: "platform" }),
|
|
2337
2327
|
}: StudioRequestOptions): (
|
|
2338
2328
|
request: IncomingMessage,
|
|
2339
2329
|
response: ServerResponse
|
package/src/server/studio-for.ts
CHANGED
|
@@ -10,7 +10,13 @@
|
|
|
10
10
|
|
|
11
11
|
import { RESTART_PATH } from "../shared/server-page.ts";
|
|
12
12
|
import type { RestartStatus } from "../shared/update-core.ts";
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
answersAs,
|
|
15
|
+
lsofHolder,
|
|
16
|
+
OTHER_DEX,
|
|
17
|
+
type PortTaken,
|
|
18
|
+
whatHolds,
|
|
19
|
+
} from "./port.ts";
|
|
14
20
|
import { projectId } from "./project-id.ts";
|
|
15
21
|
import { type RosterEntry, readRoster } from "./roster.ts";
|
|
16
22
|
|
|
@@ -71,7 +77,7 @@ async function restartFailed(port: number): Promise<boolean> {
|
|
|
71
77
|
/** What holds a port, as an agent is told: "another checkout's Dex". */
|
|
72
78
|
function holderName({ by, pid }: PortTaken): string {
|
|
73
79
|
if (by === "Dex") {
|
|
74
|
-
return
|
|
80
|
+
return OTHER_DEX;
|
|
75
81
|
}
|
|
76
82
|
return pid ? `${by} (pid ${pid})` : String(by);
|
|
77
83
|
}
|
|
@@ -136,8 +142,26 @@ export async function studioFor(
|
|
|
136
142
|
};
|
|
137
143
|
}
|
|
138
144
|
|
|
145
|
+
/**
|
|
146
|
+
* The port this checkout's Dex is on, also while it restarts there, or
|
|
147
|
+
* undefined when none is: what the app opens, and where it says to look.
|
|
148
|
+
*/
|
|
149
|
+
export function ownPort(found: StudioFor): number | undefined {
|
|
150
|
+
switch (found.kind) {
|
|
151
|
+
case "running":
|
|
152
|
+
case "starting":
|
|
153
|
+
case "failed":
|
|
154
|
+
return found.port;
|
|
155
|
+
case "none":
|
|
156
|
+
case "elsewhere":
|
|
157
|
+
return;
|
|
158
|
+
default:
|
|
159
|
+
return found satisfies never;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
139
163
|
const START =
|
|
140
|
-
"Start it with `npx dex dev` (or the project's own script, such as `npm run
|
|
164
|
+
"Start it with `npx dex dev` (or the project's own script, such as `npm run dex`), then try again.";
|
|
141
165
|
|
|
142
166
|
const ports = (tried: number[]): string =>
|
|
143
167
|
tried.map((port) => `:${port}`).join(", ");
|
|
@@ -30,49 +30,58 @@ export interface SyncPlace {
|
|
|
30
30
|
* work is in by then. Why Sync stopped comes back with where the machine
|
|
31
31
|
* stands, rather than thrown. Run it inside the repository's turn.
|
|
32
32
|
*/
|
|
33
|
-
export
|
|
33
|
+
export const syncAndUpdate = (
|
|
34
34
|
{
|
|
35
|
-
content,
|
|
36
35
|
keep,
|
|
37
36
|
message,
|
|
38
|
-
|
|
39
|
-
settings,
|
|
37
|
+
...place
|
|
40
38
|
}: SyncPlace & {
|
|
41
39
|
keep?: SyncKeep;
|
|
42
40
|
/** The commit's message, in place of one written from the changes. */
|
|
43
41
|
message?: string;
|
|
44
42
|
},
|
|
45
|
-
|
|
46
|
-
): Promise<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
} catch (error) {
|
|
52
|
-
if (!(error instanceof GitError)) {
|
|
53
|
-
throw error;
|
|
54
|
-
}
|
|
55
|
-
stopped = error;
|
|
56
|
-
}
|
|
57
|
-
const machine = await updateMachine(
|
|
58
|
-
{ content, root },
|
|
59
|
-
{ before, run, ...(running ? { running } : {}) }
|
|
43
|
+
steps: UpdateSteps = {}
|
|
44
|
+
): Promise<Updated> =>
|
|
45
|
+
thenUpdate(
|
|
46
|
+
place,
|
|
47
|
+
(run) => syncWork(place.content, place.settings, { keep, message, run }),
|
|
48
|
+
steps
|
|
60
49
|
);
|
|
61
|
-
return { machine, ...(stopped ? { stopped } : {}) };
|
|
62
|
-
}
|
|
63
50
|
|
|
64
51
|
/**
|
|
65
52
|
* Pull from base, then bring the machine up to date with what it brought
|
|
66
53
|
* in, as syncAndUpdate does for Sync. Run it inside the repository's turn.
|
|
67
54
|
*/
|
|
68
|
-
export
|
|
69
|
-
{
|
|
70
|
-
|
|
71
|
-
): Promise<
|
|
55
|
+
export const pullBaseAndUpdate = (
|
|
56
|
+
{ keep, ...place }: SyncPlace & { keep?: SyncKeep },
|
|
57
|
+
steps: UpdateSteps = {}
|
|
58
|
+
): Promise<Updated> =>
|
|
59
|
+
thenUpdate(
|
|
60
|
+
place,
|
|
61
|
+
(run) => bringInBase(place.content, place.settings, { keep, run }),
|
|
62
|
+
steps
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
interface UpdateSteps {
|
|
66
|
+
run?: StepRunner;
|
|
67
|
+
running?: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface Updated {
|
|
71
|
+
machine: MachineState;
|
|
72
|
+
stopped?: GitError;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Bring in the team's work, then update the machine, even if git stopped. */
|
|
76
|
+
async function thenUpdate(
|
|
77
|
+
{ content, root }: SyncPlace,
|
|
78
|
+
bringIn: (run: StepRunner) => Promise<unknown>,
|
|
79
|
+
{ run = runStep, running }: UpdateSteps
|
|
80
|
+
): Promise<Updated> {
|
|
72
81
|
const before = await lockfilePrint(content);
|
|
73
82
|
let stopped: GitError | undefined;
|
|
74
83
|
try {
|
|
75
|
-
await
|
|
84
|
+
await bringIn(run);
|
|
76
85
|
} catch (error) {
|
|
77
86
|
if (!(error instanceof GitError)) {
|
|
78
87
|
throw error;
|
|
@@ -4,12 +4,10 @@
|
|
|
4
4
|
// `close` says where a change landed.
|
|
5
5
|
|
|
6
6
|
import { join } from "node:path";
|
|
7
|
-
import {
|
|
8
|
-
prototypeFrames,
|
|
9
|
-
type ViewFrame,
|
|
10
|
-
} from "../content/prototype-summary.ts";
|
|
7
|
+
import { prototypeFrames } from "../content/prototype-summary.ts";
|
|
11
8
|
import { readText } from "../content/read-text.ts";
|
|
12
9
|
import { isSpecPath, kinded } from "../shared/canvas-core.ts";
|
|
10
|
+
import type { ViewFrame } from "../shared/canvas-file.ts";
|
|
13
11
|
import { prototypeFiles } from "../shared/prototypes-core.ts";
|
|
14
12
|
import { quoteAt, resolveQuote } from "../shared/spec-quote.ts";
|
|
15
13
|
import type { ChangePlace, ThreadTarget } from "../shared/threads-core.ts";
|
|
@@ -15,7 +15,8 @@ import {
|
|
|
15
15
|
type FoundComponent,
|
|
16
16
|
findComponents,
|
|
17
17
|
} from "../component-catalogue.ts";
|
|
18
|
-
import { whereThePersonIs } from "../open-page.ts";
|
|
18
|
+
import { atWorkOn, whereThePersonIs } from "../open-page.ts";
|
|
19
|
+
import { openPresence } from "../presence.ts";
|
|
19
20
|
import { briefSummary } from "../prototype-brief.ts";
|
|
20
21
|
import {
|
|
21
22
|
cutText,
|
|
@@ -96,6 +97,7 @@ export function registerReadingTools(
|
|
|
96
97
|
okAboutCode,
|
|
97
98
|
refuse,
|
|
98
99
|
root,
|
|
100
|
+
session,
|
|
99
101
|
threads,
|
|
100
102
|
withNotice,
|
|
101
103
|
} = context;
|
|
@@ -263,9 +265,20 @@ export function registerReadingTools(
|
|
|
263
265
|
annotations: { readOnlyHint: true },
|
|
264
266
|
title: "Where the person is",
|
|
265
267
|
description:
|
|
266
|
-
'Where the person is in Dex now: the file they have open (`prototype`, `fileTitle`), the `page` of it ("canvas"; "play", a section shown a frame at a time; "view", a view on a page of its own; or "file", its own page), the sections of the canvas in view (`flows`; none when they look at the canvas as a whole), the `frame` selected or playing, and when Dex last said so (`seen`, `ago`). `open` is false with a note when Dex is no longer on screen, or nobody has it open. Ask before starting on feedback, and again when the person says "this" or "here": work on what they are looking at first.',
|
|
268
|
+
'Where the person is in Dex now: the file they have open (`prototype`, `fileTitle`), the `page` of it ("canvas"; "play", a section shown a frame at a time; "view", a view on a page of its own; or "file", its own page), the sections of the canvas in view (`flows`; none when they look at the canvas as a whole), the `frame` selected or playing, and when Dex last said so (`seen`, `ago`). `open` is false with a note when Dex is no longer on screen, or nobody has it open. `atWork` is who the canvas shows at work on the file now, the view drawn in blocks: on which view or doc (`prototype` is its shared code, so every view), whose mark it is (`you`: yours end as you close or let go of your comment, or wait in `watch` with none), when it was last marked, and when it `ends` at the latest. Ask before starting on feedback, and again when the person says "this" or "here": work on what they are looking at first.',
|
|
267
269
|
inputSchema: {},
|
|
268
270
|
},
|
|
269
|
-
async () =>
|
|
271
|
+
async () => {
|
|
272
|
+
const where = await whereThePersonIs(root);
|
|
273
|
+
if (!("prototype" in where)) {
|
|
274
|
+
return ok(where);
|
|
275
|
+
}
|
|
276
|
+
const atWork = atWorkOn(
|
|
277
|
+
await openPresence(root).list(),
|
|
278
|
+
where.prototype,
|
|
279
|
+
session.marksUnder
|
|
280
|
+
);
|
|
281
|
+
return ok(atWork.length > 0 ? { ...where, atWork } : where);
|
|
282
|
+
}
|
|
270
283
|
);
|
|
271
284
|
}
|
|
@@ -7,6 +7,7 @@ import { z } from "zod";
|
|
|
7
7
|
import type { ThreadFilter } from "../../content/thread-module.ts";
|
|
8
8
|
import type { ThreadWithPrototype } from "../../shared/threads-core.ts";
|
|
9
9
|
import { FEEDBACK_WORKFLOW, isWatching } from "../channel.ts";
|
|
10
|
+
import { claimComment } from "../comments/actions.ts";
|
|
10
11
|
import { yoursGroups } from "../own-copies.ts";
|
|
11
12
|
import { LOOP_HOW, WATCH_HOW } from "../push-notice.ts";
|
|
12
13
|
import { plural, RESPONSE_BUDGETS, sizeOf } from "../response-budget.ts";
|
|
@@ -86,15 +87,12 @@ const groupsWith = (
|
|
|
86
87
|
* Claim each thread for this session, in turn: the ones it won, as they
|
|
87
88
|
* are after. One another session holds, or gone, is left out.
|
|
88
89
|
*/
|
|
89
|
-
const claimAll = async (
|
|
90
|
-
{ session }: ToolContext,
|
|
91
|
-
found: ThreadWithPrototype[]
|
|
92
|
-
) => {
|
|
90
|
+
const claimAll = async (context: ToolContext, found: ThreadWithPrototype[]) => {
|
|
93
91
|
const claimed: ThreadWithPrototype[] = [];
|
|
94
92
|
for (const thread of found) {
|
|
95
|
-
const result = await
|
|
96
|
-
if (result
|
|
97
|
-
claimed.push(result.
|
|
93
|
+
const result = await claimComment(context, thread.id);
|
|
94
|
+
if (result.value) {
|
|
95
|
+
claimed.push(result.value);
|
|
98
96
|
}
|
|
99
97
|
}
|
|
100
98
|
return claimed;
|
|
@@ -342,6 +340,8 @@ export function registerWatchTool(
|
|
|
342
340
|
if (ids) {
|
|
343
341
|
return ok(await takeThreads(ids));
|
|
344
342
|
}
|
|
343
|
+
// Waiting, an agent with nothing in hand is at work nowhere.
|
|
344
|
+
await context.session.waits();
|
|
345
345
|
const filter: ThreadFilter = { prototype, status: "waiting" };
|
|
346
346
|
let watching = true;
|
|
347
347
|
// What is claimed during the call goes back, even what was claimed as
|