@antelopejs/dms-assistant 0.1.0 → 0.2.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 +4 -17
- package/dist/builder/config.d.ts +1 -0
- package/dist/builder/config.js +9 -0
- package/dist/builder/config.js.map +1 -1
- package/dist/builder/constants/routes.d.ts +1 -0
- package/dist/builder/constants/routes.js +1 -0
- package/dist/builder/constants/routes.js.map +1 -1
- package/dist/builder/index.js +2 -0
- package/dist/builder/index.js.map +1 -1
- package/dist/builder/reload.d.ts +2 -0
- package/dist/builder/reload.js +24 -0
- package/dist/builder/reload.js.map +1 -0
- package/dist/builder/routes/database.d.ts +3 -0
- package/dist/builder/routes/database.js +11 -0
- package/dist/builder/routes/database.js.map +1 -1
- package/dist/constants/i18n.d.ts +1 -1
- package/dist/constants/i18n.js +1 -1
- package/dist/constants/i18n.js.map +1 -1
- package/dist/constants/project-mcp.d.ts +0 -2
- package/dist/constants/project-mcp.js +1 -3
- package/dist/constants/project-mcp.js.map +1 -1
- package/dist/constants/sidecar.d.ts +6 -6
- package/dist/constants/sidecar.js +6 -6
- package/dist/constants/sidecar.js.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/lifecycle/project-mcp-json.js +6 -37
- package/dist/lifecycle/project-mcp-json.js.map +1 -1
- package/dist/lifecycle/sidecar-unavailable-error.js +1 -1
- package/dist/lifecycle/sidecar-unavailable-error.js.map +1 -1
- package/dist/pages/activity/page.js +1 -1
- package/dist/pages/activity/page.js.map +1 -1
- package/dist/pages/changes/page.js +1 -1
- package/dist/pages/changes/page.js.map +1 -1
- package/dist/routes/activity.js +1 -1
- package/dist/routes/activity.js.map +1 -1
- package/dist/vocabulary/enumerations.js +0 -1
- package/dist/vocabulary/enumerations.js.map +1 -1
- package/dist/vocabulary/tools.js +1 -1
- package/dist/vocabulary/tools.js.map +1 -1
- package/frontend-vue/app/chat/components/AnswerRecord.vue +3 -3
- package/frontend-vue/app/chat/components/ApprovalDock.vue +15 -11
- package/frontend-vue/app/chat/components/BlockOutline.vue +10 -10
- package/frontend-vue/app/chat/components/BlockPreviewCard.vue +9 -7
- package/frontend-vue/app/chat/components/BlockPreviewModal.vue +15 -14
- package/frontend-vue/app/chat/components/BlockPreviewThumb.vue +1 -1
- package/frontend-vue/app/chat/components/BuildDialog.vue +16 -13
- package/frontend-vue/app/chat/components/ChangeSetCard.vue +15 -13
- package/frontend-vue/app/chat/components/ChatEmpty.vue +4 -4
- package/frontend-vue/app/chat/components/ChatView.vue +45 -101
- package/frontend-vue/app/chat/components/Composer.vue +42 -34
- package/frontend-vue/app/chat/components/ConnectionBanner.vue +6 -5
- package/frontend-vue/app/chat/components/ConversationDrawer.vue +33 -27
- package/frontend-vue/app/chat/components/DiffView.vue +1 -1
- package/frontend-vue/app/chat/components/FoldBar.vue +34 -28
- package/frontend-vue/app/chat/components/MessageList.vue +10 -10
- package/frontend-vue/app/chat/components/NoticeCard.vue +17 -17
- package/frontend-vue/app/chat/components/PanelHeader.vue +16 -15
- package/frontend-vue/app/chat/components/PermissionCard.vue +11 -11
- package/frontend-vue/app/chat/components/PlanCard.vue +5 -5
- package/frontend-vue/app/chat/components/ProviderNotice.vue +6 -4
- package/frontend-vue/app/chat/components/QuestionDock.vue +13 -10
- package/frontend-vue/app/chat/components/QueueDock.vue +17 -15
- package/frontend-vue/app/chat/components/RulesList.vue +9 -5
- package/frontend-vue/app/chat/components/StepsDock.vue +2 -2
- package/frontend-vue/app/chat/components/ToolCluster.vue +3 -3
- package/frontend-vue/app/chat/components/ToolRow.vue +4 -4
- package/frontend-vue/app/chat/components/TurnErrorCard.vue +5 -5
- package/frontend-vue/app/chat/components/UndoConflictModal.vue +4 -4
- package/frontend-vue/app/chat/components/chat-tokens.css +83 -0
- package/frontend-vue/app/chat/composables/useChatI18n.ts +2 -1
- package/frontend-vue/app/chat/composables/useComposerAttachments.ts +3 -3
- package/frontend-vue/app/chat/constants/conversation.ts +4 -4
- package/frontend-vue/app/chat/constants/protocol.ts +2 -1
- package/frontend-vue/app/chat/constants/run-status.ts +6 -6
- package/frontend-vue/app/chat/types/protocol.ts +0 -7
- package/frontend-vue/app/chat/utils/permission-view.ts +44 -36
- package/frontend-vue/app/chat/utils/status-label.ts +7 -5
- package/frontend-vue/app/chat/utils/suggestions.ts +9 -9
- package/frontend-vue/app/chat/utils/tool-lexicon.ts +4 -4
- package/frontend-vue/app/components/ActivityDetail.vue +15 -13
- package/frontend-vue/app/components/ChangesView.vue +20 -20
- package/frontend-vue/app/components/ChatPanel.vue +31 -31
- package/frontend-vue/app/components/LauncherIcon.vue +44 -38
- package/frontend-vue/app/components/Onboarding.vue +3 -3
- package/frontend-vue/app/components/OnboardingWidget.vue +8 -4
- package/frontend-vue/app/components/PaletteAnswer.vue +27 -23
- package/frontend-vue/app/onboarding/analysis-lead.ts +66 -0
- package/frontend-vue/app/onboarding/connect-database.ts +92 -21
- package/frontend-vue/app/onboarding/connect-memory.ts +204 -0
- package/frontend-vue/app/onboarding/controller.ts +44 -6
- package/frontend-vue/app/onboarding/install.ts +7 -2
- package/frontend-vue/app/onboarding/runtime.ts +4 -4
- package/frontend-vue/app/plugins/ai.client.ts +8 -8
- package/frontend-vue/app/plugins/side-panel.ts +1 -1
- package/frontend-vue/app/runtime/assistant-actions.ts +6 -4
- package/frontend-vue/app/runtime/assistant-commands.ts +31 -16
- package/frontend-vue/app/runtime/assistant-notifications.ts +17 -9
- package/frontend-vue/app/runtime/assistant-session.ts +1 -1
- package/frontend-vue/app/runtime/channel-client.ts +1 -1
- package/frontend-vue/app/runtime/constants.ts +11 -11
- package/frontend-vue/app/runtime/sidecar-status.ts +1 -1
- package/frontend-vue/app/views/ChangeSetPanel.vue +20 -20
- package/frontend-vue/app/views/DecisionLabel.vue +1 -1
- package/frontend-vue/app/views/DiffView.vue +6 -6
- package/frontend-vue/app/views/ResultPill.vue +4 -2
- package/frontend-vue/app/views/RowStepper.vue +3 -3
- package/frontend-vue/app/views/UnavailableState.vue +5 -5
- package/frontend-vue/app/views/composables/useAiData.ts +1 -1
- package/frontend-vue/app/views/composables/useChangeSetActions.ts +13 -5
- package/frontend-vue/app/views/composables/useViewFormat.ts +1 -1
- package/frontend-vue/app/views/constants.ts +0 -1
- package/frontend-vue/app/views/onboarding/OnboardingAi.vue +15 -15
- package/frontend-vue/app/views/onboarding/OnboardingAnalysis.vue +13 -13
- package/frontend-vue/app/views/onboarding/OnboardingClaude.vue +14 -14
- package/frontend-vue/app/views/onboarding/OnboardingCodex.vue +11 -11
- package/frontend-vue/app/views/onboarding/OnboardingConnected.vue +4 -4
- package/frontend-vue/app/views/onboarding/OnboardingContinue.vue +18 -18
- package/frontend-vue/app/views/onboarding/OnboardingDatabase.vue +37 -33
- package/frontend-vue/app/views/onboarding/OnboardingDontShow.vue +1 -1
- package/frontend-vue/app/views/onboarding/OnboardingPaths.vue +7 -7
- package/frontend-vue/app/views/onboarding/OnboardingReady.vue +5 -5
- package/frontend-vue/app/views/onboarding/OnboardingScratch.vue +9 -9
- package/frontend-vue/app/views/onboarding/OnboardingWelcome.vue +11 -11
- package/frontend-vue/app/views/onboarding/login-text.ts +6 -6
- package/frontend-vue/app/views/types.ts +0 -1
- package/frontend-vue/app/views/utils/moment.ts +2 -2
- package/frontend-vue/builder/app/runtime/api.ts +2 -0
- package/frontend-vue/builder/app/runtime/database-build.ts +23 -1
- package/frontend-vue/builder/app/runtime/database-connect.ts +5 -0
- package/frontend-vue/builder/tests/database-connect.test.ts +1 -1
- package/frontend-vue/dms.frontend.ts +2 -2
- package/frontend-vue/i18n/locales/builder-en-GB.json +1 -1
- package/frontend-vue/i18n/locales/builder-fr-FR.json +1 -1
- package/frontend-vue/i18n/locales/{dms-ai-pages-en-GB.json → dms-assistant-pages-en-GB.json} +2 -3
- package/frontend-vue/i18n/locales/{dms-ai-pages-fr-FR.json → dms-assistant-pages-fr-FR.json} +2 -3
- package/frontend-vue/i18n/locales/{dms-ai-panel-en-GB.json → dms-assistant-panel-en-GB.json} +1 -2
- package/frontend-vue/i18n/locales/{dms-ai-panel-fr-FR.json → dms-assistant-panel-fr-FR.json} +1 -2
- package/frontend-vue/i18n/locales/{dms-ai-views-en-GB.json → dms-assistant-views-en-GB.json} +2 -3
- package/frontend-vue/i18n/locales/{dms-ai-views-fr-FR.json → dms-assistant-views-fr-FR.json} +2 -3
- package/frontend-vue/package.json +2 -2
- package/frontend-vue/pnpm-lock.yaml +71 -21
- package/frontend-vue/tests/chat/block-target.test.ts +1 -1
- package/frontend-vue/tests/chat/build-view.test.ts +9 -5
- package/frontend-vue/tests/chat/chat-scroll.test.ts +1 -1
- package/frontend-vue/tests/chat/held-card.test.ts +2 -2
- package/frontend-vue/tests/chat/provider-notice.test.ts +1 -1
- package/frontend-vue/tests/chat/tool-lexicon.test.ts +16 -10
- package/frontend-vue/tests/chat-panel.test.ts +10 -10
- package/frontend-vue/tests/chat-transport.test.ts +1 -1
- package/frontend-vue/tests/launcher-icon.test.ts +1 -1
- package/frontend-vue/tests/launcher-label.test.ts +40 -0
- package/frontend-vue/tests/onboarding-connect-memory.test.ts +126 -0
- package/frontend-vue/tests/onboarding-controller-restart.test.ts +134 -0
- package/frontend-vue/tests/onboarding-controller.test.ts +58 -0
- package/frontend-vue/tests/onboarding-database-engines.test.ts +2 -2
- package/frontend-vue/tests/onboarding-database-new-url.test.ts +174 -0
- package/frontend-vue/tests/onboarding-database-reload.test.ts +229 -0
- package/frontend-vue/tests/onboarding-database-tabs.test.ts +184 -0
- package/frontend-vue/tests/onboarding-database.test.ts +13 -118
- package/frontend-vue/tests/palette-assistant.test.ts +8 -8
- package/frontend-vue/tests/panel-approvals.test.ts +1 -1
- package/frontend-vue/tests/panel-closed-conversation.test.ts +53 -0
- package/frontend-vue/tests/panel-mockup-prompt.test.ts +2 -2
- package/frontend-vue/tests/panel-modes.test.ts +1 -16
- package/frontend-vue/tests/panel-questions.test.ts +1 -1
- package/frontend-vue/tests/panel-states.test.ts +1 -1
- package/frontend-vue/tests/panel-tools.test.ts +2 -2
- package/frontend-vue/tests/sidecar-guest.test.ts +1 -1
- package/frontend-vue/tests/support/api-error-presenter.ts +4 -2
- package/frontend-vue/tests/support/database-connect.ts +129 -0
- package/frontend-vue/tests/support/i18n.ts +1 -1
- package/frontend-vue/tests/support/onboarding-host.ts +1 -0
- package/frontend-vue/tests/support/onboarding.ts +29 -1
- package/frontend-vue/tests/views/api-data-reads.test.ts +7 -3
- package/frontend-vue/tests/views/diff-view.test.ts +4 -2
- package/package.json +5 -8
- package/sidecar/dist/agent/permission-bus.d.ts +1 -0
- package/sidecar/dist/agent/permission-bus.js +1 -0
- package/sidecar/dist/agent/permission-bus.js.map +1 -1
- package/sidecar/dist/agent/question-bus.d.ts +1 -0
- package/sidecar/dist/agent/question-bus.js +3 -0
- package/sidecar/dist/agent/question-bus.js.map +1 -1
- package/sidecar/dist/audit/activity-query.js +0 -1
- package/sidecar/dist/audit/activity-query.js.map +1 -1
- package/sidecar/dist/audit/activity.js +11 -3
- package/sidecar/dist/audit/activity.js.map +1 -1
- package/sidecar/dist/constants/audit.d.ts +1 -1
- package/sidecar/dist/constants/audit.js +0 -1
- package/sidecar/dist/constants/audit.js.map +1 -1
- package/sidecar/dist/constants/chatgpt.d.ts +7 -7
- package/sidecar/dist/constants/chatgpt.js +6 -6
- package/sidecar/dist/constants/chatgpt.js.map +1 -1
- package/sidecar/dist/constants/checkpoints.d.ts +2 -2
- package/sidecar/dist/constants/checkpoints.js +2 -2
- package/sidecar/dist/constants/checkpoints.js.map +1 -1
- package/sidecar/dist/constants/codex.d.ts +9 -9
- package/sidecar/dist/constants/codex.js +8 -8
- package/sidecar/dist/constants/codex.js.map +1 -1
- package/sidecar/dist/constants/daemon.d.ts +2 -2
- package/sidecar/dist/constants/daemon.js +2 -2
- package/sidecar/dist/constants/daemon.js.map +1 -1
- package/sidecar/dist/constants/env.d.ts +1 -1
- package/sidecar/dist/constants/env.js +1 -1
- package/sidecar/dist/constants/env.js.map +1 -1
- package/sidecar/dist/constants/mcp.d.ts +4 -4
- package/sidecar/dist/constants/mcp.js +2 -2
- package/sidecar/dist/constants/mcp.js.map +1 -1
- package/sidecar/dist/constants/paths.d.ts +1 -1
- package/sidecar/dist/constants/paths.js +5 -1
- package/sidecar/dist/constants/paths.js.map +1 -1
- package/sidecar/dist/constants/preview.d.ts +2 -2
- package/sidecar/dist/constants/preview.js +2 -17
- package/sidecar/dist/constants/preview.js.map +1 -1
- package/sidecar/dist/constants/providers.d.ts +2 -2
- package/sidecar/dist/constants/providers.js +2 -2
- package/sidecar/dist/constants/providers.js.map +1 -1
- package/sidecar/dist/constants/settings.d.ts +1 -1
- package/sidecar/dist/constants/settings.js +1 -1
- package/sidecar/dist/constants/settings.js.map +1 -1
- package/sidecar/dist/constants/skills.d.ts +1 -1
- package/sidecar/dist/constants/skills.js +1 -1
- package/sidecar/dist/constants/skills.js.map +1 -1
- package/sidecar/dist/constants/state.d.ts +2 -1
- package/sidecar/dist/constants/state.js +2 -1
- package/sidecar/dist/constants/state.js.map +1 -1
- package/sidecar/dist/constants/tool-titles.d.ts +0 -40
- package/sidecar/dist/constants/tool-titles.js +0 -42
- package/sidecar/dist/constants/tool-titles.js.map +1 -1
- package/sidecar/dist/index.js +5 -6
- package/sidecar/dist/index.js.map +1 -1
- package/sidecar/dist/mcp/tools/preview-blocks.js +24 -19
- package/sidecar/dist/mcp/tools/preview-blocks.js.map +1 -1
- package/sidecar/dist/mcp/types.d.ts +1 -1
- package/sidecar/dist/prompts/agent.js +1 -1
- package/sidecar/dist/prompts/agent.js.map +1 -1
- package/sidecar/dist/protocol/events.d.ts +10 -28
- package/sidecar/dist/protocol/events.js +7 -5
- package/sidecar/dist/protocol/events.js.map +1 -1
- package/sidecar/dist/protocol/preview.js +1 -1
- package/sidecar/dist/protocol/preview.js.map +1 -1
- package/sidecar/dist/providers/codex/permission-profiles.d.ts +1 -1
- package/sidecar/dist/providers/codex/permission-profiles.js +1 -1
- package/sidecar/dist/providers/codex/permission-profiles.js.map +1 -1
- package/sidecar/dist/server/chat-socket-registry.d.ts +1 -0
- package/sidecar/dist/server/chat-socket-registry.js +14 -0
- package/sidecar/dist/server/chat-socket-registry.js.map +1 -1
- package/sidecar/dist/server/host-command-router.d.ts +9 -2
- package/sidecar/dist/server/host-command-router.js +5 -2
- package/sidecar/dist/server/host-command-router.js.map +1 -1
- package/sidecar/dist/server/host-page.d.ts +3 -0
- package/sidecar/dist/server/host-page.js +5 -0
- package/sidecar/dist/server/host-page.js.map +1 -0
- package/sidecar/dist/server/host-socket-registry.d.ts +1 -1
- package/sidecar/dist/server/host-socket-registry.js +6 -6
- package/sidecar/dist/server/host-socket-registry.js.map +1 -1
- package/sidecar/dist/server/routing.js +62 -20
- package/sidecar/dist/server/routing.js.map +1 -1
- package/sidecar/dist/server/turns.js +11 -3
- package/sidecar/dist/server/turns.js.map +1 -1
- package/sidecar/dist/server/ws.js +10 -2
- package/sidecar/dist/server/ws.js.map +1 -1
- package/sidecar/dist/skills/plugin-wrapper.js +1 -1
- package/sidecar/dist/skills/plugin-wrapper.js.map +1 -1
- package/sidecar/dist/state/conversations.d.ts +3 -1
- package/sidecar/dist/state/conversations.js +54 -3
- package/sidecar/dist/state/conversations.js.map +1 -1
- package/sidecar/dist/state/host-state.d.ts +2 -2
- package/sidecar/dist/state/host-state.js +6 -6
- package/sidecar/dist/state/host-state.js.map +1 -1
- package/sidecar/dist/state/settings-store.js +1 -14
- package/sidecar/dist/state/settings-store.js.map +1 -1
- package/sidecar/dist/state/store.d.ts +1 -0
- package/sidecar/dist/state/store.js +16 -9
- package/sidecar/dist/state/store.js.map +1 -1
- package/sidecar/dist/state/stored-schemas.js +0 -4
- package/sidecar/dist/state/stored-schemas.js.map +1 -1
- package/sidecar/dist/state/types.d.ts +2 -5
- package/sidecar/dist/state/types.js.map +1 -1
- package/sidecar/package.json +3 -2
- package/skills/{dms-ai → dms-assistant}/SKILL.md +6 -6
- package/skills/{dms-ai → dms-assistant}/cases.json +13 -13
- package/skills/{dms-ai-code-mode → dms-assistant-code-mode}/SKILL.md +7 -7
- package/skills/{dms-ai-code-mode → dms-assistant-code-mode}/cases.json +11 -11
- package/dist/lifecycle/builder-settings-move.d.ts +0 -1
- package/dist/lifecycle/builder-settings-move.js +0 -182
- package/dist/lifecycle/builder-settings-move.js.map +0 -1
- package/dist/lifecycle/builder-settings-plan.d.ts +0 -59
- package/dist/lifecycle/builder-settings-plan.js +0 -176
- package/dist/lifecycle/builder-settings-plan.js.map +0 -1
- package/dist/lifecycle/builder-settings-text.d.ts +0 -19
- package/dist/lifecycle/builder-settings-text.js +0 -82
- package/dist/lifecycle/builder-settings-text.js.map +0 -1
- package/dist/lifecycle/entry-verdict.d.ts +0 -15
- package/dist/lifecycle/entry-verdict.js +0 -30
- package/dist/lifecycle/entry-verdict.js.map +0 -1
- package/dist/lifecycle/environment-bindings.d.ts +0 -8
- package/dist/lifecycle/environment-bindings.js +0 -154
- package/dist/lifecycle/environment-bindings.js.map +0 -1
- package/dist/lifecycle/legacy-entries.d.ts +0 -8
- package/dist/lifecycle/legacy-entries.js +0 -126
- package/dist/lifecycle/legacy-entries.js.map +0 -1
- package/sidecar/dist/mcp/sketch-refusals.d.ts +0 -2
- package/sidecar/dist/mcp/sketch-refusals.js +0 -6
- package/sidecar/dist/mcp/sketch-refusals.js.map +0 -1
- package/sidecar/dist/state/legacy-tool-names.d.ts +0 -3
- package/sidecar/dist/state/legacy-tool-names.js +0 -34
- package/sidecar/dist/state/legacy-tool-names.js.map +0 -1
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import {
|
|
2
|
+
connectionId,
|
|
3
|
+
type DatabaseEngine,
|
|
4
|
+
tablesModuleOf,
|
|
5
|
+
} from "../../builder/app/runtime/database-connect";
|
|
6
|
+
import type { DatabaseAccess } from "../../builder/app/runtime/database-types";
|
|
7
|
+
import { CONNECTABLE_ENGINES } from "./connect-database";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A connection the popup wrote into the project and follows until its analysis is ready. The tab
|
|
11
|
+
* keeps it so that a reload of the page, or the popup closed and opened again, follows it again.
|
|
12
|
+
* The URL is never kept: it holds the password.
|
|
13
|
+
*/
|
|
14
|
+
export interface WrittenConnection {
|
|
15
|
+
engine: DatabaseEngine;
|
|
16
|
+
/** The connection id the popup named after the URL's database. */
|
|
17
|
+
connection: string;
|
|
18
|
+
/** The live check's answer before the write. */
|
|
19
|
+
access: DatabaseAccess;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** A written connection as the tab remembers it. */
|
|
23
|
+
export interface RememberedConnection extends WrittenConnection {
|
|
24
|
+
/** The tables module the builder names after the connection. */
|
|
25
|
+
module: string;
|
|
26
|
+
/** When following it again ends, in milliseconds since the epoch: past it, the popup starts over. */
|
|
27
|
+
until: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The tab's connect attempts and the connection the latest one wrote, for the signed-in user. Every
|
|
32
|
+
* popup of the tab shares it, so a write that answers after a later attempt began, in this popup or
|
|
33
|
+
* one opened since, is not kept.
|
|
34
|
+
*/
|
|
35
|
+
export interface ConnectMemory {
|
|
36
|
+
/**
|
|
37
|
+
* The connection the signed-in user's latest attempt wrote, until {@link CONNECT_MEMORY_LIMIT_MS}
|
|
38
|
+
* after the write; null for another user or another project's user.
|
|
39
|
+
*/
|
|
40
|
+
read: () => RememberedConnection | null;
|
|
41
|
+
/** Starts an attempt: forgets the written connection and every earlier attempt. */
|
|
42
|
+
begin: () => string;
|
|
43
|
+
/** Keeps the connection `attempt` wrote, unless a later attempt began or `clear` ran since. */
|
|
44
|
+
write: (attempt: string, written: WrittenConnection) => void;
|
|
45
|
+
clear: () => void;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** How long after its write a connection is followed again: past it, the popup starts over. */
|
|
49
|
+
export const CONNECT_MEMORY_LIMIT_MS = 15 * 60_000;
|
|
50
|
+
|
|
51
|
+
export const CONNECT_MEMORY_KEY = "dms-assistant:onboarding-connect";
|
|
52
|
+
|
|
53
|
+
interface Kept extends WrittenConnection {
|
|
54
|
+
writtenAt: number;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface Stored {
|
|
58
|
+
owner: string | null;
|
|
59
|
+
attempt: string;
|
|
60
|
+
written?: Kept;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function textOf(value: object, key: string): string | undefined {
|
|
64
|
+
const field: unknown = Reflect.get(value, key);
|
|
65
|
+
return typeof field === "string" ? field : undefined;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function accessOf(value: unknown): DatabaseAccess | null {
|
|
69
|
+
if (value === null || typeof value !== "object") return null;
|
|
70
|
+
const reachable: unknown = Reflect.get(value, "reachable");
|
|
71
|
+
const canRead: unknown = Reflect.get(value, "canRead");
|
|
72
|
+
const canWrite: unknown = Reflect.get(value, "canWrite");
|
|
73
|
+
const latencyMs: unknown = Reflect.get(value, "latencyMs");
|
|
74
|
+
if (
|
|
75
|
+
typeof reachable !== "boolean" ||
|
|
76
|
+
typeof canRead !== "boolean" ||
|
|
77
|
+
typeof canWrite !== "boolean"
|
|
78
|
+
) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
reachable,
|
|
83
|
+
canRead,
|
|
84
|
+
canWrite,
|
|
85
|
+
latencyMs: typeof latencyMs === "number" ? latencyMs : undefined,
|
|
86
|
+
user: textOf(value, "user"),
|
|
87
|
+
reason: textOf(value, "reason"),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function isConnectionId(text: string | undefined): text is string {
|
|
92
|
+
return text !== undefined && text !== "" && connectionId(text) === text;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function keptOf(value: unknown): Kept | null {
|
|
96
|
+
if (value === null || typeof value !== "object") return null;
|
|
97
|
+
const stored = textOf(value, "engine");
|
|
98
|
+
const engine = CONNECTABLE_ENGINES.find((known) => known === stored);
|
|
99
|
+
const connection = textOf(value, "connection");
|
|
100
|
+
const access = accessOf(Reflect.get(value, "access"));
|
|
101
|
+
const writtenAt: unknown = Reflect.get(value, "writtenAt");
|
|
102
|
+
if (
|
|
103
|
+
engine === undefined ||
|
|
104
|
+
!isConnectionId(connection) ||
|
|
105
|
+
access === null ||
|
|
106
|
+
typeof writtenAt !== "number"
|
|
107
|
+
) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
return { engine, connection, access, writtenAt };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function parsed(text: string | null): Stored | null {
|
|
114
|
+
if (text === null) return null;
|
|
115
|
+
let value: unknown;
|
|
116
|
+
try {
|
|
117
|
+
value = JSON.parse(text);
|
|
118
|
+
} catch {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
if (value === null || typeof value !== "object") return null;
|
|
122
|
+
const attempt = textOf(value, "attempt");
|
|
123
|
+
if (attempt === undefined) return null;
|
|
124
|
+
const owner = textOf(value, "owner") ?? null;
|
|
125
|
+
const written = keptOf(Reflect.get(value, "written"));
|
|
126
|
+
return written === null ? { owner, attempt } : { owner, attempt, written };
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function newAttempt(): string {
|
|
130
|
+
return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** The storage calls the memory makes; the tab's `sessionStorage` provides them. */
|
|
134
|
+
export type ConnectStorage = Pick<
|
|
135
|
+
Storage,
|
|
136
|
+
"getItem" | "setItem" | "removeItem"
|
|
137
|
+
>;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* The connect attempts in `storage`, the tab's `sessionStorage`, for `owner`: the signed-in user's
|
|
141
|
+
* id, which the project's own database issues, so it tells projects and users apart. A storage
|
|
142
|
+
* that refuses keeps none.
|
|
143
|
+
*/
|
|
144
|
+
export function connectMemory(
|
|
145
|
+
storage: () => ConnectStorage,
|
|
146
|
+
owner: () => string | null,
|
|
147
|
+
): ConnectMemory {
|
|
148
|
+
function stored(): Stored | null {
|
|
149
|
+
try {
|
|
150
|
+
return parsed(storage().getItem(CONNECT_MEMORY_KEY));
|
|
151
|
+
} catch {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function keep(next: Stored): void {
|
|
157
|
+
try {
|
|
158
|
+
storage().setItem(CONNECT_MEMORY_KEY, JSON.stringify(next));
|
|
159
|
+
} catch {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return {
|
|
165
|
+
read: () => {
|
|
166
|
+
const current = stored();
|
|
167
|
+
const written = current?.written;
|
|
168
|
+
if (
|
|
169
|
+
written === undefined ||
|
|
170
|
+
current?.owner === null ||
|
|
171
|
+
current?.owner !== owner()
|
|
172
|
+
) {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
const until = written.writtenAt + CONNECT_MEMORY_LIMIT_MS;
|
|
176
|
+
if (Date.now() >= until) return null;
|
|
177
|
+
const { engine, connection, access } = written;
|
|
178
|
+
return {
|
|
179
|
+
engine,
|
|
180
|
+
connection,
|
|
181
|
+
access,
|
|
182
|
+
module: tablesModuleOf(connection),
|
|
183
|
+
until,
|
|
184
|
+
};
|
|
185
|
+
},
|
|
186
|
+
begin: () => {
|
|
187
|
+
const attempt = newAttempt();
|
|
188
|
+
keep({ owner: owner(), attempt });
|
|
189
|
+
return attempt;
|
|
190
|
+
},
|
|
191
|
+
write: (attempt, written) => {
|
|
192
|
+
const current = stored();
|
|
193
|
+
if (current?.attempt !== attempt) return;
|
|
194
|
+
keep({ ...current, written: { ...written, writtenAt: Date.now() } });
|
|
195
|
+
},
|
|
196
|
+
clear: () => {
|
|
197
|
+
try {
|
|
198
|
+
storage().removeItem(CONNECT_MEMORY_KEY);
|
|
199
|
+
} catch {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
}
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from "vue";
|
|
11
11
|
import type { AssistantSession } from "../runtime/assistant-session";
|
|
12
12
|
import { type OnboardingApi, refusalMessage } from "./api";
|
|
13
|
+
import type { ConnectMemory } from "./connect-memory";
|
|
13
14
|
import { hasContent, NO_CONTENT, type ProjectContent } from "./content";
|
|
14
15
|
import type {
|
|
15
16
|
ClaudeTokenCheck,
|
|
@@ -30,6 +31,12 @@ import type { OnboardingStep } from "./public";
|
|
|
30
31
|
/** How often the popup asks whether the ChatGPT sign-in in the other tab completed. */
|
|
31
32
|
export const CODEX_POLL_MS = 2_000;
|
|
32
33
|
|
|
34
|
+
/**
|
|
35
|
+
* How long after a first read of the onboarding that failed it reads again, while this tab follows
|
|
36
|
+
* a connection it wrote: a page loaded while the project restarts opens on it once the backend answers.
|
|
37
|
+
*/
|
|
38
|
+
const RESUME_RETRY_MS = 2_000;
|
|
39
|
+
|
|
33
40
|
export interface OnboardingDeps {
|
|
34
41
|
api: OnboardingApi;
|
|
35
42
|
assistant: Pick<
|
|
@@ -40,6 +47,8 @@ export interface OnboardingDeps {
|
|
|
40
47
|
preferences: PreferenceStore;
|
|
41
48
|
/** The builder runs, so a database can be connected. */
|
|
42
49
|
canConnectDatabase: boolean;
|
|
50
|
+
/** The connection this tab wrote and still follows, across a reload of the page. */
|
|
51
|
+
connecting: ConnectMemory;
|
|
43
52
|
openTab: (url: string) => void;
|
|
44
53
|
}
|
|
45
54
|
|
|
@@ -57,13 +66,17 @@ export interface OnboardingController {
|
|
|
57
66
|
/** Why the last action failed, until the next view. */
|
|
58
67
|
problem: Readonly<Ref<string | null>>;
|
|
59
68
|
canConnectDatabase: boolean;
|
|
69
|
+
connecting: ConnectMemory;
|
|
60
70
|
/**
|
|
61
|
-
* Reads the onboarding state and the project's content, then opens the popup if it should
|
|
62
|
-
*
|
|
71
|
+
* Reads the onboarding state and the project's content, then opens the popup if it should: on
|
|
72
|
+
* the connect form when this tab still follows a connection it wrote. Rejects when the backend
|
|
73
|
+
* does not answer its state; `open` reads again after that, and while this tab follows a
|
|
74
|
+
* connection it wrote, so does the controller itself every {@link RESUME_RETRY_MS} until `stop`.
|
|
63
75
|
*/
|
|
64
76
|
load: () => Promise<void>;
|
|
65
77
|
/**
|
|
66
|
-
* Opens the popup, on `step` if given,
|
|
78
|
+
* Opens the popup, on `step` if given, else on the connect form while this tab still follows a
|
|
79
|
+
* connection it wrote, and reads the project's content again so it shows this
|
|
67
80
|
* session's conversations and mockups. While the state is unread, it opens once a read
|
|
68
81
|
* answers, and asks for that read again if the last one failed.
|
|
69
82
|
*/
|
|
@@ -110,6 +123,8 @@ export function createOnboarding(deps: OnboardingDeps): OnboardingController {
|
|
|
110
123
|
let codexTimer: ReturnType<typeof setInterval> | undefined;
|
|
111
124
|
let loading: Promise<void> | undefined;
|
|
112
125
|
let loadFailed = false;
|
|
126
|
+
let stopped = false;
|
|
127
|
+
let retry: ReturnType<typeof setTimeout> | undefined;
|
|
113
128
|
|
|
114
129
|
const done = computed(
|
|
115
130
|
() =>
|
|
@@ -149,6 +164,17 @@ export function createOnboarding(deps: OnboardingDeps): OnboardingController {
|
|
|
149
164
|
});
|
|
150
165
|
}
|
|
151
166
|
|
|
167
|
+
function stepOrResumed(step: OnboardingStep | null): OnboardingStep | null {
|
|
168
|
+
if (
|
|
169
|
+
step !== null ||
|
|
170
|
+
!deps.canConnectDatabase ||
|
|
171
|
+
deps.connecting.read() === null
|
|
172
|
+
) {
|
|
173
|
+
return step;
|
|
174
|
+
}
|
|
175
|
+
return "connect-database";
|
|
176
|
+
}
|
|
177
|
+
|
|
152
178
|
function open(step?: OnboardingStep): void {
|
|
153
179
|
const current = state.value;
|
|
154
180
|
if (current === null) {
|
|
@@ -156,8 +182,9 @@ export function createOnboarding(deps: OnboardingDeps): OnboardingController {
|
|
|
156
182
|
if (loadFailed) void load().catch(() => undefined);
|
|
157
183
|
return;
|
|
158
184
|
}
|
|
159
|
-
|
|
160
|
-
|
|
185
|
+
const shown = stepOrResumed(step ?? null);
|
|
186
|
+
show(current, shown);
|
|
187
|
+
void refresh(shown, flow.value);
|
|
161
188
|
}
|
|
162
189
|
|
|
163
190
|
function load(): Promise<void> {
|
|
@@ -177,12 +204,20 @@ export function createOnboarding(deps: OnboardingDeps): OnboardingController {
|
|
|
177
204
|
]);
|
|
178
205
|
} catch (error) {
|
|
179
206
|
loadFailed = true;
|
|
207
|
+
if (retry !== undefined) clearTimeout(retry);
|
|
208
|
+
if (!stopped && stepOrResumed(null) !== null) {
|
|
209
|
+
retry = setTimeout(
|
|
210
|
+
() => void load().catch(() => undefined),
|
|
211
|
+
RESUME_RETRY_MS,
|
|
212
|
+
);
|
|
213
|
+
}
|
|
180
214
|
throw error;
|
|
181
215
|
}
|
|
182
216
|
loadFailed = false;
|
|
217
|
+
if (retry !== undefined) clearTimeout(retry);
|
|
183
218
|
state.value = read;
|
|
184
219
|
content.value = project;
|
|
185
|
-
const step = pendingStep ?? null;
|
|
220
|
+
const step = stepOrResumed(pendingStep ?? null);
|
|
186
221
|
const asked = pendingStep !== undefined;
|
|
187
222
|
pendingStep = undefined;
|
|
188
223
|
const opens =
|
|
@@ -273,6 +308,7 @@ export function createOnboarding(deps: OnboardingDeps): OnboardingController {
|
|
|
273
308
|
}),
|
|
274
309
|
problem: readonly(problem),
|
|
275
310
|
canConnectDatabase: deps.canConnectDatabase,
|
|
311
|
+
connecting: deps.connecting,
|
|
276
312
|
load,
|
|
277
313
|
open,
|
|
278
314
|
close: () => {
|
|
@@ -313,6 +349,8 @@ export function createOnboarding(deps: OnboardingDeps): OnboardingController {
|
|
|
313
349
|
deps.assistant.navigate(path);
|
|
314
350
|
},
|
|
315
351
|
stop: () => {
|
|
352
|
+
stopped = true;
|
|
353
|
+
if (retry !== undefined) clearTimeout(retry);
|
|
316
354
|
stopCodexPoll();
|
|
317
355
|
stopWatchingCodex();
|
|
318
356
|
},
|
|
@@ -8,6 +8,7 @@ import type { DatabaseConnection } from "../../builder/app/runtime/database-type
|
|
|
8
8
|
import type { AssistantSession } from "../runtime/assistant-session";
|
|
9
9
|
import { createOnboardingApi } from "./api";
|
|
10
10
|
import { type ProjectContent, readConversations } from "./content";
|
|
11
|
+
import { connectMemory } from "./connect-memory";
|
|
11
12
|
import { createOnboarding, type OnboardingController } from "./controller";
|
|
12
13
|
import { LAUNCHER_ICON } from "../runtime/constants";
|
|
13
14
|
import { listMockups } from "./mockups";
|
|
@@ -30,6 +31,8 @@ export interface OnboardingHost {
|
|
|
30
31
|
};
|
|
31
32
|
provided: ShallowRef<OnboardingController | null>;
|
|
32
33
|
canConnectDatabase: boolean;
|
|
34
|
+
/** The signed-in user's id: the connection the tab remembers belongs to that user. */
|
|
35
|
+
userId: () => string | null;
|
|
33
36
|
/** Resolves once the app is mounted: the overlay joins the page after hydration. */
|
|
34
37
|
appMounted: Promise<void>;
|
|
35
38
|
runWithContext: <T>(callback: () => T) => T;
|
|
@@ -59,7 +62,7 @@ function widgetFor(needsAttention: boolean): AppWidget {
|
|
|
59
62
|
const widget: AppWidget = {
|
|
60
63
|
id: WIDGET_ID,
|
|
61
64
|
icon: LAUNCHER_ICON,
|
|
62
|
-
label: "$
|
|
65
|
+
label: "$dms_assistant.views.onboarding.widget.label",
|
|
63
66
|
body: ONBOARDING_WIDGET_COMPONENT_NAME,
|
|
64
67
|
onSelectEvent: ONBOARDING_SELECTED_STATE_KEY,
|
|
65
68
|
};
|
|
@@ -127,7 +130,8 @@ async function readContent(
|
|
|
127
130
|
* Starts the onboarding popup in a tab where the assistant runs: provides its controller, follows
|
|
128
131
|
* `?assistant=connect`, and once the app is mounted and past the DMS's setup wizard reads whether
|
|
129
132
|
* the popup opens, then registers the overlay and the widget, whether or not that read answered:
|
|
130
|
-
* a backend that does not answer yet leaves the popup unavailable until a later `open` reads again
|
|
133
|
+
* a backend that does not answer yet leaves the popup unavailable until a later `open` reads again,
|
|
134
|
+
* or, while this tab follows a connection it wrote, until the controller's own read again answers.
|
|
131
135
|
*/
|
|
132
136
|
export function startOnboarding(host: OnboardingHost): () => void {
|
|
133
137
|
const { session } = host;
|
|
@@ -140,6 +144,7 @@ export function startOnboarding(host: OnboardingHost): () => void {
|
|
|
140
144
|
readContent: () => readContent(session, host.canConnectDatabase),
|
|
141
145
|
preferences: preferenceStore(() => window.localStorage),
|
|
142
146
|
canConnectDatabase: host.canConnectDatabase,
|
|
147
|
+
connecting: connectMemory(() => window.sessionStorage, host.userId),
|
|
143
148
|
openTab: (url) => void window.open(url, "_blank", "noopener"),
|
|
144
149
|
});
|
|
145
150
|
host.provided.value = controller;
|
|
@@ -10,17 +10,17 @@ export const ONBOARDING_CONTROLLER_KEY: InjectionKey<OnboardingRef> = Symbol(
|
|
|
10
10
|
"dms-assistant:onboarding-controller",
|
|
11
11
|
);
|
|
12
12
|
|
|
13
|
-
/** The overlay component the plugin registers, the module's `
|
|
14
|
-
export const ONBOARDING_COMPONENT_NAME = "
|
|
13
|
+
/** The overlay component the plugin registers, the module's `DmsAssistant` prefix included. */
|
|
14
|
+
export const ONBOARDING_COMPONENT_NAME = "DmsAssistantOnboarding";
|
|
15
15
|
|
|
16
16
|
/** The card the DMS widget dock unfolds from the assistant's chip. */
|
|
17
|
-
export const ONBOARDING_WIDGET_COMPONENT_NAME = "
|
|
17
|
+
export const ONBOARDING_WIDGET_COMPONENT_NAME = "DmsAssistantOnboardingWidget";
|
|
18
18
|
|
|
19
19
|
/** The tab's onboarding controller, for a view the overlay draws once it exists. */
|
|
20
20
|
export function useOnboarding(): OnboardingController {
|
|
21
21
|
const controller = inject(ONBOARDING_CONTROLLER_KEY, null)?.value;
|
|
22
22
|
if (controller === null || controller === undefined) {
|
|
23
|
-
throw new Error("An onboarding view renders inside
|
|
23
|
+
throw new Error("An onboarding view renders inside DmsAssistantOnboarding");
|
|
24
24
|
}
|
|
25
25
|
return controller;
|
|
26
26
|
}
|
|
@@ -30,9 +30,9 @@ import {
|
|
|
30
30
|
createAssistantActivity,
|
|
31
31
|
} from "../runtime/assistant-activity";
|
|
32
32
|
import {
|
|
33
|
-
launcherAction,
|
|
34
33
|
paletteAssistant,
|
|
35
34
|
paletteSource,
|
|
35
|
+
registerLauncher,
|
|
36
36
|
} from "../runtime/assistant-commands";
|
|
37
37
|
import {
|
|
38
38
|
ASSISTANT_ACTIONS_KEY,
|
|
@@ -339,12 +339,10 @@ function registerDashboardEntries(
|
|
|
339
339
|
session: AssistantSession,
|
|
340
340
|
i18n: ChatI18n,
|
|
341
341
|
): () => void {
|
|
342
|
-
const
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
[i18n.locale, session.launcherState],
|
|
347
|
-
register,
|
|
342
|
+
const stopWatchingLauncher = registerLauncher(
|
|
343
|
+
i18n.t,
|
|
344
|
+
session.launcherState,
|
|
345
|
+
registerHeaderAction,
|
|
348
346
|
);
|
|
349
347
|
registerCommandPaletteSource(
|
|
350
348
|
paletteSource(i18n.t, session.pendingApprovals, {
|
|
@@ -524,6 +522,7 @@ function wireAssistant(
|
|
|
524
522
|
): () => void {
|
|
525
523
|
const { context, appMounted, provided } = options;
|
|
526
524
|
const { session } = runtime;
|
|
525
|
+
const { user } = useDmsUserSession<{ _id: string }>();
|
|
527
526
|
provided.session.value = session;
|
|
528
527
|
const stops = [
|
|
529
528
|
registerOnceMounted(context, appMounted, session, provided.i18n),
|
|
@@ -533,6 +532,7 @@ function wireAssistant(
|
|
|
533
532
|
router: options.router,
|
|
534
533
|
provided: provided.onboarding,
|
|
535
534
|
canConnectDatabase: options.features.builderEnabled,
|
|
535
|
+
userId: () => user.value?._id ?? null,
|
|
536
536
|
appMounted,
|
|
537
537
|
runWithContext: (callback) => context.runWithContext(callback),
|
|
538
538
|
}),
|
|
@@ -587,7 +587,7 @@ async function startAssistant(
|
|
|
587
587
|
|
|
588
588
|
/**
|
|
589
589
|
* The assistant appears for a signed-in owner in development only: a first
|
|
590
|
-
* probe that finds no dms-
|
|
590
|
+
* probe that finds no dms-assistant backend, or a disabled sidecar, leaves no trace.
|
|
591
591
|
* The session and the onboarding are provided at once, empty until that probe
|
|
592
592
|
* answers, so the panel the server rendered open and the workspace pages
|
|
593
593
|
* follow them, and another module's layer finds the public onboarding. A
|
|
@@ -5,7 +5,7 @@ import { assistantSidePanel } from "../runtime/assistant-commands";
|
|
|
5
5
|
* The panel's place in the dashboard, registered on the server as well: a
|
|
6
6
|
* panel left open renders docked at its width on the first paint, without the
|
|
7
7
|
* page jumping. The client plugin withdraws it where the assistant does not
|
|
8
|
-
* run (no dms-
|
|
8
|
+
* run (no dms-assistant backend, the sidecar disabled).
|
|
9
9
|
*/
|
|
10
10
|
export default defineDmsPlugin(() => {
|
|
11
11
|
if (!import.meta.env.DEV) return;
|
|
@@ -4,8 +4,8 @@ import type {
|
|
|
4
4
|
} from "./assistant-session";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* The assistant as another module's layer may use it, without depending on dms-
|
|
8
|
-
* {@link ASSISTANT_ACTIONS_KEY} with a `null` default, which is what a project without dms-
|
|
7
|
+
* The assistant as another module's layer may use it, without depending on dms-assistant: injected under
|
|
8
|
+
* {@link ASSISTANT_ACTIONS_KEY} with a `null` default, which is what a project without dms-assistant, or
|
|
9
9
|
* outside development, answers.
|
|
10
10
|
*/
|
|
11
11
|
export interface PublicAssistantActions {
|
|
@@ -25,9 +25,11 @@ export interface PublicAssistantActions {
|
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* The global key of {@link PublicAssistantActions}: `Symbol.for` resolves to the same symbol in
|
|
28
|
-
* every layer, so another module's layer injects it without importing dms-
|
|
28
|
+
* every layer, so another module's layer injects it without importing dms-assistant.
|
|
29
29
|
*/
|
|
30
|
-
export const ASSISTANT_ACTIONS_KEY = Symbol.for(
|
|
30
|
+
export const ASSISTANT_ACTIONS_KEY = Symbol.for(
|
|
31
|
+
"dms-assistant:assistant-actions",
|
|
32
|
+
);
|
|
31
33
|
|
|
32
34
|
/** The public actions over the tab's assistant session, which may not run yet, or ever. */
|
|
33
35
|
export function publicAssistantActions(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Ref, type WatchStopHandle, watch } from "vue";
|
|
2
2
|
import type { Translate } from "../chat/composables/useChatI18n";
|
|
3
3
|
import type { CurrentPage } from "../chat/types/conversation";
|
|
4
4
|
import { shortcutLabel } from "../chat/utils/platform";
|
|
@@ -110,11 +110,11 @@ export function assistantSidePanel(): AssistantSidePanel {
|
|
|
110
110
|
|
|
111
111
|
/** What each state adds to the launcher's label; a connected assistant adds nothing. */
|
|
112
112
|
const LAUNCHER_STATE_LABEL_KEYS: Record<LauncherState, string | null> = {
|
|
113
|
-
disconnected: "
|
|
113
|
+
disconnected: "dms_assistant.panel.launcher_state.disconnected",
|
|
114
114
|
connected: null,
|
|
115
|
-
working: "
|
|
116
|
-
finished: "
|
|
117
|
-
question: "
|
|
115
|
+
working: "dms_assistant.panel.launcher_state.working",
|
|
116
|
+
finished: "dms_assistant.panel.launcher_state.finished",
|
|
117
|
+
question: "dms_assistant.panel.launcher_state.question",
|
|
118
118
|
};
|
|
119
119
|
|
|
120
120
|
/**
|
|
@@ -142,6 +142,21 @@ export function launcherAction(
|
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
+
/**
|
|
146
|
+
* Registers the launcher now and again whenever its label changes: with the
|
|
147
|
+
* state, the locale, or the messages of a locale that load after the app
|
|
148
|
+
* mounted, which `t` reads reactively.
|
|
149
|
+
*/
|
|
150
|
+
export function registerLauncher(
|
|
151
|
+
t: Translate,
|
|
152
|
+
state: Readonly<Ref<LauncherState>>,
|
|
153
|
+
register: (action: LauncherAction) => void,
|
|
154
|
+
): WatchStopHandle {
|
|
155
|
+
return watch(() => launcherAction(t, state.value), register, {
|
|
156
|
+
immediate: true,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
145
160
|
/** The palette answers read-only: what it can answer in place comes first. */
|
|
146
161
|
function byReadOnlyFirst(
|
|
147
162
|
suggestions: readonly PageSuggestion[],
|
|
@@ -154,7 +169,7 @@ function byReadOnlyFirst(
|
|
|
154
169
|
/**
|
|
155
170
|
* The palette's assistant mode (Tab in ⌘K): first prompts that fit the page on
|
|
156
171
|
* screen, as the panel's empty chat offers them, and an answer drawn by
|
|
157
|
-
* `
|
|
172
|
+
* `DmsAssistantPaletteAnswer`.
|
|
158
173
|
*/
|
|
159
174
|
export function paletteAssistant(
|
|
160
175
|
t: Translate,
|
|
@@ -192,29 +207,29 @@ export function paletteSource(
|
|
|
192
207
|
groups: () => [
|
|
193
208
|
{
|
|
194
209
|
id: `${COMMAND_PALETTE_SOURCE_ID}-assistant`,
|
|
195
|
-
label: t("
|
|
210
|
+
label: t("dms_assistant.panel.palette.group"),
|
|
196
211
|
items: [
|
|
197
212
|
{
|
|
198
|
-
id: "dms-
|
|
199
|
-
label: t("
|
|
213
|
+
id: "dms-assistant-ask",
|
|
214
|
+
label: t("dms_assistant.panel.palette.ask"),
|
|
200
215
|
icon: "i-ph-sparkle",
|
|
201
216
|
suffix: shortcutLabel(TOGGLE_SHORTCUT_KEY, true),
|
|
202
217
|
onSelect: actions.ask,
|
|
203
218
|
},
|
|
204
219
|
{
|
|
205
|
-
id: "dms-
|
|
206
|
-
label: t("
|
|
220
|
+
id: "dms-assistant-new",
|
|
221
|
+
label: t("dms_assistant.panel.palette.new"),
|
|
207
222
|
icon: "i-ph-note-pencil",
|
|
208
223
|
onSelect: actions.startConversation,
|
|
209
224
|
},
|
|
210
225
|
{
|
|
211
|
-
id: "dms-
|
|
212
|
-
label: t("
|
|
226
|
+
id: "dms-assistant-approvals",
|
|
227
|
+
label: t("dms_assistant.panel.palette.approvals"),
|
|
213
228
|
icon: "i-ph-hand-palm",
|
|
214
229
|
suffix:
|
|
215
230
|
pendingApprovals.value > 0
|
|
216
231
|
? t(
|
|
217
|
-
"
|
|
232
|
+
"dms_assistant.panel.palette.waiting",
|
|
218
233
|
{ count: pendingApprovals.value },
|
|
219
234
|
pendingApprovals.value,
|
|
220
235
|
)
|
|
@@ -222,8 +237,8 @@ export function paletteSource(
|
|
|
222
237
|
onSelect: actions.reviewApprovals,
|
|
223
238
|
},
|
|
224
239
|
{
|
|
225
|
-
id: "dms-
|
|
226
|
-
label: t("
|
|
240
|
+
id: "dms-assistant-changes",
|
|
241
|
+
label: t("dms_assistant.panel.palette.changes"),
|
|
227
242
|
icon: "i-ph-git-diff",
|
|
228
243
|
onSelect: actions.openChanges,
|
|
229
244
|
},
|
|
@@ -72,18 +72,22 @@ function approvalToast(
|
|
|
72
72
|
state.announcedApprovals = count;
|
|
73
73
|
toast({
|
|
74
74
|
title,
|
|
75
|
-
description: t(
|
|
75
|
+
description: t(
|
|
76
|
+
"dms_assistant.panel.toast.approvals_waiting",
|
|
77
|
+
{ count },
|
|
78
|
+
count,
|
|
79
|
+
),
|
|
76
80
|
icon: ICON,
|
|
77
81
|
color: "secondary",
|
|
78
82
|
duration: TOAST_DURATION_MS,
|
|
79
83
|
actions: [
|
|
80
84
|
{
|
|
81
|
-
label: t("
|
|
85
|
+
label: t("dms_assistant.panel.toast.review"),
|
|
82
86
|
color: "secondary",
|
|
83
87
|
onClick: () => reviewApprovals(conversationId),
|
|
84
88
|
},
|
|
85
89
|
{
|
|
86
|
-
label: t("
|
|
90
|
+
label: t("dms_assistant.panel.toast.later"),
|
|
87
91
|
color: "neutral",
|
|
88
92
|
variant: "outline",
|
|
89
93
|
onClick: () => undefined,
|
|
@@ -98,8 +102,10 @@ function onPermissionRequest(
|
|
|
98
102
|
): void {
|
|
99
103
|
if (state.options.isPanelOpen.value || !state.isEnabled) return;
|
|
100
104
|
const title = frame.summary
|
|
101
|
-
? t(state, "
|
|
102
|
-
|
|
105
|
+
? t(state, "dms_assistant.panel.toast.request_title", {
|
|
106
|
+
summary: frame.summary,
|
|
107
|
+
})
|
|
108
|
+
: t(state, "dms_assistant.panel.toast.request_generic");
|
|
103
109
|
approvalToast(state, title, frame.conversationId);
|
|
104
110
|
}
|
|
105
111
|
|
|
@@ -118,20 +124,22 @@ function onChangeSet(state: NotifierState, frame: ChangeSetFrame): void {
|
|
|
118
124
|
if (set.state !== "applied" || state.options.isPanelOpen.value) return;
|
|
119
125
|
const { toast, undoChangeSet, reviewChangeSet } = state.options;
|
|
120
126
|
toast({
|
|
121
|
-
title: t(state, "
|
|
127
|
+
title: t(state, "dms_assistant.panel.toast.applied", {
|
|
128
|
+
number: set.number,
|
|
129
|
+
}),
|
|
122
130
|
description: set.title,
|
|
123
131
|
icon: ICON,
|
|
124
132
|
color: "secondary",
|
|
125
133
|
duration: TOAST_DURATION_MS,
|
|
126
134
|
actions: [
|
|
127
135
|
{
|
|
128
|
-
label: t(state, "
|
|
136
|
+
label: t(state, "dms_assistant.panel.change.undo"),
|
|
129
137
|
color: "neutral",
|
|
130
138
|
variant: "outline",
|
|
131
139
|
onClick: () => undoChangeSet(set),
|
|
132
140
|
},
|
|
133
141
|
{
|
|
134
|
-
label: t(state, "
|
|
142
|
+
label: t(state, "dms_assistant.panel.change.review"),
|
|
135
143
|
color: "secondary",
|
|
136
144
|
onClick: () => reviewChangeSet(set.id),
|
|
137
145
|
},
|
|
@@ -172,7 +180,7 @@ export function installAssistantNotifications(
|
|
|
172
180
|
const isNew = count > state.announcedApprovals;
|
|
173
181
|
if (!isNew) state.announcedApprovals = count;
|
|
174
182
|
if (!isNew || options.isPanelOpen.value || !state.isEnabled) return;
|
|
175
|
-
approvalToast(state, t(state, "
|
|
183
|
+
approvalToast(state, t(state, "dms_assistant.panel.toast.request_generic"));
|
|
176
184
|
});
|
|
177
185
|
return () => {
|
|
178
186
|
stopListening();
|
|
@@ -73,5 +73,5 @@ export interface AssistantSession {
|
|
|
73
73
|
export type AssistantSessionRef = Readonly<ShallowRef<AssistantSession | null>>;
|
|
74
74
|
|
|
75
75
|
export const ASSISTANT_SESSION_KEY: InjectionKey<AssistantSessionRef> = Symbol(
|
|
76
|
-
"dms-
|
|
76
|
+
"dms-assistant:assistant-session",
|
|
77
77
|
);
|
|
@@ -222,7 +222,7 @@ function reconnectNow(state: ClientState): void {
|
|
|
222
222
|
* and the chat's frames alike, and sequential POSTs to send. Browsers keep at
|
|
223
223
|
* most six HTTP/1.1 connections per origin, so a tab holds one such stream and
|
|
224
224
|
* only while it needs it: the caller starts and stops it. While started, any
|
|
225
|
-
* end of the stream — a sidecar that went down, a hot reload of dms-
|
|
225
|
+
* end of the stream — a sidecar that went down, a hot reload of dms-assistant, a
|
|
226
226
|
* network drop — reconnects with backoff, and each new connection is announced
|
|
227
227
|
* through `onReady` so the caller identifies itself again.
|
|
228
228
|
*/
|