@dsmm/dsmm 0.3.13 → 0.3.15
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 +77 -36
- package/docs/agent-presets.md +1 -1
- package/docs/compatibility.md +2 -2
- package/docs/deferred-native-approval-risk.md +4 -4
- package/docs/design.md +1 -1
- package/docs/lsp.md +1 -1
- package/docs/model-routing.md +1 -1
- package/docs/native-permissions.md +12 -2
- package/docs/profiles.md +14 -5
- package/docs/roadmap.md +67 -30
- package/docs/runtime-recovery.md +1 -1
- package/docs/safety-guards.md +1 -1
- package/docs/settings-status.md +1 -1
- package/lib/client/DeploymentFields.js +3 -1
- package/lib/client/DeploymentPage.js +34 -2
- package/lib/client/EditableChoice.js +5 -2
- package/lib/client/PermissionsPanel.js +1 -1
- package/lib/client/ProfileModelsDialog.d.ts +4 -2
- package/lib/client/ProfileModelsDialog.js +46 -7
- package/lib/client/ProfilesSection.js +47 -17
- package/lib/client/RoleToolView-locales.d.ts +1 -1
- package/lib/client/RoleToolView-locales.js +2 -2
- package/lib/client/SessionProfiles.js +24 -6
- package/lib/client/children-locales.d.ts +1 -1
- package/lib/client/controller.d.ts +23 -1
- package/lib/client/controller.js +289 -8
- package/lib/client/deployment-locales.d.ts +2 -0
- package/lib/client/deployment-locales.js +3 -1
- package/lib/client/index.js +10 -2
- package/lib/client/locales.d.ts +8 -0
- package/lib/client/locales.js +16 -6
- package/lib/client/profile-blank.d.ts +43 -0
- package/lib/client/profile-blank.js +19 -0
- package/lib/client/session-labels.d.ts +1 -0
- package/lib/client/session-labels.js +3 -0
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.js +27 -12
- package/lib/client.js +714 -234
- package/lib/command-approval.d.ts +2 -0
- package/lib/command-approval.js +4 -1
- package/lib/index.js +2 -1
- package/lib/native-admission.d.ts +10 -3
- package/lib/native-admission.js +129 -28
- package/lib/profile-runtime.js +3 -5
- package/package.json +1 -1
|
@@ -31,7 +31,7 @@ function menuIssue(issue) {
|
|
|
31
31
|
export function SessionScopeFeedback({ state, t }) {
|
|
32
32
|
const session = state.session;
|
|
33
33
|
const status = state.sessionNotice === null ? "" : t(state.sessionNotice === "mode-on" ? "headerModeOn" : state.sessionNotice === "mode-off" ? "headerModeOff" : state.sessionNotice === "applied-with-model" ? "sessionAppliedWithModel" : state.sessionNotice === "applied" ? "sessionApplied" : "sessionResetDone");
|
|
34
|
-
return _jsxs("div", { "data-dsmm-session-feedback": true, children: [session?.warnings?.length ? _jsxs("div", { children: [_jsx("p", { children: t("admissionWarnings") }), _jsx(ProfileWarnings, { warnings: session.warnings, t: t })] }) : null, state.dirty && _jsx("p", { className: "dsmm-hint", children: t("sessionDirty") }), (session?.refreshRequired || session?.selection.refreshRequired) && _jsx("p", { role: "status", children: t("sessionCommittedRefresh") }), state.sessionUnconfirmed && _jsx("p", { role: "status", children: t("sessionUnconfirmedRefresh") }), state.sessionIssue !== null && _jsxs(_Fragment, { children: [_jsx("p", { role: "alert", children: state.sessionIssue.source === "profile-model" ? t(state.sessionIssue.code === "model-unconfigured" ? "headerNoProfileModel" : state.sessionIssue.code === "model-choice-changed" ? "headerModelChoiceChanged" : "headerModelUnconfirmed")
|
|
34
|
+
return _jsxs("div", { "data-dsmm-session-feedback": true, children: [session?.warnings?.length ? _jsxs("div", { children: [_jsx("p", { children: t("admissionWarnings") }), _jsx(ProfileWarnings, { warnings: session.warnings, t: t })] }) : null, state.dirty && _jsx("p", { className: "dsmm-hint", children: t("sessionDirty") }), (session?.refreshRequired || session?.selection.refreshRequired) && _jsx("p", { role: "status", children: t("sessionCommittedRefresh") }), state.sessionUnconfirmed && _jsx("p", { role: "status", children: t(state.sessionIssue?.code === "blank-identity-unconfirmed" ? "sessionPreparationUnknown" : "sessionUnconfirmedRefresh") }), state.sessionIssue !== null && _jsxs(_Fragment, { children: [_jsx("p", { role: "alert", children: state.sessionIssue.source === "profile-model" ? t(state.sessionIssue.code === "model-unconfigured" ? "headerNoProfileModel" : state.sessionIssue.code === "model-choice-changed" ? "headerModelChoiceChanged" : "headerModelUnconfirmed")
|
|
35
35
|
: state.sessionIssue.code === "conflict" ? t("sessionConflict")
|
|
36
36
|
: ["busy", "maintenance", "disposed", "not-owned"].includes(state.sessionIssue.code) ? t("sessionBusy", { reason: state.sessionIssue.code })
|
|
37
37
|
: t(state.sessionIssue.code === "validation" ? "validation" : "sessionUnavailable") }), _jsx(IssueDetails, { issue: state.sessionIssue, t: t })] }), _jsx("p", { className: "dsmm-status", role: "status", "aria-live": "polite", "aria-atomic": "true", children: state.sessionBusy === "read" ? t("reading") : status })] });
|
|
@@ -54,7 +54,11 @@ export function SessionScope({ state, actions, t, compact = false, showFeedback
|
|
|
54
54
|
catch {
|
|
55
55
|
binding = undefined;
|
|
56
56
|
}
|
|
57
|
-
return _jsxs("div", { className: "dsmm-session-scope", "aria-busy": state.sessionBusy !== null, "data-dsmm-session-scope": true, children: [!compact && _jsx("h3", { children: t("sessionScope") }), state.currentSessionId === null ?
|
|
57
|
+
return _jsxs("div", { className: "dsmm-session-scope", "aria-busy": state.sessionBusy !== null, "data-dsmm-session-scope": true, children: [!compact && _jsx("h3", { children: t("sessionScope") }), state.currentSessionId === null ? _jsxs(_Fragment, { children: [_jsx("p", { className: "dsmm-hint", children: t(state.sessionPreparationAvailable ? "sessionChooseWorkspace" : "sessionPreparationUnavailable") }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-workspace`, children: t("sessionWorkspace") }), _jsxs("select", { id: `${prefix}-workspace`, value: state.sessionWorkspaceId ?? "", disabled: !state.sessionPreparationAvailable || disabled, onChange: event => { if (current())
|
|
58
|
+
void actions.chooseSessionWorkspace(event.currentTarget.value); }, children: [_jsx("option", { value: "", children: t("sessionWorkspacePlaceholder") }), state.sessionWorkspaces.map(workspace => _jsx("option", { value: workspace.id, children: workspace.label }, workspace.id))] })] }), state.sessionWorkspaces.length === 0 && _jsx("p", { className: "dsmm-hint", children: t("sessionNoWorkspaces") }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-choice`, children: t("sessionSelect") }), _jsxs("select", { id: `${prefix}-choice`, value: state.sessionChoice ?? "", disabled: !state.sessionPreparationAvailable || disabled || state.sessionUnconfirmed, onChange: event => { if (current())
|
|
59
|
+
actions.chooseSessionProfile(event.currentTarget.value || null); }, children: [_jsx("option", { value: "", children: t("sessionBaseline") }), state.snapshot?.profiles.map(profile => _jsx("option", { value: profile.id, disabled: !isConfigRevision(profile.revision) || profile.error !== undefined, children: profile.label?.trim() || profile.id }, profile.id))] })] }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", disabled: !state.sessionPreparationAvailable || disabled || state.sessionUnconfirmed || state.snapshot === null, onClick: () => { if (current())
|
|
60
|
+
void actions.applySession(); }, children: t("sessionPrepare") }), _jsx(Button, { type: "button", variant: "outline", disabled: state.sessionBusy !== null || state.busy !== null || state.pendingEditor !== null, onClick: () => { if (current())
|
|
61
|
+
void actions.refreshSession(); }, children: t("sessionRefresh") })] })] }) : _jsxs(_Fragment, { children: [labels !== null && _jsx("p", { "data-dsmm-session-state": true, children: labels.admitted }), labels !== null && !compact && _jsx("p", { className: "dsmm-hint", "data-dsmm-session-future-default": true, children: labels.futureDefault }), session === null && _jsx("p", { className: "dsmm-hint", id: `${prefix}-overlay-reason`, children: t("sessionUnavailable") }), session !== null && !allowed && _jsx("p", { className: "dsmm-hint", id: `${prefix}-overlay-reason`, children: capabilityReason(session.applyOverlayUnavailableReason, t) }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-choice`, children: t("sessionSelect") }), _jsxs("select", { id: `${prefix}-choice`, value: state.sessionChoice ?? "", disabled: disabled || !allowed, "aria-describedby": !allowed ? `${prefix}-overlay-reason` : undefined, onChange: (event) => { if (current())
|
|
58
62
|
actions.chooseSessionProfile(event.currentTarget.value || null); }, children: [_jsx("option", { value: "", children: t("sessionBaseline") }), state.sessionChoice !== null && selected === undefined && _jsx("option", { value: state.sessionChoice, children: state.sessionChoice }), state.snapshot?.profiles.map((profile) => _jsxs("option", { value: profile.id, disabled: !isConfigRevision(profile.revision) || profile.error !== undefined, children: [profile.label?.trim() || profile.id, profileWarnings(profile.warnings).length ? ` — ${t("warningProfile")}` : ""] }, profile.id))] })] }), !compact && _jsxs(_Fragment, { children: [_jsx("p", { className: "dsmm-hint", id: `${prefix}-model-hint`, children: t("useSessionProfileModelDesc") }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled || !modelAllowed, "aria-describedby": `${prefix}-model-hint${!modelAllowed ? ` ${prefix}-model-reason` : ""}`, onClick: () => { if (current())
|
|
59
63
|
void actions.useSessionProfileModel(); }, children: t("headerUseCurrentModel") }), !modelAllowed && _jsx("p", { className: "dsmm-hint", id: `${prefix}-model-reason`, children: capabilityReason(session?.selectModelUnavailableReason, t) }), session !== null && _jsxs("details", { children: [_jsx("summary", { children: t("technicalDetails") }), _jsxs("div", { className: "dsmm-availability", children: [_jsx("p", { children: binding === undefined ? t("bindingUnknown") : t("bindingState", { binding: binding.binding, ready: t(binding.deliveryFenceReady ? "enabled" : "disabled"), restart: t(binding.restartRequired ? "enabled" : "disabled") }) }), binding?.reason !== undefined && _jsx("p", { children: t("bindingReason", { reason: binding.reason }) })] }), session.roles !== undefined && _jsxs("details", { children: [_jsx("summary", { children: t("admittedRoles") }), session.roles.map(role => _jsxs("div", { className: "dsmm-availability", children: [_jsx("p", { children: role.id }), _jsx(RoleAvailability, { value: role, t: t })] }, role.id))] }), session.rolePolicy !== undefined && _jsx("p", { "data-dsmm-session-policy": true, children: t("roleState", { route: session.rolePolicy.route === undefined ? t("inheritRoute") : `${session.rolePolicy.route.provider}/${session.rolePolicy.route.model}${session.rolePolicy.route.reasoningEffort === undefined ? "" : ` (${session.rolePolicy.route.reasoningEffort})`}`, strategy: session.rolePolicy.strategy, retries: session.rolePolicy.retries, failures: session.rolePolicy.rateLimitFailures, switches: session.rolePolicy.switches, delay: session.rolePolicy.totalDelayMs }) })] })] }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", disabled: disabled || !allowed || (state.sessionChoice !== null && !isConfigRevision(selected?.revision)), "aria-describedby": !allowed ? `${prefix}-overlay-reason` : undefined, onClick: () => { if (current())
|
|
60
64
|
void actions.applySession(); }, children: t(state.sessionBusy === "apply" ? "sessionApplying" : "sessionApply") }), !compact && _jsx(Button, { type: "button", variant: "outline", disabled: disabled || !allowed, "aria-describedby": !allowed ? `${prefix}-overlay-reason` : undefined, onClick: () => { if (current())
|
|
@@ -81,10 +85,11 @@ export function SessionProfiles(props) {
|
|
|
81
85
|
const unavailable = id === null || committing || state.busy !== null || state.sessionUnconfirmed || session === null || session.refreshRequired === true || session.selection.refreshRequired === true;
|
|
82
86
|
const profileDisabled = unavailable || state.pendingEditor !== null || state.dirty || state.invalidFields.length > 0
|
|
83
87
|
|| session === null || !writableSelectionVersion(session.selection.selectionRevision);
|
|
84
|
-
const
|
|
88
|
+
const sessionlessDisabled = !state.sessionPreparationAvailable || committing || state.busy !== null || state.sessionUnconfirmed || state.pendingEditor !== null || state.dirty || state.invalidFields.length > 0 || state.snapshot === null;
|
|
89
|
+
const disabled = id === null ? sessionlessDisabled : profileDisabled || session?.canApplyOverlay !== true || session?.applyOverlayUnavailableReason === "new-session-required" || state.snapshot === null;
|
|
85
90
|
let feedback = "";
|
|
86
91
|
if (state.sessionUnconfirmed)
|
|
87
|
-
feedback = t("sessionUnconfirmedRefresh");
|
|
92
|
+
feedback = t(state.sessionIssue?.code === "blank-identity-unconfirmed" ? "sessionPreparationUnknown" : "sessionUnconfirmedRefresh");
|
|
88
93
|
else if (session?.refreshRequired || session?.selection.refreshRequired)
|
|
89
94
|
feedback = t("sessionCommittedRefresh");
|
|
90
95
|
else if (state.sessionIssue !== null)
|
|
@@ -97,7 +102,7 @@ export function SessionProfiles(props) {
|
|
|
97
102
|
else if (state.dirty || state.invalidFields.length > 0 || state.pendingEditor !== null)
|
|
98
103
|
feedback = t("headerDraft");
|
|
99
104
|
else if (id === null)
|
|
100
|
-
feedback = t("sessionChooseWorkspace");
|
|
105
|
+
feedback = t(!state.sessionPreparationAvailable ? "sessionPreparationUnavailable" : state.sessionWorkspaceId === null ? "sessionChooseWorkspace" : "sessionPrepareHint");
|
|
101
106
|
else if (session === null || state.snapshot === null)
|
|
102
107
|
feedback = t("headerUnavailable");
|
|
103
108
|
else if (state.sessionNotice !== null)
|
|
@@ -125,6 +130,13 @@ export function SessionProfiles(props) {
|
|
|
125
130
|
entries.push({ id: admission.selectedId, label: `${admission.selectedId} — ${t("headerSavedUnavailable")}`, disabled: true });
|
|
126
131
|
if (unknownCaptured)
|
|
127
132
|
entries.push({ id: "__dsmm_captured_default__", label: t("headerCaptured"), disabled: true });
|
|
133
|
+
if (id === null) {
|
|
134
|
+
entries.push({ type: "separator", id: "@workspace-separator" }, { type: "label", id: "@workspace-heading", text: state.sessionPreparationPending ? t("sessionPendingProfile", { profile: profiles.find(profile => profile.id === state.sessionChoice)?.label?.trim() || state.sessionChoice || t("sessionBaseline") }) : t("sessionWorkspace") });
|
|
135
|
+
for (const workspace of state.sessionWorkspaces)
|
|
136
|
+
entries.push({ id: `@workspace:${workspace.id}`, label: `${workspace.id === state.sessionWorkspaceId ? "✓ " : ""}${workspace.label}`, disabled: !state.sessionPreparationAvailable || state.dirty || state.invalidFields.length > 0 || state.pendingEditor !== null || state.busy !== null });
|
|
137
|
+
if (state.sessionWorkspaces.length === 0)
|
|
138
|
+
entries.push({ type: "label", id: "@no-workspaces", text: t("sessionNoWorkspaces") });
|
|
139
|
+
}
|
|
128
140
|
entries.push({ type: "separator", id: "@keep-separator" }, { type: "label", id: "@keep-heading", text: t("headerCompactProfiles") }, { id: "", label: t("sessionBaseline"), disabled });
|
|
129
141
|
if (session !== null && (session.canApplyOverlay !== true || session.applyOverlayUnavailableReason === "new-session-required"))
|
|
130
142
|
entries.push({ type: "label", id: "@overlay-reason", text: capabilityReason(session.applyOverlayUnavailableReason, t) });
|
|
@@ -141,13 +153,17 @@ export function SessionProfiles(props) {
|
|
|
141
153
|
if (value === "@refresh") {
|
|
142
154
|
if (committing || state.busy !== null)
|
|
143
155
|
return;
|
|
144
|
-
void (async () => { await props.refresh(); if (
|
|
156
|
+
void (async () => { await props.refresh(); if (props.readProfileView().currentSessionId === id && props.readProfileView().sessionViewEpoch === state.sessionViewEpoch)
|
|
145
157
|
await props.refreshSession(); })();
|
|
146
158
|
}
|
|
147
159
|
else {
|
|
148
160
|
const row = entries.find((entry) => entry.id === value && !("type" in entry));
|
|
149
161
|
if (row === undefined || !("disabled" in row) || row.disabled)
|
|
150
162
|
return;
|
|
163
|
+
if (value.startsWith("@workspace:")) {
|
|
164
|
+
void props.chooseSessionWorkspace(value.slice("@workspace:".length));
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
151
167
|
if (value === "@mode") {
|
|
152
168
|
if (mode !== undefined)
|
|
153
169
|
void props.setDeepwork(!mode.active);
|
|
@@ -157,6 +173,8 @@ export function SessionProfiles(props) {
|
|
|
157
173
|
else {
|
|
158
174
|
props.chooseSessionProfile(value || null);
|
|
159
175
|
void props.applySession();
|
|
176
|
+
if (id === null && state.sessionWorkspaceId === null)
|
|
177
|
+
return;
|
|
160
178
|
}
|
|
161
179
|
}
|
|
162
180
|
setOpenFor(undefined);
|
|
@@ -2,13 +2,14 @@ import type { RemoteResult } from "@deepseek-ai/dsh-typert-protocol";
|
|
|
2
2
|
import type { HostObservable } from "@deepseek-ai/dsh-client-ui-slots";
|
|
3
3
|
import type { ConnectionGenerationState } from "@deepseek-ai/dsh-client-connection/client";
|
|
4
4
|
import type { ComposerBlocks } from "@deepseek-ai/dsh-client-ui-conversation/client";
|
|
5
|
-
import type { SessionEventSource } from "@deepseek-ai/dsh-api-session-controller/client";
|
|
5
|
+
import type { SessionEventSource, SessionSnapshot } from "@deepseek-ai/dsh-api-session-controller/client";
|
|
6
6
|
import type { ModelDirectoryState } from "@deepseek-ai/dsh-client-ui-model-selection/client";
|
|
7
7
|
import type { DsmmProfilesRemote } from "../profile-remote.js";
|
|
8
8
|
import type { ProfileDiagnostic, ProfileDiagnosticCode, ProfileDiagnosticLocation, ProfileErrorInfo, ProfileReadResult, ProfileSnapshot } from "../profile-types.js";
|
|
9
9
|
import type { SessionProfileSnapshot } from "../profile-types.js";
|
|
10
10
|
import type { ModelCatalog, SessionSelectModelRequest, SessionSelectModelValue } from "@deepseek-ai/dsh-api-session-controller";
|
|
11
11
|
import type { JsonPath } from "./structured.js";
|
|
12
|
+
import type { ProfileBlankNative, ProfileWorkspace } from "./profile-blank.js";
|
|
12
13
|
export interface ProfileEditor {
|
|
13
14
|
id: string;
|
|
14
15
|
content: string;
|
|
@@ -48,6 +49,10 @@ export interface ProfilesViewSnapshot {
|
|
|
48
49
|
sessionUnconfirmed: boolean;
|
|
49
50
|
session: SessionProfileSnapshot | null;
|
|
50
51
|
sessionChoice: string | null;
|
|
52
|
+
sessionWorkspaces: readonly ProfileWorkspace[];
|
|
53
|
+
sessionWorkspaceId: string | null;
|
|
54
|
+
sessionPreparationAvailable: boolean;
|
|
55
|
+
sessionPreparationPending: boolean;
|
|
51
56
|
sessionBusy: "read" | "apply" | "reset" | "mode" | null;
|
|
52
57
|
sessionIssue: ProfilesIssue | null;
|
|
53
58
|
sessionNotice: "applied" | "reset" | "applied-with-model" | "mode-on" | "mode-off" | null;
|
|
@@ -75,6 +80,7 @@ export interface ProfilesActions {
|
|
|
75
80
|
refreshCatalog(): Promise<void>;
|
|
76
81
|
refreshSession(): Promise<void>;
|
|
77
82
|
chooseSessionProfile(id: string | null): void;
|
|
83
|
+
chooseSessionWorkspace(id: string): Promise<void>;
|
|
78
84
|
applySession(options?: SessionApplyOptions): Promise<void>;
|
|
79
85
|
resetSession(): Promise<void>;
|
|
80
86
|
setDeepwork(active: boolean): Promise<void>;
|
|
@@ -107,6 +113,9 @@ export declare class ProfilesController {
|
|
|
107
113
|
private generation;
|
|
108
114
|
private disposed;
|
|
109
115
|
private sessionGeneration;
|
|
116
|
+
private blankNative;
|
|
117
|
+
private stopWorkspaces;
|
|
118
|
+
private preparation;
|
|
110
119
|
private pendingSessionSelections;
|
|
111
120
|
private connection;
|
|
112
121
|
private connectionBaseline;
|
|
@@ -129,6 +138,9 @@ export declare class ProfilesController {
|
|
|
129
138
|
private modelEventsWatermark;
|
|
130
139
|
private modeEventsWatermark;
|
|
131
140
|
private modeRefreshPending;
|
|
141
|
+
private sessionSource;
|
|
142
|
+
private sessionSourceId;
|
|
143
|
+
private stopSessionSource;
|
|
132
144
|
private stopModelEvents;
|
|
133
145
|
private modelInteraction;
|
|
134
146
|
private modelInteractionSessionId;
|
|
@@ -144,11 +156,21 @@ export declare class ProfilesController {
|
|
|
144
156
|
dispose(): void;
|
|
145
157
|
bindConnection(source: ConnectionGenerationState | null): void;
|
|
146
158
|
private connectionCurrent;
|
|
159
|
+
attachBlankNative(native: ProfileBlankNative | null): void;
|
|
160
|
+
private releasePreparation;
|
|
161
|
+
private cancelPreparation;
|
|
162
|
+
private chooseSessionWorkspace;
|
|
163
|
+
private preparationOwned;
|
|
164
|
+
private preparationCurrent;
|
|
165
|
+
private preparationConfirmed;
|
|
166
|
+
private openPrepared;
|
|
167
|
+
private prepareSession;
|
|
147
168
|
attachComposerBlocks(blocks: ComposerBlocks | null, reason?: () => string): void;
|
|
148
169
|
private releaseComposerBlock;
|
|
149
170
|
private syncComposerBlock;
|
|
150
171
|
attachModelSelector(remote: ProfileModelSelectorRemote | null): void;
|
|
151
172
|
attachModelSelectionSource(sessionId: string | null, source: HostObservable<unknown> | null): void;
|
|
173
|
+
attachSessionSource(sessionId: string | null, source: HostObservable<SessionSnapshot> | null): void;
|
|
152
174
|
attachModelEventSource(sessionId: string | null, source: SessionEventSource | null): void;
|
|
153
175
|
attachModelInteractionSource(sessionId: string | null, source: ModelInteractionSource | null): void;
|
|
154
176
|
attachCatalog(remote: ModelCatalogRemote | null): void;
|
package/lib/client/controller.js
CHANGED
|
@@ -28,12 +28,15 @@ export function canReconcileSelection(snapshot) {
|
|
|
28
28
|
export class ProfilesController {
|
|
29
29
|
remote;
|
|
30
30
|
current = { snapshot: null, editor: null, dirty: false, busy: null, issue: null, notice: null, pendingEditor: null,
|
|
31
|
-
catalog: null, catalogBusy: false, catalogUnavailable: true, currentSessionId: null, sessionViewEpoch: 0, sessionUnconfirmed: false, session: null, sessionChoice: null, sessionBusy: null, sessionIssue: null, sessionNotice: null, invalidFields: [], editorEpoch: 0, validationEpoch: 0 };
|
|
31
|
+
catalog: null, catalogBusy: false, catalogUnavailable: true, currentSessionId: null, sessionViewEpoch: 0, sessionUnconfirmed: false, session: null, sessionChoice: null, sessionWorkspaces: [], sessionWorkspaceId: null, sessionPreparationAvailable: false, sessionPreparationPending: false, sessionBusy: null, sessionIssue: null, sessionNotice: null, invalidFields: [], editorEpoch: 0, validationEpoch: 0 };
|
|
32
32
|
accepted = null;
|
|
33
33
|
listeners = new Set();
|
|
34
34
|
generation = 0;
|
|
35
35
|
disposed = false;
|
|
36
36
|
sessionGeneration = 0;
|
|
37
|
+
blankNative = null;
|
|
38
|
+
stopWorkspaces = null;
|
|
39
|
+
preparation = null;
|
|
37
40
|
pendingSessionSelections = new Set();
|
|
38
41
|
connection = null;
|
|
39
42
|
connectionBaseline;
|
|
@@ -56,6 +59,9 @@ export class ProfilesController {
|
|
|
56
59
|
modelEventsWatermark = -1;
|
|
57
60
|
modeEventsWatermark = -1;
|
|
58
61
|
modeRefreshPending = false;
|
|
62
|
+
sessionSource = null;
|
|
63
|
+
sessionSourceId = null;
|
|
64
|
+
stopSessionSource = null;
|
|
59
65
|
stopModelEvents = null;
|
|
60
66
|
modelInteraction = null;
|
|
61
67
|
modelInteractionSessionId = null;
|
|
@@ -80,6 +86,7 @@ export class ProfilesController {
|
|
|
80
86
|
refreshCatalog: () => this.refreshCatalog(), refreshSession: () => this.refreshSession(),
|
|
81
87
|
chooseSessionProfile: (id) => { if (!this.disposed && this.connectionCurrent() && !this.current.sessionUnconfirmed && this.current.sessionBusy === null && this.current.busy === null && !this.current.dirty && this.current.pendingEditor === null && this.current.invalidFields.length === 0)
|
|
82
88
|
this.publish({ sessionChoice: id, sessionNotice: null }); },
|
|
89
|
+
chooseSessionWorkspace: id => this.chooseSessionWorkspace(id),
|
|
83
90
|
applySession: (options) => this.selectSession(false, options), resetSession: () => this.selectSession(true),
|
|
84
91
|
setDeepwork: (active) => this.setDeepwork(active), useSessionProfileModel: () => this.selectSession(false, { useProfileModel: true }, true),
|
|
85
92
|
setFieldInvalid: (field, invalid) => {
|
|
@@ -107,7 +114,7 @@ export class ProfilesController {
|
|
|
107
114
|
constructor(remote) {
|
|
108
115
|
this.remote = remote;
|
|
109
116
|
}
|
|
110
|
-
dispose() { this.releaseComposerBlock(); this.numberDrafts.clear(); this.stopConnection?.(); this.disposed = true; this.generation += 1; this.sessionGeneration += 1; this.catalogGeneration += 1; this.modelSelectorGeneration += 1; this.modelSelectionGeneration += 1; this.stopModelSelection?.(); this.stopModelEvents?.(); this.stopModelInteraction?.(); this.stopModelSelection = null; this.stopModelEvents = null; this.stopModelInteraction = null; this.modelSelectionSource = null; this.modelEvents = null; this.modelInteraction = null; this.catalogRemote = null; this.modelSelector = null; this.listeners.clear(); }
|
|
117
|
+
dispose() { this.releasePreparation(); this.stopWorkspaces?.(); this.releaseComposerBlock(); this.numberDrafts.clear(); this.stopConnection?.(); this.stopSessionSource?.(); this.sessionSource = null; this.disposed = true; this.generation += 1; this.sessionGeneration += 1; this.catalogGeneration += 1; this.modelSelectorGeneration += 1; this.modelSelectionGeneration += 1; this.stopModelSelection?.(); this.stopModelEvents?.(); this.stopModelInteraction?.(); this.stopModelSelection = null; this.stopModelEvents = null; this.stopModelInteraction = null; this.modelSelectionSource = null; this.modelEvents = null; this.modelInteraction = null; this.catalogRemote = null; this.modelSelector = null; this.listeners.clear(); }
|
|
111
118
|
bindConnection(source) {
|
|
112
119
|
if (this.disposed)
|
|
113
120
|
return;
|
|
@@ -117,15 +124,17 @@ export class ProfilesController {
|
|
|
117
124
|
this.connectionBound = true;
|
|
118
125
|
this.connectionBaseline = source?.getSnapshot();
|
|
119
126
|
const invalidate = () => {
|
|
127
|
+
this.releasePreparation();
|
|
120
128
|
this.connectionBaseline = source?.getSnapshot();
|
|
121
129
|
this.generation += 1;
|
|
122
130
|
this.sessionGeneration += 1;
|
|
131
|
+
this.modeRefreshPending = false;
|
|
123
132
|
this.modelSelectorGeneration += 1;
|
|
124
133
|
// A replaced connection only discards what it observed. It never records a
|
|
125
134
|
// durable refusal for the session: an unread configuration is read again
|
|
126
135
|
// by the next refresh, and typing stays available in the meantime.
|
|
127
136
|
this.publish({ session: null, sessionBusy: null, sessionNotice: null, sessionUnconfirmed: false,
|
|
128
|
-
sessionViewEpoch: this.current.sessionViewEpoch + 1, busy: null, issue: { kind: "transport", code: "unavailable" } });
|
|
137
|
+
sessionViewEpoch: this.current.sessionViewEpoch + 1, sessionWorkspaceId: null, sessionPreparationPending: false, busy: null, issue: { kind: "transport", code: "unavailable" } });
|
|
129
138
|
};
|
|
130
139
|
if (replacement || source === null || this.connectionBaseline === undefined)
|
|
131
140
|
invalidate();
|
|
@@ -140,13 +149,229 @@ export class ProfilesController {
|
|
|
140
149
|
connectionCurrent() {
|
|
141
150
|
return !this.connectionBound || this.connectionBaseline !== undefined && this.connection?.getSnapshot() === this.connectionBaseline;
|
|
142
151
|
}
|
|
152
|
+
attachBlankNative(native) {
|
|
153
|
+
if (this.disposed)
|
|
154
|
+
return;
|
|
155
|
+
this.cancelPreparation();
|
|
156
|
+
this.stopWorkspaces?.();
|
|
157
|
+
this.blankNative = native;
|
|
158
|
+
const update = () => {
|
|
159
|
+
const sessionWorkspaces = native?.workspaces.getSnapshot() ?? [];
|
|
160
|
+
const sessionWorkspaceId = sessionWorkspaces.some(item => item.id === this.current.sessionWorkspaceId) ? this.current.sessionWorkspaceId : null;
|
|
161
|
+
if (this.preparation !== null && sessionWorkspaceId !== this.preparation.workspaceId)
|
|
162
|
+
this.cancelPreparation();
|
|
163
|
+
this.publish({ sessionWorkspaces, sessionWorkspaceId, sessionPreparationAvailable: native !== null && this.composerBlocks !== null });
|
|
164
|
+
};
|
|
165
|
+
this.stopWorkspaces = native?.workspaces.subscribe(update) ?? null;
|
|
166
|
+
update();
|
|
167
|
+
}
|
|
168
|
+
releasePreparation() {
|
|
169
|
+
const task = this.preparation;
|
|
170
|
+
this.preparation = null;
|
|
171
|
+
if (task === null)
|
|
172
|
+
return;
|
|
173
|
+
task.stop();
|
|
174
|
+
const held = task.held;
|
|
175
|
+
if (held !== null && task.id !== null && held.blocks.storeFor(task.id) === held.store && held.store.getSnapshot() === held.block)
|
|
176
|
+
held.blocks.set(task.id, undefined);
|
|
177
|
+
task.reference?.release();
|
|
178
|
+
}
|
|
179
|
+
cancelPreparation() {
|
|
180
|
+
if (this.preparation === null)
|
|
181
|
+
return;
|
|
182
|
+
this.releasePreparation();
|
|
183
|
+
this.sessionGeneration += 1;
|
|
184
|
+
this.publish({ sessionBusy: null, sessionUnconfirmed: false, sessionPreparationPending: false, sessionNotice: null });
|
|
185
|
+
}
|
|
186
|
+
async chooseSessionWorkspace(id) {
|
|
187
|
+
if (this.disposed || !this.connectionCurrent() || this.current.currentSessionId !== null || !this.current.sessionWorkspaces.some(item => item.id === id)
|
|
188
|
+
|| this.current.dirty || this.current.invalidFields.length > 0 || this.current.pendingEditor !== null || this.current.busy !== null)
|
|
189
|
+
return;
|
|
190
|
+
const pending = this.current.sessionPreparationPending;
|
|
191
|
+
if (id !== this.current.sessionWorkspaceId)
|
|
192
|
+
this.cancelPreparation();
|
|
193
|
+
this.publish({ sessionWorkspaceId: id, sessionIssue: null });
|
|
194
|
+
if (pending)
|
|
195
|
+
await this.prepareSession();
|
|
196
|
+
}
|
|
197
|
+
preparationOwned(task) {
|
|
198
|
+
return !this.disposed && this.connectionCurrent() && this.preparation === task
|
|
199
|
+
&& this.current.currentSessionId === null && this.current.sessionWorkspaceId === task.workspaceId;
|
|
200
|
+
}
|
|
201
|
+
preparationCurrent(task) {
|
|
202
|
+
return this.preparationOwned(task) && !task.navigation.aborted;
|
|
203
|
+
}
|
|
204
|
+
preparationConfirmed(task, session) {
|
|
205
|
+
const selection = session.admittedSelection;
|
|
206
|
+
return selection !== undefined && !selection.refreshRequired && session.sessionId === task.id && !session.refreshRequired && !session.selection.refreshRequired
|
|
207
|
+
&& writableSelectionVersion(session.selection.selectionRevision) && selection.selectedId === task.selectedId && selection.appliedRevision === task.revision
|
|
208
|
+
&& session.selection.selectedId === task.selectedId && session.selection.appliedRevision === task.revision;
|
|
209
|
+
}
|
|
210
|
+
openPrepared(task, explicit = false) {
|
|
211
|
+
if (!this.preparationOwned(task) || !explicit && task.navigation.aborted || task.id === null || this.current.busy !== null || this.current.dirty || this.current.invalidFields.length > 0 || this.current.pendingEditor !== null)
|
|
212
|
+
return;
|
|
213
|
+
task.opening = true;
|
|
214
|
+
try {
|
|
215
|
+
this.publish({ sessionUnconfirmed: true });
|
|
216
|
+
if (this.preparationOwned(task))
|
|
217
|
+
task.native.openSession(task.id);
|
|
218
|
+
}
|
|
219
|
+
finally {
|
|
220
|
+
task.opening = false;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
async prepareSession(refreshOnly = false) {
|
|
224
|
+
const { sessionWorkspaceId: workspaceId, sessionChoice: selectedId, snapshot } = this.current;
|
|
225
|
+
const native = this.blankNative;
|
|
226
|
+
if (this.disposed || !this.connectionCurrent() || native === null || this.composerBlocks === null || this.composerReason === null
|
|
227
|
+
|| this.current.currentSessionId !== null || this.current.sessionBusy !== null || this.current.busy !== null
|
|
228
|
+
|| this.current.dirty || this.current.invalidFields.length > 0 || this.current.pendingEditor !== null || snapshot === null)
|
|
229
|
+
return;
|
|
230
|
+
if (workspaceId === null) {
|
|
231
|
+
if (!refreshOnly)
|
|
232
|
+
this.publish({ sessionPreparationPending: true });
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
if (this.current.sessionUnconfirmed && !refreshOnly)
|
|
236
|
+
return;
|
|
237
|
+
const profile = snapshot.profiles.find(item => item.id === selectedId), revision = selectedId === null ? null : profile?.revision;
|
|
238
|
+
if (!refreshOnly && selectedId !== null && (!isConfigRevision(revision) || profile?.error !== undefined))
|
|
239
|
+
return;
|
|
240
|
+
let task = this.preparation;
|
|
241
|
+
const openOnly = !refreshOnly && task?.confirmed === true && task.selectedId === selectedId && task.revision === (revision ?? null);
|
|
242
|
+
if (task === null) {
|
|
243
|
+
if (refreshOnly)
|
|
244
|
+
return;
|
|
245
|
+
const navigation = native.beginNavigation();
|
|
246
|
+
task = { native, navigation, workspaceId, selectedId, revision: revision ?? null, id: null, reference: null, held: null, confirmed: false, opening: false, stop: () => { } };
|
|
247
|
+
this.preparation = task;
|
|
248
|
+
}
|
|
249
|
+
else if (!refreshOnly && !openOnly) {
|
|
250
|
+
task.selectedId = selectedId;
|
|
251
|
+
task.revision = revision ?? null;
|
|
252
|
+
task.confirmed = false;
|
|
253
|
+
}
|
|
254
|
+
if (!refreshOnly && !openOnly) {
|
|
255
|
+
task.stop();
|
|
256
|
+
if (task.navigation.aborted)
|
|
257
|
+
task.navigation = native.beginNavigation();
|
|
258
|
+
const navigation = task.navigation;
|
|
259
|
+
const owned = task;
|
|
260
|
+
const abort = () => { if (this.preparation === owned && !owned.opening)
|
|
261
|
+
this.cancelPreparation(); };
|
|
262
|
+
navigation.addEventListener("abort", abort, { once: true });
|
|
263
|
+
task.stop = () => navigation.removeEventListener("abort", abort);
|
|
264
|
+
}
|
|
265
|
+
const owned = task;
|
|
266
|
+
const live = () => refreshOnly ? this.preparationOwned(owned) : this.preparationCurrent(owned);
|
|
267
|
+
this.publish({ sessionBusy: refreshOnly ? "read" : "apply", sessionPreparationPending: false, sessionIssue: null, sessionNotice: null });
|
|
268
|
+
try {
|
|
269
|
+
if (openOnly) {
|
|
270
|
+
this.openPrepared(task, true);
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
if (!live())
|
|
274
|
+
return;
|
|
275
|
+
if (task.id === null) {
|
|
276
|
+
if (refreshOnly)
|
|
277
|
+
throw { kind: "transport", code: "unavailable" };
|
|
278
|
+
const id = await native.connectWorkspace(workspaceId);
|
|
279
|
+
if (!live())
|
|
280
|
+
return;
|
|
281
|
+
task.id = id;
|
|
282
|
+
}
|
|
283
|
+
const id = task.id;
|
|
284
|
+
if (task.reference === null) {
|
|
285
|
+
task.reference = native.retain(id);
|
|
286
|
+
if (!live()) {
|
|
287
|
+
task.reference.release();
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
if (task.reference.sessionId !== id)
|
|
291
|
+
throw { kind: "assembly", code: "unavailable" };
|
|
292
|
+
}
|
|
293
|
+
if (task.held === null) {
|
|
294
|
+
// Occupy the empty native seat synchronously, before awaiting readiness.
|
|
295
|
+
const blocks = this.composerBlocks, store = blocks.storeFor(id);
|
|
296
|
+
if (store.getSnapshot() !== undefined)
|
|
297
|
+
throw { kind: "domain", code: "busy" };
|
|
298
|
+
const block = { reason: this.composerReason() };
|
|
299
|
+
task.held = { blocks, store, block };
|
|
300
|
+
blocks.set(id, block);
|
|
301
|
+
}
|
|
302
|
+
const binding = await task.reference.ready;
|
|
303
|
+
if (!live())
|
|
304
|
+
return;
|
|
305
|
+
if (binding.sessionId !== id)
|
|
306
|
+
throw { kind: "assembly", code: "unavailable" };
|
|
307
|
+
const session = await this.unwrap(this.remote.describeSession(id));
|
|
308
|
+
if (!live())
|
|
309
|
+
return;
|
|
310
|
+
if (session.sessionId !== id)
|
|
311
|
+
throw { kind: "assembly", code: "unavailable" };
|
|
312
|
+
if (refreshOnly) {
|
|
313
|
+
task.confirmed = this.preparationConfirmed(task, session);
|
|
314
|
+
if (task.confirmed) {
|
|
315
|
+
this.publish({ sessionUnconfirmed: false });
|
|
316
|
+
this.openPrepared(task);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
const uncertain = session.refreshRequired === true || session.selection.refreshRequired === true;
|
|
320
|
+
this.publish({ sessionUnconfirmed: uncertain, sessionIssue: { kind: "domain", code: uncertain ? "unavailable" : "conflict" } });
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
if (session.refreshRequired || session.selection.refreshRequired || !writableSelectionVersion(session.selection.selectionRevision))
|
|
324
|
+
throw { kind: "domain", code: "conflict" };
|
|
325
|
+
if (session.canApplyOverlay !== true || session.applyOverlayUnavailableReason === "new-session-required")
|
|
326
|
+
throw { kind: "domain", code: session.applyOverlayUnavailableReason ?? "unavailable" };
|
|
327
|
+
const held = task.held;
|
|
328
|
+
if (held === null || held.blocks.storeFor(id) !== held.store || held.store.getSnapshot() !== held.block)
|
|
329
|
+
throw { kind: "domain", code: "busy" };
|
|
330
|
+
if (this.current.dirty || this.current.invalidFields.length > 0 || this.current.pendingEditor !== null)
|
|
331
|
+
throw { kind: "domain", code: "conflict" };
|
|
332
|
+
this.pendingSessionSelections.add(id);
|
|
333
|
+
const accepted = await this.unwrap(this.remote.selectSession(id, { sessionId: id, id: task.selectedId,
|
|
334
|
+
...(task.selectedId === null ? {} : { expectedRevision: task.revision }), expectedSelectionRevision: session.selection.selectionRevision, expectedAdmissionEpoch: session.admissionEpoch }));
|
|
335
|
+
if (!live())
|
|
336
|
+
return;
|
|
337
|
+
if (!this.preparationConfirmed(task, accepted)) {
|
|
338
|
+
this.publish({ sessionUnconfirmed: true });
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
task.confirmed = true;
|
|
342
|
+
this.openPrepared(task);
|
|
343
|
+
}
|
|
344
|
+
catch (error) {
|
|
345
|
+
if (this.preparationOwned(task)) {
|
|
346
|
+
const issue = this.issue(error), uncertain = task.confirmed || issue.kind !== "domain" || issue.code === "cancelled";
|
|
347
|
+
this.publish({ sessionIssue: task.id === null && uncertain ? { kind: "assembly", code: "blank-identity-unconfirmed" } : issue, sessionUnconfirmed: uncertain });
|
|
348
|
+
// A definite pre-commit refusal needs no task-owned send block or retain.
|
|
349
|
+
if (!uncertain)
|
|
350
|
+
this.releasePreparation();
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
finally {
|
|
354
|
+
if (task.id !== null)
|
|
355
|
+
this.pendingSessionSelections.delete(task.id);
|
|
356
|
+
if (this.preparationOwned(task))
|
|
357
|
+
this.publish({ sessionBusy: null });
|
|
358
|
+
else if (!this.disposed && this.current.currentSessionId === null && this.preparation === null)
|
|
359
|
+
this.publish({ sessionBusy: null });
|
|
360
|
+
else if (!this.disposed && this.connectionCurrent() && task.id === this.current.currentSessionId) {
|
|
361
|
+
this.modeRefreshPending = true;
|
|
362
|
+
this.refreshObservedMode();
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
143
366
|
attachComposerBlocks(blocks, reason) {
|
|
144
367
|
if (this.disposed)
|
|
145
368
|
return;
|
|
369
|
+
if (blocks !== this.composerBlocks && this.preparation !== null)
|
|
370
|
+
this.cancelPreparation();
|
|
146
371
|
this.releaseComposerBlock();
|
|
147
372
|
this.composerBlocks = blocks;
|
|
148
373
|
this.composerReason = reason ?? null;
|
|
149
|
-
this.
|
|
374
|
+
this.publish({ sessionPreparationAvailable: this.blankNative !== null && blocks !== null });
|
|
150
375
|
}
|
|
151
376
|
releaseComposerBlock() {
|
|
152
377
|
const held = this.composerBlock;
|
|
@@ -185,6 +410,33 @@ export class ProfilesController {
|
|
|
185
410
|
this.modelSelectionSource = source;
|
|
186
411
|
this.stopModelSelection = source?.subscribe(() => { this.modelSelectionGeneration += 1; }) ?? null;
|
|
187
412
|
}
|
|
413
|
+
attachSessionSource(sessionId, source) {
|
|
414
|
+
if (this.disposed || sessionId === this.sessionSourceId && source === this.sessionSource)
|
|
415
|
+
return;
|
|
416
|
+
this.stopSessionSource?.();
|
|
417
|
+
this.sessionSourceId = sessionId;
|
|
418
|
+
this.sessionSource = source;
|
|
419
|
+
let running = source?.getSnapshot().running;
|
|
420
|
+
const current = () => !this.disposed && sessionId !== null && sessionId === this.current.currentSessionId && source === this.sessionSource;
|
|
421
|
+
this.stopSessionSource = source?.subscribe(() => {
|
|
422
|
+
if (!current())
|
|
423
|
+
return;
|
|
424
|
+
const next = source.getSnapshot().running;
|
|
425
|
+
if (next === running)
|
|
426
|
+
return;
|
|
427
|
+
running = next;
|
|
428
|
+
// Running is an invalidation signal, never permission to apply an overlay.
|
|
429
|
+
this.modeRefreshPending = true;
|
|
430
|
+
this.refreshObservedMode();
|
|
431
|
+
}) ?? null;
|
|
432
|
+
if (current()) {
|
|
433
|
+
this.sessionGeneration += 1;
|
|
434
|
+
this.modeRefreshPending = source !== null;
|
|
435
|
+
this.publish({ session: null, sessionBusy: null, sessionNotice: null, sessionViewEpoch: this.current.sessionViewEpoch + 1,
|
|
436
|
+
sessionUnconfirmed: this.pendingSessionSelections.has(sessionId) });
|
|
437
|
+
this.refreshObservedMode();
|
|
438
|
+
}
|
|
439
|
+
}
|
|
188
440
|
attachModelEventSource(sessionId, source) {
|
|
189
441
|
if (this.disposed || (sessionId === this.modelEventsSessionId && source === this.modelEvents))
|
|
190
442
|
return;
|
|
@@ -241,15 +493,26 @@ export class ProfilesController {
|
|
|
241
493
|
setSession(id) {
|
|
242
494
|
if (this.disposed || id === this.current.currentSessionId)
|
|
243
495
|
return;
|
|
496
|
+
const task = this.preparation;
|
|
497
|
+
const preparationUnconfirmed = task?.id === id && this.current.sessionUnconfirmed;
|
|
498
|
+
if (task?.id === id && task.held !== null && id !== null) {
|
|
499
|
+
// The native current binding has retained this exact target. Transfer our
|
|
500
|
+
// block to the ordinary current-session lifecycle without an empty seat.
|
|
501
|
+
this.composerBlock = { id: id, store: task.held.store, block: task.held.block };
|
|
502
|
+
task.held = null;
|
|
503
|
+
}
|
|
504
|
+
this.releasePreparation();
|
|
244
505
|
this.sessionGeneration += 1;
|
|
245
506
|
this.modeRefreshPending = false;
|
|
507
|
+
if (id !== this.sessionSourceId)
|
|
508
|
+
this.attachSessionSource(null, null);
|
|
246
509
|
if (id !== this.modelSelectionSessionId)
|
|
247
510
|
this.attachModelSelectionSource(null, null);
|
|
248
511
|
if (id !== this.modelEventsSessionId)
|
|
249
512
|
this.attachModelEventSource(null, null);
|
|
250
513
|
if (id !== this.modelInteractionSessionId)
|
|
251
514
|
this.attachModelInteractionSource(null, null);
|
|
252
|
-
this.publish({ currentSessionId: id, sessionViewEpoch: this.current.sessionViewEpoch + 1, sessionUnconfirmed: id !== null && this.pendingSessionSelections.has(id), session: null, sessionChoice: null, sessionBusy: null, sessionIssue: null, sessionNotice: null });
|
|
515
|
+
this.publish({ currentSessionId: id, sessionViewEpoch: this.current.sessionViewEpoch + 1, sessionPreparationPending: false, sessionUnconfirmed: id !== null && (preparationUnconfirmed || this.pendingSessionSelections.has(id)), session: null, sessionChoice: null, sessionBusy: null, sessionIssue: null, sessionNotice: null });
|
|
253
516
|
if (id !== null)
|
|
254
517
|
void this.refreshSession();
|
|
255
518
|
}
|
|
@@ -278,7 +541,11 @@ export class ProfilesController {
|
|
|
278
541
|
}
|
|
279
542
|
async refreshSession(preserveFeedback = false) {
|
|
280
543
|
const id = this.current.currentSessionId;
|
|
281
|
-
if (
|
|
544
|
+
if (id === null && this.preparation !== null) {
|
|
545
|
+
await this.prepareSession(true);
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
if (this.disposed || !this.connectionCurrent() || id === null || this.current.sessionBusy !== null || this.sessionSourceId === id && this.sessionSource === null)
|
|
282
549
|
return;
|
|
283
550
|
this.modeRefreshPending = false;
|
|
284
551
|
const generation = ++this.sessionGeneration;
|
|
@@ -321,18 +588,30 @@ export class ProfilesController {
|
|
|
321
588
|
this.publish({ session: accepted, sessionNotice: active ? "mode-on" : "mode-off" });
|
|
322
589
|
}
|
|
323
590
|
catch (error) {
|
|
324
|
-
if (live())
|
|
325
|
-
|
|
591
|
+
if (live()) {
|
|
592
|
+
const issue = this.issue(error);
|
|
593
|
+
if (["busy", "maintenance", "conflict"].includes(issue.code))
|
|
594
|
+
this.modeRefreshPending = true;
|
|
595
|
+
this.publish({ sessionIssue: issue });
|
|
596
|
+
}
|
|
326
597
|
}
|
|
327
598
|
finally {
|
|
328
599
|
if (live()) {
|
|
329
600
|
this.publish({ sessionBusy: null });
|
|
330
601
|
this.refreshObservedMode();
|
|
331
602
|
}
|
|
603
|
+
else if (!this.disposed && this.connectionCurrent() && id === this.current.currentSessionId) {
|
|
604
|
+
this.modeRefreshPending = true;
|
|
605
|
+
this.refreshObservedMode();
|
|
606
|
+
}
|
|
332
607
|
}
|
|
333
608
|
}
|
|
334
609
|
async selectSession(reset, options, modelOnly = false) {
|
|
335
610
|
const { currentSessionId: id, session, sessionChoice, snapshot } = this.current;
|
|
611
|
+
if (id === null && !reset && !modelOnly && options?.useProfileModel !== true) {
|
|
612
|
+
await this.prepareSession();
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
336
615
|
if (this.disposed || !this.connectionCurrent() || this.current.sessionUnconfirmed || id === null || session === null || session.refreshRequired || session.selection.refreshRequired || !writableSelectionVersion(session.selection.selectionRevision)
|
|
337
616
|
|| (modelOnly ? session.canSelectModel !== true : session.canApplyOverlay !== true || session.applyOverlayUnavailableReason === "new-session-required") || this.current.sessionBusy !== null
|
|
338
617
|
|| this.current.busy !== null || this.current.dirty || this.current.invalidFields.length > 0 || this.current.pendingEditor !== null)
|
|
@@ -426,6 +705,8 @@ export class ProfilesController {
|
|
|
426
705
|
catch (error) {
|
|
427
706
|
if (live()) {
|
|
428
707
|
const issue = this.issue(error);
|
|
708
|
+
if (["busy", "maintenance", "conflict"].includes(issue.code))
|
|
709
|
+
this.modeRefreshPending = true;
|
|
429
710
|
this.publish({ sessionIssue: issue, sessionUnconfirmed: !modelOnly && (issue.kind !== "domain" || issue.code === "cancelled") });
|
|
430
711
|
}
|
|
431
712
|
}
|
|
@@ -44,6 +44,8 @@ export declare const deploymentEn: {
|
|
|
44
44
|
unitChars: string;
|
|
45
45
|
useDefaults: string;
|
|
46
46
|
restoreInheritance: string;
|
|
47
|
+
gitWriteAllWrites: string;
|
|
48
|
+
gitWriteHighRisk: string;
|
|
47
49
|
nativeRuntimeState: string;
|
|
48
50
|
nativeRuntimeBinding: string;
|
|
49
51
|
nativeRuntimeFence: string;
|
|
@@ -22,6 +22,7 @@ export const deploymentEn = {
|
|
|
22
22
|
nativeRuntimeReadinessHint: "Task progress is available in the session.",
|
|
23
23
|
unsetGroup: "Use defaults for this group", unitBytes: "bytes", unitChars: "characters",
|
|
24
24
|
useDefaults: "Use defaults", restoreInheritance: "Restore inheritance",
|
|
25
|
+
gitWriteAllWrites: "All write operations", gitWriteHighRisk: "High-risk write operations only",
|
|
25
26
|
nativeRuntimeState: "Observed native runtime", nativeRuntimeBinding: "Observed runtime composition", nativeRuntimeFence: "Execution admission ready", nativeRuntimeRestart: "Restart required", nativeRuntimeStock: "Official Host runtime", nativeRuntimeUnavailable: "Unavailable / unknown",
|
|
26
27
|
"nativeRuntimeReason-explicit-composition-required": "The Host requires an explicit native runtime composition.", "nativeRuntimeReason-duplicate-provider": "More than one native provider is present; readiness is not confirmed.", "nativeRuntimeReason-authority-not-ready": "Native execution authority is not ready.", "nativeRuntimeReason-disabled": "The saved native runtime is disabled.", "nativeRuntimeReason-pending-restart": "Saved desired state differs from the mounted native composition; restart is pending.", "nativeRuntimeReason-scope-conflict": "Native scope ownership conflicts; readiness is not confirmed.",
|
|
27
28
|
saveGlobal: "Save", saveProfile: "Save", saving: "Saving…", refresh: "Refresh", discard: "Discard and reload", dirty: "Unsaved changes", saved: "Saved",
|
|
@@ -65,6 +66,7 @@ export const deploymentZh = {
|
|
|
65
66
|
nativeRuntimeReadinessHint: "任务进度可在会话中查看。",
|
|
66
67
|
unsetGroup: "整组使用默认配置", unitBytes: "字节", unitChars: "字符",
|
|
67
68
|
useDefaults: "使用默认值", restoreInheritance: "恢复继承",
|
|
69
|
+
gitWriteAllWrites: "所有写操作", gitWriteHighRisk: "仅高风险写操作",
|
|
68
70
|
nativeRuntimeState: "已观测原生运行时", nativeRuntimeBinding: "已观测运行时组合", nativeRuntimeFence: "执行准入已就绪", nativeRuntimeRestart: "需要重启", nativeRuntimeStock: "官方 Host 运行时", nativeRuntimeUnavailable: "不可用/未知",
|
|
69
71
|
"nativeRuntimeReason-explicit-composition-required": "Host 需要显式的原生运行时组合。", "nativeRuntimeReason-duplicate-provider": "存在重复原生 provider,无法确认就绪状态。", "nativeRuntimeReason-authority-not-ready": "原生执行权限尚未就绪。", "nativeRuntimeReason-disabled": "已保存的原生运行时为关闭。", "nativeRuntimeReason-pending-restart": "已保存 desired 与已挂载原生组合不同,等待独立重启。", "nativeRuntimeReason-scope-conflict": "原生 scope 所有权冲突,无法确认就绪状态。",
|
|
70
72
|
saveGlobal: "保存", saveProfile: "保存", saving: "正在保存…", refresh: "刷新", discard: "丢弃并重载", dirty: "未保存", saved: "已保存",
|
|
@@ -97,7 +99,7 @@ export const deploymentFieldLabels = {
|
|
|
97
99
|
promptOrder: ["Prompt order", "提示词顺序"], defaultActive: ["Default Deepwork mode", "默认 Deepwork 模式"],
|
|
98
100
|
enabled: ["Enabled", "启用"], materialize: ["Materialize presets", "物化预设"], scope: ["Guard scope", "保护范围"],
|
|
99
101
|
shellCommandSafety: ["Shell command safety", "Shell 命令安全"], gitWriteGuard: ["Git write policy", "Git 写入策略"],
|
|
100
|
-
gitWriteScope: ["
|
|
102
|
+
gitWriteScope: ["Git write protection scope", "Git 写操作保护范围"],
|
|
101
103
|
toolOutputTruncation: ["Tool output truncation", "工具输出截断"], maxInlineBytes: ["Inline byte limit", "内联字节上限"],
|
|
102
104
|
planFormatValidation: ["Plan format validation", "计划格式校验"], questionLabelHelper: ["Question labels", "提问标签"], maxLabelChars: ["Label character limit", "标签字符上限"], todoDisciplineHelper: ["Todo discipline", "待办纪律"],
|
|
103
105
|
enableRunInBackground: ["Allow background runs", "允许后台执行"], backgroundMode: ["Background mode", "后台模式"], maxDepth: ["Maximum depth", "最大深度"],
|