@spotpatch/runtime 1.1.0 → 1.1.2
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/dist/index.cjs +58 -120
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +58 -121
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -76,7 +76,6 @@ function createAnnotation(input) {
|
|
|
76
76
|
// src/api/runtime-api.ts
|
|
77
77
|
import {
|
|
78
78
|
SPOTPATCH_ENDPOINTS,
|
|
79
|
-
SPOTPATCH_EDITOR_PREFERENCES,
|
|
80
79
|
SPOTPATCH_TOKEN_HEADER,
|
|
81
80
|
getAgentJobEndpoint
|
|
82
81
|
} from "@spotpatch/shared";
|
|
@@ -249,9 +248,6 @@ function readSuccessData(value) {
|
|
|
249
248
|
function isCodeContext(value) {
|
|
250
249
|
return isRecord2(value) && typeof value.relativePath === "string" && (value.language === "tsx" || value.language === "jsx") && typeof value.startLine === "number" && typeof value.endLine === "number" && typeof value.excerpt === "string" && (value.boundary === "component" || value.boundary === "nearby-lines");
|
|
251
250
|
}
|
|
252
|
-
function isEditorOpenResult(value) {
|
|
253
|
-
return isRecord2(value) && typeof value.editor === "string" && SPOTPATCH_EDITOR_PREFERENCES.includes(value.editor);
|
|
254
|
-
}
|
|
255
251
|
function deepFreezeUnknown(value) {
|
|
256
252
|
if (!isRecord2(value) && !Array.isArray(value)) {
|
|
257
253
|
return;
|
|
@@ -479,7 +475,7 @@ function createRuntimeApi(options) {
|
|
|
479
475
|
},
|
|
480
476
|
async openEditor(request) {
|
|
481
477
|
const data = await requestJson(SPOTPATCH_ENDPOINTS.openEditor, "POST", request);
|
|
482
|
-
if (!
|
|
478
|
+
if (!isRecord2(data) || data.editor !== "auto" && data.editor !== "vscode" && data.editor !== "cursor") {
|
|
483
479
|
throw new RuntimeApiError();
|
|
484
480
|
}
|
|
485
481
|
return Object.freeze({ editor: data.editor });
|
|
@@ -1570,10 +1566,12 @@ var AGENT_PANEL_STYLES = `
|
|
|
1570
1566
|
border-radius: 10px;
|
|
1571
1567
|
padding: 8px 30px 8px 10px;
|
|
1572
1568
|
color: #e8ebf2;
|
|
1569
|
+
color-scheme: dark;
|
|
1573
1570
|
background: var(--spotpatch-bg-raised);
|
|
1574
1571
|
font-size: 15px;
|
|
1575
1572
|
outline: none;
|
|
1576
1573
|
}
|
|
1574
|
+
.spotpatch-agent select option { color: #e8ebf2; background: #10151e; }
|
|
1577
1575
|
.spotpatch-agent select:focus-visible,
|
|
1578
1576
|
.spotpatch-consent input:focus-visible {
|
|
1579
1577
|
outline: 2px solid #8b7cf7;
|
|
@@ -1796,8 +1794,7 @@ function createAgentPanel(document, ai, localizer) {
|
|
|
1796
1794
|
resetButton.hidden = true;
|
|
1797
1795
|
}
|
|
1798
1796
|
};
|
|
1799
|
-
|
|
1800
|
-
providerSelect.addEventListener("change", () => {
|
|
1797
|
+
function handleProviderChange() {
|
|
1801
1798
|
populateModels();
|
|
1802
1799
|
consentCheckbox.checked = false;
|
|
1803
1800
|
capability.dataset.state = "idle";
|
|
@@ -1807,8 +1804,8 @@ function createAgentPanel(document, ai, localizer) {
|
|
|
1807
1804
|
latestCapabilityErrorCode = void 0;
|
|
1808
1805
|
capabilityReady = false;
|
|
1809
1806
|
refreshActions();
|
|
1810
|
-
}
|
|
1811
|
-
|
|
1807
|
+
}
|
|
1808
|
+
function handleModelChange() {
|
|
1812
1809
|
capability.dataset.state = "idle";
|
|
1813
1810
|
capability.textContent = messages.agent.connectionNotTested;
|
|
1814
1811
|
latestCapabilityState = "idle";
|
|
@@ -1816,7 +1813,10 @@ function createAgentPanel(document, ai, localizer) {
|
|
|
1816
1813
|
latestCapabilityErrorCode = void 0;
|
|
1817
1814
|
capabilityReady = false;
|
|
1818
1815
|
refreshActions();
|
|
1819
|
-
}
|
|
1816
|
+
}
|
|
1817
|
+
populateModels();
|
|
1818
|
+
providerSelect.addEventListener("change", handleProviderChange);
|
|
1819
|
+
modelSelect.addEventListener("change", handleModelChange);
|
|
1820
1820
|
consentCheckbox.addEventListener("change", refreshActions);
|
|
1821
1821
|
function renderCurrentJob() {
|
|
1822
1822
|
if (latestSnapshot === void 0) {
|
|
@@ -1990,6 +1990,9 @@ function createAgentPanel(document, ai, localizer) {
|
|
|
1990
1990
|
},
|
|
1991
1991
|
dispose() {
|
|
1992
1992
|
unsubscribeLocale();
|
|
1993
|
+
providerSelect.removeEventListener("change", handleProviderChange);
|
|
1994
|
+
modelSelect.removeEventListener("change", handleModelChange);
|
|
1995
|
+
consentCheckbox.removeEventListener("change", refreshActions);
|
|
1993
1996
|
}
|
|
1994
1997
|
});
|
|
1995
1998
|
}
|
|
@@ -2141,15 +2144,6 @@ var STATUS_ZH = Object.freeze({
|
|
|
2141
2144
|
reverted: "\u5DF2\u64A4\u9500",
|
|
2142
2145
|
failed: "\u5931\u8D25"
|
|
2143
2146
|
});
|
|
2144
|
-
function editorName(editor, automatic) {
|
|
2145
|
-
if (editor === "vscode") {
|
|
2146
|
-
return "VS Code";
|
|
2147
|
-
}
|
|
2148
|
-
if (editor === "cursor") {
|
|
2149
|
-
return "Cursor";
|
|
2150
|
-
}
|
|
2151
|
-
return automatic;
|
|
2152
|
-
}
|
|
2153
2147
|
var ERROR_MESSAGES_EN = Object.freeze({
|
|
2154
2148
|
[ERROR_CODES2.INVALID_REQUEST]: "The Agent request was rejected as invalid.",
|
|
2155
2149
|
[ERROR_CODES2.INVALID_TOKEN]: "The local SpotPatch session expired.",
|
|
@@ -2288,7 +2282,7 @@ var UI_MESSAGES = Object.freeze({
|
|
|
2288
2282
|
brand: Object.freeze({
|
|
2289
2283
|
name: "SpotPatch",
|
|
2290
2284
|
context: "Live context",
|
|
2291
|
-
repository: "GitHub",
|
|
2285
|
+
repository: "GitHub \u2197",
|
|
2292
2286
|
repositoryTitle: "Star SpotPatch on GitHub"
|
|
2293
2287
|
}),
|
|
2294
2288
|
trigger: Object.freeze({
|
|
@@ -2342,8 +2336,8 @@ var UI_MESSAGES = Object.freeze({
|
|
|
2342
2336
|
actions: Object.freeze({
|
|
2343
2337
|
addElement: "Add element",
|
|
2344
2338
|
reselect: "Start over",
|
|
2345
|
-
openEditor:
|
|
2346
|
-
openTarget: (index
|
|
2339
|
+
openEditor: "Open source",
|
|
2340
|
+
openTarget: (index) => `Open source for target ${String(index)}`,
|
|
2347
2341
|
preview: "Preview prompt",
|
|
2348
2342
|
copy: "Copy prompt",
|
|
2349
2343
|
back: "Back to edit"
|
|
@@ -2399,9 +2393,9 @@ var UI_MESSAGES = Object.freeze({
|
|
|
2399
2393
|
detachedTargetRemoved: "A removed page element was dropped from the selection.",
|
|
2400
2394
|
contextWarning: "Browser context collection completed with a warning.",
|
|
2401
2395
|
contextCollected: "Browser context collected.",
|
|
2402
|
-
editorOpening:
|
|
2403
|
-
editorOpened:
|
|
2404
|
-
editorFailed:
|
|
2396
|
+
editorOpening: "Opening source\u2026",
|
|
2397
|
+
editorOpened: "Source opened in the editor.",
|
|
2398
|
+
editorFailed: "Could not open the editor. Start it or configure editor.",
|
|
2405
2399
|
completeInstructions: "Add an instruction for every target and wait for context collection to finish.",
|
|
2406
2400
|
promptCopied: "Prompt copied to the clipboard.",
|
|
2407
2401
|
clipboardUnavailable: "Clipboard access is unavailable. Select the prompt manually.",
|
|
@@ -2417,7 +2411,7 @@ var UI_MESSAGES = Object.freeze({
|
|
|
2417
2411
|
brand: Object.freeze({
|
|
2418
2412
|
name: "SpotPatch",
|
|
2419
2413
|
context: "\u5B9E\u65F6\u4E0A\u4E0B\u6587",
|
|
2420
|
-
repository: "GitHub",
|
|
2414
|
+
repository: "GitHub \u2197",
|
|
2421
2415
|
repositoryTitle: "\u5728 GitHub \u4E0A Star SpotPatch"
|
|
2422
2416
|
}),
|
|
2423
2417
|
trigger: Object.freeze({
|
|
@@ -2471,8 +2465,8 @@ var UI_MESSAGES = Object.freeze({
|
|
|
2471
2465
|
actions: Object.freeze({
|
|
2472
2466
|
addElement: "\u6DFB\u52A0\u5143\u7D20",
|
|
2473
2467
|
reselect: "\u91CD\u65B0\u5F00\u59CB",
|
|
2474
|
-
openEditor:
|
|
2475
|
-
openTarget: (index
|
|
2468
|
+
openEditor: "\u6253\u5F00\u6E90\u7801",
|
|
2469
|
+
openTarget: (index) => `\u6253\u5F00\u76EE\u6807 ${String(index)} \u7684\u6E90\u7801`,
|
|
2476
2470
|
preview: "\u9884\u89C8 Prompt",
|
|
2477
2471
|
copy: "\u590D\u5236 Prompt",
|
|
2478
2472
|
back: "\u8FD4\u56DE\u7F16\u8F91"
|
|
@@ -2528,9 +2522,9 @@ var UI_MESSAGES = Object.freeze({
|
|
|
2528
2522
|
detachedTargetRemoved: "\u9875\u9762\u4E2D\u7684\u76EE\u6807\u5DF2\u5378\u8F7D\uFF0C\u5DF2\u4ECE\u5F53\u524D\u9009\u62E9\u4E2D\u79FB\u9664\u3002",
|
|
2529
2523
|
contextWarning: "\u6D4F\u89C8\u5668\u4E0A\u4E0B\u6587\u91C7\u96C6\u5B8C\u6210\uFF0C\u4F46\u5B58\u5728\u8B66\u544A\u3002",
|
|
2530
2524
|
contextCollected: "\u6D4F\u89C8\u5668\u4E0A\u4E0B\u6587\u91C7\u96C6\u5B8C\u6210\u3002",
|
|
2531
|
-
editorOpening:
|
|
2532
|
-
editorOpened:
|
|
2533
|
-
editorFailed:
|
|
2525
|
+
editorOpening: "\u6B63\u5728\u6253\u5F00\u6E90\u7801\u2026\u2026",
|
|
2526
|
+
editorOpened: "\u6E90\u7801\u5DF2\u5728\u7F16\u8F91\u5668\u4E2D\u6253\u5F00\u3002",
|
|
2527
|
+
editorFailed: "\u65E0\u6CD5\u6253\u5F00\u7F16\u8F91\u5668\u3002\u8BF7\u5148\u542F\u52A8\u7F16\u8F91\u5668\u6216\u68C0\u67E5 editor \u914D\u7F6E\u3002",
|
|
2534
2528
|
completeInstructions: "\u8BF7\u4E3A\u6BCF\u4E2A\u76EE\u6807\u586B\u5199\u4FEE\u6539\u8BF4\u660E\uFF0C\u5E76\u7B49\u5F85\u4E0A\u4E0B\u6587\u91C7\u96C6\u5B8C\u6210\u3002",
|
|
2535
2529
|
promptCopied: "Prompt \u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F\u3002",
|
|
2536
2530
|
clipboardUnavailable: "\u65E0\u6CD5\u8BBF\u95EE\u526A\u8D34\u677F\uFF0C\u8BF7\u624B\u52A8\u9009\u62E9\u5E76\u590D\u5236 Prompt\u3002",
|
|
@@ -2825,36 +2819,27 @@ function createStyles(document) {
|
|
|
2825
2819
|
gap: 8px;
|
|
2826
2820
|
flex: none;
|
|
2827
2821
|
}
|
|
2822
|
+
.spotpatch-repository,
|
|
2823
|
+
.spotpatch-locale,
|
|
2824
|
+
.spotpatch-close {
|
|
2825
|
+
height: 30px;
|
|
2826
|
+
border: 1px solid rgb(255 255 255 / 11%);
|
|
2827
|
+
border-radius: 9px;
|
|
2828
|
+
background: rgb(255 255 255 / 4%);
|
|
2829
|
+
}
|
|
2828
2830
|
.spotpatch-repository {
|
|
2829
2831
|
display: inline-flex;
|
|
2830
|
-
height: 30px;
|
|
2831
2832
|
align-items: center;
|
|
2832
|
-
gap: 5px;
|
|
2833
|
-
border: 1px solid rgb(68 202 224 / 20%);
|
|
2834
|
-
border-radius: 9px;
|
|
2835
2833
|
padding: 0 10px;
|
|
2836
2834
|
color: #bcecf2;
|
|
2837
|
-
background: rgb(8 145 178 / 7%);
|
|
2838
2835
|
font-size: 11px;
|
|
2839
2836
|
font-weight: 680;
|
|
2840
2837
|
text-decoration: none;
|
|
2841
|
-
transition: border-color 150ms ease, color 150ms ease, background 150ms ease, transform 150ms ease;
|
|
2842
|
-
}
|
|
2843
|
-
.spotpatch-repository::after { content: "\u2197"; font-size: 10px; }
|
|
2844
|
-
.spotpatch-repository:hover {
|
|
2845
|
-
border-color: rgb(68 202 224 / 42%);
|
|
2846
|
-
color: #e6fbff;
|
|
2847
|
-
background: rgb(8 145 178 / 12%);
|
|
2848
|
-
transform: translateY(-1px);
|
|
2849
2838
|
}
|
|
2850
2839
|
.spotpatch-locale {
|
|
2851
2840
|
min-width: 38px;
|
|
2852
|
-
height: 30px;
|
|
2853
|
-
border: 1px solid rgb(255 255 255 / 11%);
|
|
2854
|
-
border-radius: 9px;
|
|
2855
2841
|
padding: 0 9px;
|
|
2856
2842
|
color: #c5cad5;
|
|
2857
|
-
background: rgb(255 255 255 / 4%);
|
|
2858
2843
|
cursor: pointer;
|
|
2859
2844
|
font-size: 12px;
|
|
2860
2845
|
font-weight: 650;
|
|
@@ -2862,20 +2847,17 @@ function createStyles(document) {
|
|
|
2862
2847
|
.spotpatch-close {
|
|
2863
2848
|
display: inline-grid;
|
|
2864
2849
|
width: 30px;
|
|
2865
|
-
height: 30px;
|
|
2866
2850
|
padding: 0;
|
|
2867
2851
|
place-items: center;
|
|
2868
|
-
border: 1px solid rgb(255 255 255 / 11%);
|
|
2869
|
-
border-radius: 9px;
|
|
2870
2852
|
color: #9da5b4;
|
|
2871
|
-
background: rgb(255 255 255 / 4%);
|
|
2872
2853
|
cursor: pointer;
|
|
2873
2854
|
font-size: 17px;
|
|
2874
2855
|
line-height: 1;
|
|
2875
2856
|
transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
|
|
2876
2857
|
}
|
|
2877
2858
|
.spotpatch-close:hover,
|
|
2878
|
-
.spotpatch-locale:hover
|
|
2859
|
+
.spotpatch-locale:hover,
|
|
2860
|
+
.spotpatch-repository:hover { border-color: rgb(129 112 247 / 45%); color: #fff; background: rgb(109 93 246 / 10%); }
|
|
2879
2861
|
.spotpatch-title {
|
|
2880
2862
|
margin: 0;
|
|
2881
2863
|
color: #fff;
|
|
@@ -2925,10 +2907,14 @@ function createStyles(document) {
|
|
|
2925
2907
|
background: #f59e0b;
|
|
2926
2908
|
content: "";
|
|
2927
2909
|
}
|
|
2928
|
-
.spotpatch-context-state[data-state="ready"]
|
|
2929
|
-
.spotpatch-
|
|
2930
|
-
.spotpatch-context-state[data-state="
|
|
2931
|
-
.spotpatch-
|
|
2910
|
+
.spotpatch-context-state[data-state="ready"],
|
|
2911
|
+
.spotpatch-editor-feedback[data-state="success"] { color: #9fe3c4; }
|
|
2912
|
+
.spotpatch-context-state[data-state="ready"]::before,
|
|
2913
|
+
.spotpatch-editor-feedback[data-state="success"]::before { background: #34d399; }
|
|
2914
|
+
.spotpatch-context-state[data-state="warning"],
|
|
2915
|
+
.spotpatch-editor-feedback[data-state="error"] { color: #fecaca; }
|
|
2916
|
+
.spotpatch-context-state[data-state="warning"]::before,
|
|
2917
|
+
.spotpatch-editor-feedback[data-state="error"]::before { background: #fb7185; }
|
|
2932
2918
|
.spotpatch-body {
|
|
2933
2919
|
min-height: 0;
|
|
2934
2920
|
overflow: auto;
|
|
@@ -3167,29 +3153,9 @@ function createStyles(document) {
|
|
|
3167
3153
|
background: rgb(8 12 22 / 82%);
|
|
3168
3154
|
}
|
|
3169
3155
|
.spotpatch-editor-feedback {
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
align-items: center;
|
|
3173
|
-
gap: 7px;
|
|
3174
|
-
margin-bottom: 1px;
|
|
3175
|
-
color: #9ca5b5;
|
|
3176
|
-
font-size: 11px;
|
|
3177
|
-
line-height: 1.45;
|
|
3156
|
+
flex-basis: 100%;
|
|
3157
|
+
white-space: normal;
|
|
3178
3158
|
}
|
|
3179
|
-
.spotpatch-editor-feedback[hidden] { display: none; }
|
|
3180
|
-
.spotpatch-editor-feedback::before {
|
|
3181
|
-
width: 6px;
|
|
3182
|
-
height: 6px;
|
|
3183
|
-
flex: none;
|
|
3184
|
-
border-radius: 999px;
|
|
3185
|
-
background: #94a3b8;
|
|
3186
|
-
content: "";
|
|
3187
|
-
}
|
|
3188
|
-
.spotpatch-editor-feedback[data-state="opening"]::before { background: #38bdf8; }
|
|
3189
|
-
.spotpatch-editor-feedback[data-state="success"] { color: #9fe3c4; }
|
|
3190
|
-
.spotpatch-editor-feedback[data-state="success"]::before { background: #34d399; }
|
|
3191
|
-
.spotpatch-editor-feedback[data-state="error"] { color: #fecaca; }
|
|
3192
|
-
.spotpatch-editor-feedback[data-state="error"]::before { background: #fb7185; }
|
|
3193
3159
|
.spotpatch-actions button {
|
|
3194
3160
|
display: inline-flex;
|
|
3195
3161
|
min-height: 40px;
|
|
@@ -3255,8 +3221,6 @@ function createStyles(document) {
|
|
|
3255
3221
|
.spotpatch-actions { padding-left: 16px; padding-right: 16px; }
|
|
3256
3222
|
.spotpatch-target-select { grid-template-columns: 32px minmax(0, 1fr); }
|
|
3257
3223
|
.spotpatch-target-state { display: none; }
|
|
3258
|
-
.spotpatch-repository { width: 30px; overflow: hidden; padding: 0; justify-content: center; color: transparent; }
|
|
3259
|
-
.spotpatch-repository::after { color: #bcecf2; content: "\u2197"; }
|
|
3260
3224
|
}
|
|
3261
3225
|
${AGENT_PANEL_STYLES}
|
|
3262
3226
|
`;
|
|
@@ -3266,7 +3230,7 @@ function summaryLine(summary, prefix) {
|
|
|
3266
3230
|
const line = summary.split("\n").find((candidate) => candidate.startsWith(`${prefix}: `));
|
|
3267
3231
|
return line?.slice(prefix.length + 2).trim();
|
|
3268
3232
|
}
|
|
3269
|
-
function createRuntimeView(document, shortcut, ai = Object.freeze({ enabled: false }), localePreference = "auto"
|
|
3233
|
+
function createRuntimeView(document, shortcut, ai = Object.freeze({ enabled: false }), localePreference = "auto") {
|
|
3270
3234
|
const localizer = createUiLocalizer(document, localePreference);
|
|
3271
3235
|
let messages = localizer.messages();
|
|
3272
3236
|
const host = document.createElement("spotpatch-root");
|
|
@@ -3388,17 +3352,14 @@ function createRuntimeView(document, shortcut, ai = Object.freeze({ enabled: fal
|
|
|
3388
3352
|
const actions = createMarkedElement(document, "footer");
|
|
3389
3353
|
actions.className = "spotpatch-actions";
|
|
3390
3354
|
const editorFeedback = createMarkedElement(document, "div");
|
|
3391
|
-
editorFeedback.className = "spotpatch-editor-feedback";
|
|
3355
|
+
editorFeedback.className = "spotpatch-context-state spotpatch-editor-feedback";
|
|
3392
3356
|
editorFeedback.dataset.state = "idle";
|
|
3393
3357
|
editorFeedback.setAttribute("role", "status");
|
|
3394
3358
|
editorFeedback.setAttribute("aria-live", "polite");
|
|
3395
3359
|
editorFeedback.hidden = true;
|
|
3396
3360
|
const addTargetButton = createButton(document, messages.actions.addElement);
|
|
3397
3361
|
const reselectButton = createButton(document, messages.actions.reselect);
|
|
3398
|
-
const openEditorButton = createButton(
|
|
3399
|
-
document,
|
|
3400
|
-
messages.actions.openEditor(editorPreference)
|
|
3401
|
-
);
|
|
3362
|
+
const openEditorButton = createButton(document, messages.actions.openEditor);
|
|
3402
3363
|
const previewButton = createButton(
|
|
3403
3364
|
document,
|
|
3404
3365
|
messages.actions.preview,
|
|
@@ -3446,20 +3407,11 @@ function createRuntimeView(document, shortcut, ai = Object.freeze({ enabled: fal
|
|
|
3446
3407
|
let currentTargets = [];
|
|
3447
3408
|
let currentMaximum = 0;
|
|
3448
3409
|
let currentEditorFeedbackState = "idle";
|
|
3449
|
-
function
|
|
3450
|
-
if (state === "opening") {
|
|
3451
|
-
return messages.announcements.editorOpening(editorPreference);
|
|
3452
|
-
}
|
|
3453
|
-
if (state === "success") {
|
|
3454
|
-
return messages.announcements.editorOpened(editorPreference);
|
|
3455
|
-
}
|
|
3456
|
-
return state === "error" ? messages.announcements.editorFailed(editorPreference) : "";
|
|
3457
|
-
}
|
|
3458
|
-
function renderEditorStatus(state, message = defaultEditorFeedback(state)) {
|
|
3410
|
+
function renderEditorStatus(state) {
|
|
3459
3411
|
currentEditorFeedbackState = state;
|
|
3460
3412
|
editorFeedback.dataset.state = state;
|
|
3461
3413
|
editorFeedback.hidden = state === "idle";
|
|
3462
|
-
editorFeedback.textContent =
|
|
3414
|
+
editorFeedback.textContent = state === "opening" ? messages.announcements.editorOpening : state === "success" ? messages.announcements.editorOpened : state === "error" ? messages.announcements.editorFailed : "";
|
|
3463
3415
|
placeDialog();
|
|
3464
3416
|
}
|
|
3465
3417
|
function statusText(target) {
|
|
@@ -3543,11 +3495,8 @@ function createRuntimeView(document, shortcut, ai = Object.freeze({ enabled: fal
|
|
|
3543
3495
|
const open = createButton(document, "\u2197", "spotpatch-target-open");
|
|
3544
3496
|
open.dataset.openTargetId = target.id;
|
|
3545
3497
|
open.disabled = !target.canOpenEditor;
|
|
3546
|
-
open.setAttribute(
|
|
3547
|
-
|
|
3548
|
-
messages.actions.openTarget(index + 1, editorPreference)
|
|
3549
|
-
);
|
|
3550
|
-
open.title = messages.actions.openTarget(index + 1, editorPreference);
|
|
3498
|
+
open.setAttribute("aria-label", messages.actions.openTarget(index + 1));
|
|
3499
|
+
open.title = messages.actions.openTarget(index + 1);
|
|
3551
3500
|
const remove = createButton(document, "\xD7", "spotpatch-target-remove");
|
|
3552
3501
|
remove.dataset.removeTargetId = target.id;
|
|
3553
3502
|
remove.disabled = !editingEnabled;
|
|
@@ -3745,7 +3694,7 @@ function createRuntimeView(document, shortcut, ai = Object.freeze({ enabled: fal
|
|
|
3745
3694
|
promptOutput.setAttribute("aria-label", messages.diagnostics.promptAriaLabel);
|
|
3746
3695
|
addTargetButton.textContent = messages.actions.addElement;
|
|
3747
3696
|
reselectButton.textContent = messages.actions.reselect;
|
|
3748
|
-
openEditorButton.textContent = messages.actions.openEditor
|
|
3697
|
+
openEditorButton.textContent = messages.actions.openEditor;
|
|
3749
3698
|
previewButton.textContent = messages.actions.preview;
|
|
3750
3699
|
copyButton.textContent = messages.actions.copy;
|
|
3751
3700
|
backButton.textContent = messages.actions.back;
|
|
@@ -4381,13 +4330,7 @@ function resolveBrowserDependencies(dependencies) {
|
|
|
4381
4330
|
}
|
|
4382
4331
|
function createController(config, dependencies = {}) {
|
|
4383
4332
|
const browser = resolveBrowserDependencies(dependencies);
|
|
4384
|
-
const view = dependencies.view ?? createRuntimeView(
|
|
4385
|
-
browser.document,
|
|
4386
|
-
config.shortcut,
|
|
4387
|
-
config.ai,
|
|
4388
|
-
config.locale,
|
|
4389
|
-
config.editor
|
|
4390
|
-
);
|
|
4333
|
+
const view = dependencies.view ?? createRuntimeView(browser.document, config.shortcut, config.ai, config.locale);
|
|
4391
4334
|
const api = dependencies.api ?? createRuntimeApi({
|
|
4392
4335
|
apiBase: config.apiBase,
|
|
4393
4336
|
fetch: browser.window.fetch.bind(browser.window),
|
|
@@ -4926,24 +4869,18 @@ ${summary}`;
|
|
|
4926
4869
|
const selectionRevision = sessionRevision;
|
|
4927
4870
|
const requestRevision = ++editorRequestRevision;
|
|
4928
4871
|
transition({ type: "OPEN_EDITOR" });
|
|
4929
|
-
|
|
4930
|
-
view.renderEditorStatus("opening", openingMessage);
|
|
4931
|
-
view.announce(openingMessage);
|
|
4872
|
+
view.renderEditorStatus("opening");
|
|
4932
4873
|
void api.openEditor({
|
|
4933
4874
|
fileId: marker.fileId,
|
|
4934
4875
|
line: marker.line,
|
|
4935
4876
|
column: marker.column
|
|
4936
|
-
}).then((
|
|
4877
|
+
}).then(() => {
|
|
4937
4878
|
if (mounted && state.status === "selected" && selectionRevision === sessionRevision && requestRevision === editorRequestRevision && activeTargetId === current.id && targets.includes(current)) {
|
|
4938
|
-
|
|
4939
|
-
view.renderEditorStatus("success", message);
|
|
4940
|
-
view.announce(message);
|
|
4879
|
+
view.renderEditorStatus("success");
|
|
4941
4880
|
}
|
|
4942
4881
|
}).catch(() => {
|
|
4943
4882
|
if (mounted && state.status === "selected" && selectionRevision === sessionRevision && requestRevision === editorRequestRevision && activeTargetId === current.id && targets.includes(current)) {
|
|
4944
|
-
|
|
4945
|
-
view.renderEditorStatus("error", message);
|
|
4946
|
-
view.announce(message);
|
|
4883
|
+
view.renderEditorStatus("error");
|
|
4947
4884
|
}
|
|
4948
4885
|
});
|
|
4949
4886
|
}
|