@kortix/ui 0.14.15 → 0.14.17
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/_vendor/shared/artifact-annotations.d.ts +126 -1
- package/dist/_vendor/shared/artifact-comments.d.ts +30 -1
- package/dist/_vendor/shared/channel-descriptors.d.ts +5 -1
- package/dist/customize/settings/tabs/experimental-tab.js +1 -4
- package/dist/customize/shared/channels-switch-dialog.d.ts +4 -8
- package/dist/customize/shared/channels-switch-dialog.js +5 -16
- package/dist/customize/shared/feature-gate-screen.js +5 -7
- package/dist/files/drives/drive-path-param.d.ts +4 -0
- package/dist/files/drives/drive-path-param.js +50 -0
- package/dist/files/index.d.ts +1 -0
- package/dist/files/index.js +1 -0
- package/dist/i18n/en.d.ts +48 -18
- package/dist/i18n/en.js +62 -32
- package/dist/internal/lib/use-project-feature-flags.js +0 -2
- package/dist/internal/lib/utils/kortix-system-tags.d.ts +2 -8
- package/dist/internal/lib/utils/kortix-system-tags.js +4 -58
- package/dist/markdown/doc-editor/doc-menus.d.ts +6 -0
- package/dist/markdown/doc-editor/doc-menus.js +74 -9
- package/dist/session/status/provisioning-failure.d.ts +22 -1
- package/dist/session/status/provisioning-failure.js +35 -7
- package/dist/session/status/session-starting-loader.js +15 -5
- package/dist/session/tool/tools/kortix-tool-card.d.ts +4 -81
- package/dist/session/tool/tools/kortix-tool-card.js +4 -184
- package/dist/session/tool/tools/workflow-run.d.ts +4 -126
- package/dist/session/tool/tools/workflow-run.js +4 -249
- package/dist/session/turn/subagent-notice.d.ts +4 -56
- package/dist/session/turn/subagent-notice.js +4 -109
- package/dist/styles.css +1 -1
- package/dist/workspace/sidebar/project-session-list.js +13 -26
- package/dist/workspace/sidebar/session-brief-hover-card.d.ts +0 -3
- package/dist/workspace/sidebar/session-brief-hover-card.js +0 -3
- package/package.json +3 -3
- package/skills/kortix-ui/references/modules.md +1 -1
package/dist/i18n/en.js
CHANGED
|
@@ -773,10 +773,6 @@ const catalog = {
|
|
|
773
773
|
"name": "Marketplace",
|
|
774
774
|
"description": "Browse and install skills from community and vendor registries. Sources, updates, and team scopes are still changing."
|
|
775
775
|
},
|
|
776
|
-
"meta_agent": {
|
|
777
|
-
"name": "My Kortix",
|
|
778
|
-
"description": "My Kortix, the one agent you talk to. It routes each task to the agent made for it and runs it, with your permissions. The project setting is `builtin_agents.my_kortix` in kortix.yaml; this switch applies only when that key is not set."
|
|
779
|
-
},
|
|
780
776
|
"warm_sessions": {
|
|
781
777
|
"name": "Warm Sessions",
|
|
782
778
|
"description": "Keep one sandbox ready for instant session starts. The idle sandbox uses compute."
|
|
@@ -805,14 +801,6 @@ const catalog = {
|
|
|
805
801
|
"name": "Composio event triggers",
|
|
806
802
|
"description": "Start an agent when something happens in a connected app: a new email, a pull request, a calendar event. Events come from Composio. Kortix also checks your connected apps itself."
|
|
807
803
|
},
|
|
808
|
-
"volumes": {
|
|
809
|
-
"name": "Volumes",
|
|
810
|
-
"description": "Shared Files for this project."
|
|
811
|
-
},
|
|
812
|
-
"drives": {
|
|
813
|
-
"name": "Drive",
|
|
814
|
-
"description": "Shared folders that stay in sync with sessions: your own drive, one per agent, and company drives an admin attaches to the project. New sessions see them under /drives."
|
|
815
|
-
},
|
|
816
804
|
"session_log_restore": {
|
|
817
805
|
"name": "Session log restore",
|
|
818
806
|
"description": "Rebuilds a session from its saved session log when its computer lost the conversation. Kortix enables it per project."
|
|
@@ -1394,6 +1382,17 @@ const catalog = {
|
|
|
1394
1382
|
"label": "Restart session",
|
|
1395
1383
|
"pending": "Restarting…",
|
|
1396
1384
|
"ownerOnly": "Only the session owner or a project manager can restart this session."
|
|
1385
|
+
},
|
|
1386
|
+
"image": {
|
|
1387
|
+
"title": "Preparing the sandbox image",
|
|
1388
|
+
"states": {
|
|
1389
|
+
"resolving": "Choosing the image for this session.",
|
|
1390
|
+
"serving_last_ready": "Starting from the last ready image. The new one builds in the background.",
|
|
1391
|
+
"waiting_for_build": "The first image for this project is building. The session starts when it is ready.",
|
|
1392
|
+
"building": "Building the first image for this project. This happens once and takes a few minutes.",
|
|
1393
|
+
"copying_to_region": "Copying the image to this session's region.",
|
|
1394
|
+
"waiting_for_provider": "The image is finishing. The session starts when it is ready."
|
|
1395
|
+
}
|
|
1397
1396
|
}
|
|
1398
1397
|
},
|
|
1399
1398
|
"sessionDelete": {
|
|
@@ -7457,23 +7456,23 @@ const catalog = {
|
|
|
7457
7456
|
"addAccess": "Add a person, team or agent",
|
|
7458
7457
|
"notGrantable": "This folder holds the tree together and can't be shared. Share a folder inside it.",
|
|
7459
7458
|
"viewOnlyAccess": "Only people who can share this folder can change who has access.",
|
|
7460
|
-
"noGrants": "Nobody has been given access here yet. Project
|
|
7459
|
+
"noGrants": "Nobody has been given access here yet. Project admins can open every folder.",
|
|
7461
7460
|
"myFolder": "My folder",
|
|
7462
|
-
"myFolderHint": "Your own folder:
|
|
7461
|
+
"myFolderHint": "Your own folder: only you and the project's admins can open it, and it is your desktop in your sessions",
|
|
7463
7462
|
"sharedWithMeHint": "Folders other people shared with you",
|
|
7464
7463
|
"sessionNoFolders": "No folders are mounted in this session.",
|
|
7465
7464
|
"folderAccessDescription": "Choose who can open this folder and everything in it. A session gets the folder when its agent, its project or the person who started it has access.",
|
|
7466
7465
|
"whoCanAccess": "Who can access",
|
|
7467
7466
|
"whoCanAccessFolder": "Who can access {name}",
|
|
7468
7467
|
"accessPanelDescription": "People, teams and agents with access get this folder and everything in it.",
|
|
7469
|
-
"accessPanelRoot": "Open a folder to choose who can access it. Company is shared with everyone in the project
|
|
7468
|
+
"accessPanelRoot": "Open a folder to choose who can access it. Company is shared with everyone in the project. Each person's own folder opens for them and the project's admins.",
|
|
7470
7469
|
"audienceEveryoneDescription": "Everyone who works in this project, and every session in it.",
|
|
7471
7470
|
"audienceAdmins": "Admins only",
|
|
7472
7471
|
"audienceAdminsShort": "Project managers can open and share it",
|
|
7473
7472
|
"audienceAdminsDescription": "Project managers can open and share it. No session gets it until you share it.",
|
|
7474
7473
|
"audienceOnlyYou": "Only you",
|
|
7475
7474
|
"audienceOnlyOwner": "Only {name}",
|
|
7476
|
-
"audienceOwnerDescription": "A person's own folder
|
|
7475
|
+
"audienceOwnerDescription": "A person's own folder opens for them and the project's admins. Each time an admin opens it, its owner can see that.",
|
|
7477
7476
|
"audienceSpecific": "Specific people, teams or agents",
|
|
7478
7477
|
"audienceSpecificDescription": "Only the people, teams and agents you pick, plus project managers. An agent gets the folder in every one of its sessions.",
|
|
7479
7478
|
"inheritedEveryoneNote": "Everyone in this project already has access through {path}. Change it there to narrow it.",
|
|
@@ -7499,7 +7498,6 @@ const catalog = {
|
|
|
7499
7498
|
"audienceQuestion": "Who can open it?",
|
|
7500
7499
|
"badgeEveryone": "Everyone",
|
|
7501
7500
|
"badgePeople": "{count, plural, one {# person} other {# people}}",
|
|
7502
|
-
"privateNote": "Only you can open My files, not even admins. Share a folder to give someone access.",
|
|
7503
7501
|
"noTeamFolders": "No team folders yet.",
|
|
7504
7502
|
"sessionFilesName": "Files",
|
|
7505
7503
|
"sessionFilesHint": "Folders it can open",
|
|
@@ -7524,7 +7522,21 @@ const catalog = {
|
|
|
7524
7522
|
"accountStorageTitle": "Files storage",
|
|
7525
7523
|
"accountStorageDescription": "What each project's Files hold. Your plan allows {project} per project and {account} across all projects.",
|
|
7526
7524
|
"accountStorageEmpty": "No project holds files yet.",
|
|
7527
|
-
"accountStorageIncomplete": "Some projects could not be measured right now."
|
|
7525
|
+
"accountStorageIncomplete": "Some projects could not be measured right now.",
|
|
7526
|
+
"folderInfo": {
|
|
7527
|
+
"audienceYouAndAdmins": "You and project admins",
|
|
7528
|
+
"audienceOwnerAndAdmins": "Owner and admins",
|
|
7529
|
+
"boxPathHint": "Where sessions see this folder. Click to copy.",
|
|
7530
|
+
"pathCopied": "Copied",
|
|
7531
|
+
"projectAdmins": "Project admins",
|
|
7532
|
+
"adminsOpenRecorded": "Can open it. You see each time they do.",
|
|
7533
|
+
"openedByAdmins": "Opened by admins",
|
|
7534
|
+
"noAdminOpens": "No admin has opened this folder."
|
|
7535
|
+
},
|
|
7536
|
+
"folderTree": "Folders",
|
|
7537
|
+
"treeYou": "{name} (You)",
|
|
7538
|
+
"treeExpand": "Open {name}",
|
|
7539
|
+
"treeCollapse": "Close {name}"
|
|
7528
7540
|
},
|
|
7529
7541
|
"genui": {
|
|
7530
7542
|
"showData": "Show data",
|
|
@@ -7604,8 +7616,8 @@ const catalog = {
|
|
|
7604
7616
|
"listPlaceholder": "value 1, value 2"
|
|
7605
7617
|
},
|
|
7606
7618
|
"triggerAutoPause": {
|
|
7607
|
-
"title": "Paused
|
|
7608
|
-
"description": "It
|
|
7619
|
+
"title": "Paused automatically",
|
|
7620
|
+
"description": "It stopped starting runs for the reason below. Fix the cause, then resume it."
|
|
7609
7621
|
},
|
|
7610
7622
|
"featureGate": {
|
|
7611
7623
|
"enable": "Enable {name}",
|
|
@@ -8343,7 +8355,7 @@ const catalog = {
|
|
|
8343
8355
|
"edit": "Edit",
|
|
8344
8356
|
"delete": "Delete",
|
|
8345
8357
|
"deleteTitle": "Delete comment?",
|
|
8346
|
-
"deleteDescription": "
|
|
8358
|
+
"deleteDescription": "Its text is removed for everyone, and “Comment deleted” stays in its place. This cannot be undone.",
|
|
8347
8359
|
"commentDeleted": "Comment deleted",
|
|
8348
8360
|
"threadDeleted": "This thread was deleted.",
|
|
8349
8361
|
"resolve": "Resolve",
|
|
@@ -8354,9 +8366,6 @@ const catalog = {
|
|
|
8354
8366
|
"quoteLabel": "Selected passage",
|
|
8355
8367
|
"waitingForPerson": "Waiting for a person",
|
|
8356
8368
|
"deliveryFailed": "Could not send feedback to the agent.",
|
|
8357
|
-
"sendToAgent": "Send to agent ({count})",
|
|
8358
|
-
"sendExisting": "This Artifact’s session",
|
|
8359
|
-
"sendNew": "A new {agent} session",
|
|
8360
8369
|
"sendFailed": "Could not send these comments. Try again.",
|
|
8361
8370
|
"retrySend": "Retry send ({count})",
|
|
8362
8371
|
"discardSend": "Discard and use latest comments",
|
|
@@ -8369,8 +8378,9 @@ const catalog = {
|
|
|
8369
8378
|
"contextLoadError": "Could not load comment permissions.",
|
|
8370
8379
|
"activityLoadError": "Could not load activity.",
|
|
8371
8380
|
"retry": "Try again",
|
|
8381
|
+
"sendAgainTo": "Send again to {agent}",
|
|
8372
8382
|
"noComments": "No open comments",
|
|
8373
|
-
"noCommentsHint": "Select a passage or
|
|
8383
|
+
"noCommentsHint": "Select a passage to comment on it, or start a new comment.",
|
|
8374
8384
|
"noResolved": "No resolved comments",
|
|
8375
8385
|
"noResolvedHint": "Resolved threads appear here.",
|
|
8376
8386
|
"noAllComments": "No comments yet",
|
|
@@ -8387,7 +8397,7 @@ const catalog = {
|
|
|
8387
8397
|
"preparingSelection": "Preparing selected passage…",
|
|
8388
8398
|
"selectionCaptureFailed": "Could not prepare the selected passage. Discard it to leave a whole-Artifact comment.",
|
|
8389
8399
|
"commentSelection": "Comment",
|
|
8390
|
-
"selectionTooLong": "
|
|
8400
|
+
"selectionTooLong": "This passage is too long to comment on. Select {max} characters or fewer.",
|
|
8391
8401
|
"selectionUnavailable": "This passage cannot be anchored. Select another passage.",
|
|
8392
8402
|
"snapshotChanged": "The document changed. Reload it before commenting.",
|
|
8393
8403
|
"commentSaveFailed": "Could not save the document. Try again before commenting.",
|
|
@@ -8406,7 +8416,7 @@ const catalog = {
|
|
|
8406
8416
|
"sent_to_agent": "sent feedback to an agent"
|
|
8407
8417
|
},
|
|
8408
8418
|
"person": "Person",
|
|
8409
|
-
"deleteRootDescription": "
|
|
8419
|
+
"deleteRootDescription": "Its text is removed for everyone, and the thread becomes read-only. This cannot be undone.",
|
|
8410
8420
|
"showPanel": "Show comments",
|
|
8411
8421
|
"hidePanel": "Hide comments",
|
|
8412
8422
|
"panelTitle": "Comments and activity",
|
|
@@ -8428,7 +8438,29 @@ const catalog = {
|
|
|
8428
8438
|
"screenshotReadFailed": "Could not load the screenshot.",
|
|
8429
8439
|
"screenshotMissing": "Screenshot unavailable. The drawing is saved.",
|
|
8430
8440
|
"screenshotCaptureFailed": "Could not capture a screenshot. Your comment will include the drawing without an image.",
|
|
8431
|
-
"sendScreenshotLimit": "
|
|
8441
|
+
"sendScreenshotLimit": "Could not send these comments. Their screenshots exceed the limit for one request. Send fewer threads with drawings.",
|
|
8442
|
+
"agentsUnavailable": "Could not load agents.",
|
|
8443
|
+
"showMore": "Show more",
|
|
8444
|
+
"showLess": "Show less",
|
|
8445
|
+
"moreReplies": "{count, plural, one {# more reply} other {# more replies}}",
|
|
8446
|
+
"resolvedBy": "Resolved by {name}",
|
|
8447
|
+
"agent": "Agent",
|
|
8448
|
+
"threadResolved": "Thread resolved",
|
|
8449
|
+
"undo": "Undo",
|
|
8450
|
+
"agentPending": "Sending to agent…",
|
|
8451
|
+
"agentSent": "Sent to agent",
|
|
8452
|
+
"openSession": "Open session",
|
|
8453
|
+
"notDelivered": "Not delivered",
|
|
8454
|
+
"sendThreads": "{count, plural, one {Send # open thread to {agent}} other {Send # open threads to {agent}}}",
|
|
8455
|
+
"chooseAgent": "Choose agent",
|
|
8456
|
+
"sentToAgent": "Comments sent to {agent}",
|
|
8457
|
+
"newCommentFrom": "New comment from {name}",
|
|
8458
|
+
"newComments": "{count, plural, one {# new comment} other {# new comments}}",
|
|
8459
|
+
"filterLabel": "Thread status",
|
|
8460
|
+
"pagePinLabel": "Comment {number}",
|
|
8461
|
+
"showPanelCount": "Show comments, {count} open",
|
|
8462
|
+
"hidePanelCount": "Hide comments, {count} open",
|
|
8463
|
+
"commentSelectionHint": "Comment on the selection"
|
|
8432
8464
|
},
|
|
8433
8465
|
"insertMedia": "Image or video…",
|
|
8434
8466
|
"diagram": "Diagram",
|
|
@@ -9070,10 +9102,8 @@ const catalog = {
|
|
|
9070
9102
|
"memoryNoteChannel": "What agents in {place} remember. Agents read this at the start of every thread.",
|
|
9071
9103
|
"memoryNoteDm": "What {agent} remembers from this DM. It reads this at the start of every thread.",
|
|
9072
9104
|
"off": {
|
|
9073
|
-
"title": "
|
|
9074
|
-
"description": "Files and memory for {place} live in Drive.
|
|
9075
|
-
"descriptionMember": "Files and memory for {place} live in Drive. Ask a project admin to turn it on.",
|
|
9076
|
-
"action": "Open feature flags"
|
|
9105
|
+
"title": "No Drive here",
|
|
9106
|
+
"description": "Files and memory for {place} live in the Drive. This Kortix stores no Drive: it needs Platinum."
|
|
9077
9107
|
}
|
|
9078
9108
|
},
|
|
9079
9109
|
"onboarding": {
|
|
@@ -22,7 +22,6 @@ import { useFeatureFlag } from '@kortix/sdk/react';
|
|
|
22
22
|
*/
|
|
23
23
|
export function useProjectFeatureFlags(projectId) {
|
|
24
24
|
const marketplace = useFeatureFlag(projectId, 'marketplace');
|
|
25
|
-
const metaAgent = useFeatureFlag(projectId, 'meta_agent');
|
|
26
25
|
const reminders = useFeatureFlag(projectId, 'reminders');
|
|
27
26
|
const warmSessions = useFeatureFlag(projectId, 'warm_sessions');
|
|
28
27
|
const secretsEgress = useFeatureFlag(projectId, 'secrets_egress');
|
|
@@ -47,7 +46,6 @@ export function useProjectFeatureFlags(projectId) {
|
|
|
47
46
|
return {
|
|
48
47
|
flags: {
|
|
49
48
|
marketplace: marketplace.enabled,
|
|
50
|
-
meta_agent: metaAgent.enabled,
|
|
51
49
|
reminders: reminders.enabled,
|
|
52
50
|
warm_sessions: warmSessions.enabled,
|
|
53
51
|
secrets_egress: secretsEgress.enabled,
|
|
@@ -2,14 +2,8 @@
|
|
|
2
2
|
import type { UiTranslator } from '../../../i18n/index.js';
|
|
3
3
|
/** Removes every `<kortix_system …>…</kortix_system>` block, in any ASCII case. */
|
|
4
4
|
export declare function stripKortixSystemTags(text: string): string;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
status: 'COMPLETE' | 'FAILED';
|
|
8
|
-
project: string;
|
|
9
|
-
prompt: string;
|
|
10
|
-
result: string;
|
|
11
|
-
}
|
|
12
|
-
export declare function extractSessionReport(text: string): SessionReport | null;
|
|
5
|
+
/** The parser lives in `@kortix/sdk` (`core/turns/session-report.ts`). */
|
|
6
|
+
export { extractSessionReport, type SessionReport } from '@kortix/sdk';
|
|
13
7
|
/**
|
|
14
8
|
* Check if a user message text is purely a kortix_system message
|
|
15
9
|
* (no visible user content outside the tags).
|
|
@@ -6,7 +6,7 @@ import { indexOfIgnoreCase, removeSpans, tagBlocks } from '../../../_vendor/kort
|
|
|
6
6
|
* state, PTY output, etc.) in <kortix_system type="..." source="..."> tags.
|
|
7
7
|
*
|
|
8
8
|
* - stripKortixSystemTags: removes ALL tags before markdown rendering
|
|
9
|
-
* - extractSessionReport: parses session-report tags
|
|
9
|
+
* - extractSessionReport: parses session-report tags (re-exported from `@kortix/sdk`)
|
|
10
10
|
*
|
|
11
11
|
* Nothing here runs a regex over the message. The regexes these functions used
|
|
12
12
|
* were quadratic or cubic in the text — extracting system messages from 60k
|
|
@@ -21,63 +21,9 @@ export function stripKortixSystemTags(text) {
|
|
|
21
21
|
return '';
|
|
22
22
|
return removeSpans(text, tagBlocks(text, 'kortix_system', { attributes: 'any', ignoreCase: true })).trim();
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const xml = sessionReportXml(text);
|
|
28
|
-
if (xml === null)
|
|
29
|
-
return null;
|
|
30
|
-
const get = (tag) => tagBlocks(xml, tag, { limit: 1 })[0]?.body.trim() || '';
|
|
31
|
-
return {
|
|
32
|
-
sessionId: get('session-id'),
|
|
33
|
-
status: get('status') === 'FAILED' ? 'FAILED' : 'COMPLETE',
|
|
34
|
-
project: get('project'),
|
|
35
|
-
prompt: get('prompt'),
|
|
36
|
-
result: get('result'),
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* The text between `<session-report>` and `</session-report>` after the first
|
|
41
|
-
* `<kortix_system …>` tag that holds `type="session-report"`, with a closing
|
|
42
|
-
* `</kortix_system>` after it — what
|
|
43
|
-
* `/<kortix_system[^>]*type="session-report"[^>]*>[\s\S]*?<session-report>([\s\S]*?)<\/session-report>[\s\S]*?<\/kortix_system>/i`
|
|
44
|
-
* captured. That regex was cubic: 7.6 s at 60k characters.
|
|
45
|
-
*/
|
|
46
|
-
function sessionReportXml(text) {
|
|
47
|
-
const marker = 'type="session-report"';
|
|
48
|
-
let from = 0;
|
|
49
|
-
// The first marker at or after the last position searched from; -2 until searched.
|
|
50
|
-
let markerAt = -2;
|
|
51
|
-
for (;;) {
|
|
52
|
-
const open = indexOfIgnoreCase(text, OPEN, from);
|
|
53
|
-
if (open === -1)
|
|
54
|
-
return null;
|
|
55
|
-
const attrs = open + OPEN.length;
|
|
56
|
-
const gt = text.indexOf('>', attrs);
|
|
57
|
-
if (gt === -1)
|
|
58
|
-
return null;
|
|
59
|
-
if (markerAt < attrs)
|
|
60
|
-
markerAt = indexOfIgnoreCase(text, marker, attrs);
|
|
61
|
-
if (markerAt === -1)
|
|
62
|
-
return null;
|
|
63
|
-
// The marker lies past this tag. Every opener before `gt` shares this tag's
|
|
64
|
-
// attributes, so none of them holds the marker either.
|
|
65
|
-
if (markerAt > gt) {
|
|
66
|
-
from = gt;
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
// Each search below failing means no later opener can succeed: its search starts later still.
|
|
70
|
-
const start = indexOfIgnoreCase(text, '<session-report>', gt + 1);
|
|
71
|
-
if (start === -1)
|
|
72
|
-
return null;
|
|
73
|
-
const stop = indexOfIgnoreCase(text, '</session-report>', start + 16);
|
|
74
|
-
if (stop === -1)
|
|
75
|
-
return null;
|
|
76
|
-
if (indexOfIgnoreCase(text, CLOSE, stop + 17) === -1)
|
|
77
|
-
return null;
|
|
78
|
-
return text.slice(start + 16, stop);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
24
|
+
// ── Session Report extraction ────────────────────────────────────────────────
|
|
25
|
+
/** The parser lives in `@kortix/sdk` (`core/turns/session-report.ts`). */
|
|
26
|
+
export { extractSessionReport } from '@kortix/sdk';
|
|
81
27
|
/**
|
|
82
28
|
* Check if a user message text is purely a kortix_system message
|
|
83
29
|
* (no visible user content outside the tags).
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { type Editor } from '@tiptap/react';
|
|
2
|
+
/**
|
|
3
|
+
* ⌘⌥M on a Mac, Ctrl+Alt+M elsewhere: comment on the selected text (the
|
|
4
|
+
* Google Docs key). Matched by the physical key too: ⌥M types `µ` on a Mac,
|
|
5
|
+
* and Windows treats Ctrl+Alt as AltGr, so `key` is often not `m`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isCommentShortcut(event: Pick<KeyboardEvent, 'key' | 'code' | 'metaKey' | 'ctrlKey' | 'altKey' | 'shiftKey' | 'repeat'>, mac: boolean): boolean;
|
|
2
8
|
export declare function DocMenus({ editor, blockMenu, editable, canComment, commenting, onComment, }: {
|
|
3
9
|
editor: Editor;
|
|
4
10
|
blockMenu?: boolean;
|
|
@@ -1,23 +1,62 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx,
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
/**
|
|
4
4
|
* The document editor's two menus: one over selected text (marks, headings,
|
|
5
5
|
* quote, table rows) and a `+` menu on an empty line (blocks). Markdown
|
|
6
6
|
* shortcuts (`# `, `- `, `1. `, `[ ] `, `> `, ``` ```) work without them.
|
|
7
7
|
* `blockMenu={false}` drops the `+` menu, for an editor with a `/` block menu.
|
|
8
|
-
* `canComment`
|
|
9
|
-
* it is the only button
|
|
8
|
+
* `canComment` puts a labeled Comment button first over selected text (with
|
|
9
|
+
* `editable={false}` it is the only button) and turns on its shortcut, ⌘⌥M on
|
|
10
|
+
* a Mac and Ctrl+Alt+M elsewhere.
|
|
10
11
|
*/
|
|
11
12
|
import { ChatCircleIcon, CheckSquareIcon, CodeBlockIcon, CodeIcon, LinkSimpleIcon, ListBulletsIcon, ListNumbersIcon, MinusIcon, PlusIcon, QuotesIcon, TableIcon, TextBIcon, TextHOneIcon, TextHThreeIcon, TextHTwoIcon, TextItalicIcon, TextStrikethroughIcon, TrashIcon, } from '@phosphor-icons/react';
|
|
12
13
|
import { TextSelection } from '@tiptap/pm/state';
|
|
13
14
|
import { useEditorState } from '@tiptap/react';
|
|
14
15
|
import { BubbleMenu, FloatingMenu } from '@tiptap/react/menus';
|
|
16
|
+
import { useEffect, useRef, useState } from 'react';
|
|
15
17
|
import { useTranslations } from '../../i18n/index.js';
|
|
16
18
|
import { Button } from '../../primitives/button.js';
|
|
17
19
|
import Hint from '../../primitives/hint.js';
|
|
20
|
+
import { Kbd, KbdGroup } from '../../primitives/kbd.js';
|
|
21
|
+
import Loading from '../../primitives/loading.js';
|
|
22
|
+
const isMac = () => typeof navigator !== 'undefined' && /Mac|iPhone|iPad/.test(navigator.platform);
|
|
23
|
+
/**
|
|
24
|
+
* ⌘⌥M on a Mac, Ctrl+Alt+M elsewhere: comment on the selected text (the
|
|
25
|
+
* Google Docs key). Matched by the physical key too: ⌥M types `µ` on a Mac,
|
|
26
|
+
* and Windows treats Ctrl+Alt as AltGr, so `key` is often not `m`.
|
|
27
|
+
*/
|
|
28
|
+
export function isCommentShortcut(event, mac) {
|
|
29
|
+
if (!event.altKey || event.shiftKey || event.repeat)
|
|
30
|
+
return false;
|
|
31
|
+
if (mac ? !event.metaKey || event.ctrlKey : !event.ctrlKey || event.metaKey)
|
|
32
|
+
return false;
|
|
33
|
+
return event.code === 'KeyM' || event.key.toLowerCase() === 'm';
|
|
34
|
+
}
|
|
35
|
+
/** Selected text a comment can quote: a non-blank text range, not an image or a video. */
|
|
36
|
+
function commentableSelection(editor, state) {
|
|
37
|
+
const { selection } = state;
|
|
38
|
+
return (selection instanceof TextSelection &&
|
|
39
|
+
selection.from !== selection.to &&
|
|
40
|
+
!!state.doc.textBetween(selection.from, selection.to).trim() &&
|
|
41
|
+
!editor.isActive('image') &&
|
|
42
|
+
!editor.isActive('video'));
|
|
43
|
+
}
|
|
18
44
|
function MenuButton({ icon: IconCmp, label, active, onClick, disabled, }) {
|
|
19
45
|
return (_jsx(Hint, { label: label, side: "top", sideOffset: 6, children: _jsx(Button, { type: "button", size: "icon-sm", variant: "ghost", "aria-label": label, "aria-pressed": active, "aria-busy": disabled || undefined, disabled: disabled, onMouseDown: (e) => e.preventDefault(), onClick: onClick, className: "data-[active=true]:bg-active data-[active=true]:text-foreground text-muted-foreground", "data-active": active || undefined, children: _jsx(IconCmp, { className: "size-4" }) }) }));
|
|
20
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* The first item over selected text: a labeled button, so a first-time reader
|
|
49
|
+
* finds comments. Its hint closes with the menu: the shortcut hides the menu
|
|
50
|
+
* under a still pointer, and an open hint would lose its anchor.
|
|
51
|
+
*/
|
|
52
|
+
function CommentButton({ label, busy, shown, onClick, }) {
|
|
53
|
+
const [mac] = useState(isMac);
|
|
54
|
+
const [hint, setHint] = useState(false);
|
|
55
|
+
if (hint && !shown)
|
|
56
|
+
setHint(false);
|
|
57
|
+
const keys = mac ? ['⌘', '⌥', 'M'] : ['Ctrl', 'Alt', 'M'];
|
|
58
|
+
return (_jsx(Hint, { open: hint && shown && !busy, onOpenChange: setHint, side: "top", sideOffset: 6, label: _jsxs("span", { className: "flex items-center gap-1.5", children: [label, _jsx(KbdGroup, { children: keys.map((key) => (_jsx(Kbd, { className: "h-4 w-auto min-w-4", children: key }, key))) })] }), children: _jsxs(Button, { type: "button", size: "xs", variant: "ghost", "aria-keyshortcuts": mac ? 'Meta+Alt+M' : 'Control+Alt+M', "aria-busy": busy || undefined, disabled: busy, onMouseDown: (e) => e.preventDefault(), onClick: onClick, children: [busy ? _jsx(Loading, { className: "size-4" }) : _jsx(ChatCircleIcon, { className: "size-4" }), label] }) }));
|
|
59
|
+
}
|
|
21
60
|
const MENU = 'bg-popover text-popover-foreground flex items-center gap-0.5 rounded-lg border p-1 shadow-md';
|
|
22
61
|
export function DocMenus({ editor, blockMenu = true, editable = true, canComment = false, commenting = false, onComment, }) {
|
|
23
62
|
const t = useTranslations('artifacts');
|
|
@@ -36,6 +75,37 @@ export function DocMenus({ editor, blockMenu = true, editable = true, canComment
|
|
|
36
75
|
table: e.isActive('table'),
|
|
37
76
|
}),
|
|
38
77
|
});
|
|
78
|
+
// ⌘⌥M / Ctrl+Alt+M comments on the selection in this editor, while comments are on.
|
|
79
|
+
const comment = useRef({ onComment, commenting });
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
comment.current = { onComment, commenting };
|
|
82
|
+
});
|
|
83
|
+
const commentsOn = canComment && !!onComment;
|
|
84
|
+
// One options object for the menu's life: it reports when the menu shows and hides.
|
|
85
|
+
const [bubbleShown, setBubbleShown] = useState(false);
|
|
86
|
+
const [bubbleOptions] = useState(() => ({
|
|
87
|
+
placement: 'top',
|
|
88
|
+
onShow: () => setBubbleShown(true),
|
|
89
|
+
onHide: () => setBubbleShown(false),
|
|
90
|
+
}));
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
if (!commentsOn)
|
|
93
|
+
return;
|
|
94
|
+
const mac = isMac();
|
|
95
|
+
const onKey = (event) => {
|
|
96
|
+
const { onComment: run, commenting: busy } = comment.current;
|
|
97
|
+
if (event.defaultPrevented || !run || !isCommentShortcut(event, mac))
|
|
98
|
+
return;
|
|
99
|
+
const selected = editor.view.dom.ownerDocument.getSelection()?.anchorNode;
|
|
100
|
+
if (!selected || !editor.view.dom.contains(selected) || !commentableSelection(editor, editor.state))
|
|
101
|
+
return;
|
|
102
|
+
event.preventDefault();
|
|
103
|
+
if (!busy)
|
|
104
|
+
run();
|
|
105
|
+
};
|
|
106
|
+
window.addEventListener('keydown', onKey);
|
|
107
|
+
return () => window.removeEventListener('keydown', onKey);
|
|
108
|
+
}, [editor, commentsOn]);
|
|
39
109
|
const chain = () => editor.chain().focus();
|
|
40
110
|
const setLink = () => {
|
|
41
111
|
const previous = editor.getAttributes('link').href;
|
|
@@ -47,10 +117,5 @@ export function DocMenus({ editor, blockMenu = true, editable = true, canComment
|
|
|
47
117
|
else
|
|
48
118
|
chain().extendMarkRange('link').setLink({ href: url.trim() }).run();
|
|
49
119
|
};
|
|
50
|
-
return (_jsxs(_Fragment, { children: [_jsx(BubbleMenu, { editor: editor, options: {
|
|
51
|
-
s.selection instanceof TextSelection &&
|
|
52
|
-
from !== to &&
|
|
53
|
-
!!s.doc.textBetween(from, to).trim() &&
|
|
54
|
-
!e.isActive('image') &&
|
|
55
|
-
!e.isActive('video'), children: _jsxs("div", { className: MENU, children: [editable ? (_jsxs(_Fragment, { children: [_jsx(MenuButton, { icon: TextBIcon, label: t('bold'), active: state.bold, onClick: () => chain().toggleBold().run() }), _jsx(MenuButton, { icon: TextItalicIcon, label: t('italic'), active: state.italic, onClick: () => chain().toggleItalic().run() }), _jsx(MenuButton, { icon: TextStrikethroughIcon, label: t('strike'), active: state.strike, onClick: () => chain().toggleStrike().run() }), _jsx(MenuButton, { icon: CodeIcon, label: t('inlineCode'), active: state.code, onClick: () => chain().toggleCode().run() }), _jsx(MenuButton, { icon: LinkSimpleIcon, label: t('link'), active: state.link, onClick: setLink }), _jsx("span", { className: "bg-border mx-0.5 h-5 w-px" }), _jsx(MenuButton, { icon: TextHOneIcon, label: t('heading1'), active: state.h1, onClick: () => chain().toggleHeading({ level: 1 }).run() }), _jsx(MenuButton, { icon: TextHTwoIcon, label: t('heading2'), active: state.h2, onClick: () => chain().toggleHeading({ level: 2 }).run() }), _jsx(MenuButton, { icon: TextHThreeIcon, label: t('heading3'), active: state.h3, onClick: () => chain().toggleHeading({ level: 3 }).run() }), _jsx(MenuButton, { icon: QuotesIcon, label: t('quote'), active: state.quote, onClick: () => chain().toggleBlockquote().run() }), state.table ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "bg-border mx-0.5 h-5 w-px" }), _jsx(MenuButton, { icon: PlusIcon, label: t('addRow'), onClick: () => chain().addRowAfter().run() }), _jsx(MenuButton, { icon: ListBulletsIcon, label: t('addColumn'), onClick: () => chain().addColumnAfter().run() }), _jsx(MenuButton, { icon: MinusIcon, label: t('deleteRow'), onClick: () => chain().deleteRow().run() }), _jsx(MenuButton, { icon: TrashIcon, label: t('deleteTable'), onClick: () => chain().deleteTable().run() })] })) : null] })) : null, canComment && onComment ? (_jsxs(_Fragment, { children: [editable ? _jsx("span", { className: "bg-border mx-0.5 h-5 w-px" }) : null, _jsx(MenuButton, { icon: ChatCircleIcon, label: t('discussion.commentSelection'), onClick: onComment, disabled: commenting })] })) : null] }) }), editable && blockMenu ? (_jsx(FloatingMenu, { editor: editor, options: { placement: 'bottom-start', offset: 6 }, children: _jsxs("div", { className: MENU, children: [_jsx(MenuButton, { icon: TextHOneIcon, label: t('heading1'), onClick: () => chain().setHeading({ level: 1 }).run() }), _jsx(MenuButton, { icon: TextHTwoIcon, label: t('heading2'), onClick: () => chain().setHeading({ level: 2 }).run() }), _jsx(MenuButton, { icon: TextHThreeIcon, label: t('heading3'), onClick: () => chain().setHeading({ level: 3 }).run() }), _jsx(MenuButton, { icon: ListBulletsIcon, label: t('bulletList'), onClick: () => chain().toggleBulletList().run() }), _jsx(MenuButton, { icon: ListNumbersIcon, label: t('numberedList'), onClick: () => chain().toggleOrderedList().run() }), _jsx(MenuButton, { icon: CheckSquareIcon, label: t('taskList'), onClick: () => chain().toggleTaskList().run() }), _jsx(MenuButton, { icon: QuotesIcon, label: t('quote'), onClick: () => chain().toggleBlockquote().run() }), _jsx(MenuButton, { icon: CodeBlockIcon, label: t('codeBlock'), onClick: () => chain().toggleCodeBlock().run() }), _jsx(MenuButton, { icon: TableIcon, label: t('table'), onClick: () => chain().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run() }), _jsx(MenuButton, { icon: MinusIcon, label: t('divider'), onClick: () => chain().setHorizontalRule().run() })] }) })) : null] }));
|
|
120
|
+
return (_jsxs(_Fragment, { children: [_jsx(BubbleMenu, { editor: editor, options: bubbleOptions, shouldShow: ({ editor: e, state: s }) => (editable || canComment) && commentableSelection(e, s), children: _jsxs("div", { className: MENU, children: [canComment && onComment ? (_jsxs(_Fragment, { children: [_jsx(CommentButton, { label: t('discussion.commentSelection'), busy: commenting, shown: bubbleShown, onClick: onComment }), editable ? _jsx("span", { className: "bg-border mx-0.5 h-5 w-px" }) : null] })) : null, editable ? (_jsxs(_Fragment, { children: [_jsx(MenuButton, { icon: TextBIcon, label: t('bold'), active: state.bold, onClick: () => chain().toggleBold().run() }), _jsx(MenuButton, { icon: TextItalicIcon, label: t('italic'), active: state.italic, onClick: () => chain().toggleItalic().run() }), _jsx(MenuButton, { icon: TextStrikethroughIcon, label: t('strike'), active: state.strike, onClick: () => chain().toggleStrike().run() }), _jsx(MenuButton, { icon: CodeIcon, label: t('inlineCode'), active: state.code, onClick: () => chain().toggleCode().run() }), _jsx(MenuButton, { icon: LinkSimpleIcon, label: t('link'), active: state.link, onClick: setLink }), _jsx("span", { className: "bg-border mx-0.5 h-5 w-px" }), _jsx(MenuButton, { icon: TextHOneIcon, label: t('heading1'), active: state.h1, onClick: () => chain().toggleHeading({ level: 1 }).run() }), _jsx(MenuButton, { icon: TextHTwoIcon, label: t('heading2'), active: state.h2, onClick: () => chain().toggleHeading({ level: 2 }).run() }), _jsx(MenuButton, { icon: TextHThreeIcon, label: t('heading3'), active: state.h3, onClick: () => chain().toggleHeading({ level: 3 }).run() }), _jsx(MenuButton, { icon: QuotesIcon, label: t('quote'), active: state.quote, onClick: () => chain().toggleBlockquote().run() }), state.table ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "bg-border mx-0.5 h-5 w-px" }), _jsx(MenuButton, { icon: PlusIcon, label: t('addRow'), onClick: () => chain().addRowAfter().run() }), _jsx(MenuButton, { icon: ListBulletsIcon, label: t('addColumn'), onClick: () => chain().addColumnAfter().run() }), _jsx(MenuButton, { icon: MinusIcon, label: t('deleteRow'), onClick: () => chain().deleteRow().run() }), _jsx(MenuButton, { icon: TrashIcon, label: t('deleteTable'), onClick: () => chain().deleteTable().run() })] })) : null] })) : null] }) }), editable && blockMenu ? (_jsx(FloatingMenu, { editor: editor, options: { placement: 'bottom-start', offset: 6 }, children: _jsxs("div", { className: MENU, children: [_jsx(MenuButton, { icon: TextHOneIcon, label: t('heading1'), onClick: () => chain().setHeading({ level: 1 }).run() }), _jsx(MenuButton, { icon: TextHTwoIcon, label: t('heading2'), onClick: () => chain().setHeading({ level: 2 }).run() }), _jsx(MenuButton, { icon: TextHThreeIcon, label: t('heading3'), onClick: () => chain().setHeading({ level: 3 }).run() }), _jsx(MenuButton, { icon: ListBulletsIcon, label: t('bulletList'), onClick: () => chain().toggleBulletList().run() }), _jsx(MenuButton, { icon: ListNumbersIcon, label: t('numberedList'), onClick: () => chain().toggleOrderedList().run() }), _jsx(MenuButton, { icon: CheckSquareIcon, label: t('taskList'), onClick: () => chain().toggleTaskList().run() }), _jsx(MenuButton, { icon: QuotesIcon, label: t('quote'), onClick: () => chain().toggleBlockquote().run() }), _jsx(MenuButton, { icon: CodeBlockIcon, label: t('codeBlock'), onClick: () => chain().toggleCodeBlock().run() }), _jsx(MenuButton, { icon: TableIcon, label: t('table'), onClick: () => chain().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run() }), _jsx(MenuButton, { icon: MinusIcon, label: t('divider'), onClick: () => chain().setHorizontalRule().run() })] }) })) : null] }));
|
|
56
121
|
}
|
|
@@ -9,6 +9,17 @@ interface ProvisioningFailurePresentation {
|
|
|
9
9
|
export declare function provisioningFailurePresentation(metadata: Record<string, unknown>, sandboxLabel: string | undefined, tI18nComplete: UiTranslator): ProvisioningFailurePresentation;
|
|
10
10
|
/** Read the server-owned recovery copy. This function never consumes it. */
|
|
11
11
|
export declare function pendingSessionPromptFromMetadata(metadata: Record<string, unknown> | null | undefined): PendingSessionPrompt | null;
|
|
12
|
+
/**
|
|
13
|
+
* The prompt the failure card shows, and who delivers it on Retry.
|
|
14
|
+
*
|
|
15
|
+
* `redeliveredOnRestart` is true for `metadata.initial_prompt`: the restart
|
|
16
|
+
* route (`provisionReplacementRuntime`) hands that prompt to the new runtime
|
|
17
|
+
* itself, so Retry must only restart. A legacy `pending_prompt.text` and a
|
|
18
|
+
* start stash exist only in the client, so Retry must POST them.
|
|
19
|
+
*/
|
|
20
|
+
export interface RecoveryPrompt extends PendingSessionPrompt {
|
|
21
|
+
redeliveredOnRestart: boolean;
|
|
22
|
+
}
|
|
12
23
|
/**
|
|
13
24
|
* The recovery copy, from the server when it has one and from this tab's start
|
|
14
25
|
* stash otherwise. Never consumes either.
|
|
@@ -18,6 +29,16 @@ export declare function pendingSessionPromptFromMetadata(metadata: Record<string
|
|
|
18
29
|
* nothing, so its prompt lives only in the start stash the composer wrote before
|
|
19
30
|
* navigating. Reading both is what keeps the failure card's "copy your prompt"
|
|
20
31
|
* and Retry working identically on either path.
|
|
32
|
+
*
|
|
33
|
+
* A session that an agent, a trigger, a channel, MCP or a marketplace install
|
|
34
|
+
* created has neither: its first prompt is `metadata.initial_prompt`. That
|
|
35
|
+
* prompt is shown only while `runtimeSessionId` is empty, which is the same
|
|
36
|
+
* condition under which the restart re-delivers it.
|
|
37
|
+
*/
|
|
38
|
+
export declare function pendingSessionPromptForRecovery(sessionId: string, metadata: Record<string, unknown> | null | undefined, runtimeSessionId?: string | null): RecoveryPrompt | null;
|
|
39
|
+
/**
|
|
40
|
+
* The prompt Retry must POST itself, or null when the restart alone delivers
|
|
41
|
+
* it. Sending a `redeliveredOnRestart` prompt here would run it twice.
|
|
21
42
|
*/
|
|
22
|
-
export declare function
|
|
43
|
+
export declare function recoveryPromptToSendOnRetry(prompt: RecoveryPrompt | null): PendingSessionPrompt | null;
|
|
23
44
|
export {};
|
|
@@ -79,19 +79,47 @@ export function pendingSessionPromptFromMetadata(metadata) {
|
|
|
79
79
|
* nothing, so its prompt lives only in the start stash the composer wrote before
|
|
80
80
|
* navigating. Reading both is what keeps the failure card's "copy your prompt"
|
|
81
81
|
* and Retry working identically on either path.
|
|
82
|
+
*
|
|
83
|
+
* A session that an agent, a trigger, a channel, MCP or a marketplace install
|
|
84
|
+
* created has neither: its first prompt is `metadata.initial_prompt`. That
|
|
85
|
+
* prompt is shown only while `runtimeSessionId` is empty, which is the same
|
|
86
|
+
* condition under which the restart re-delivers it.
|
|
82
87
|
*/
|
|
83
|
-
export function pendingSessionPromptForRecovery(sessionId, metadata) {
|
|
88
|
+
export function pendingSessionPromptForRecovery(sessionId, metadata, runtimeSessionId) {
|
|
84
89
|
const fromMetadata = pendingSessionPromptFromMetadata(metadata);
|
|
85
90
|
if (fromMetadata)
|
|
86
|
-
return fromMetadata;
|
|
91
|
+
return { ...fromMetadata, redeliveredOnRestart: false };
|
|
87
92
|
const stash = readStartStash(sessionId);
|
|
88
|
-
if (
|
|
93
|
+
if (stash && stash.prompt.trim().length > 0) {
|
|
94
|
+
return {
|
|
95
|
+
text: stash.prompt,
|
|
96
|
+
agent: stash.agent ?? null,
|
|
97
|
+
model: stash.model ?? null,
|
|
98
|
+
variant: stash.variant ?? null,
|
|
99
|
+
attachment_names: [],
|
|
100
|
+
redeliveredOnRestart: false,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
const initialPrompt = metadata?.initial_prompt;
|
|
104
|
+
if (runtimeSessionId || typeof initialPrompt !== 'string' || initialPrompt.trim().length === 0) {
|
|
89
105
|
return null;
|
|
106
|
+
}
|
|
90
107
|
return {
|
|
91
|
-
text:
|
|
92
|
-
agent:
|
|
93
|
-
model:
|
|
94
|
-
variant:
|
|
108
|
+
text: initialPrompt,
|
|
109
|
+
agent: null,
|
|
110
|
+
model: null,
|
|
111
|
+
variant: null,
|
|
95
112
|
attachment_names: [],
|
|
113
|
+
redeliveredOnRestart: true,
|
|
96
114
|
};
|
|
97
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* The prompt Retry must POST itself, or null when the restart alone delivers
|
|
118
|
+
* it. Sending a `redeliveredOnRestart` prompt here would run it twice.
|
|
119
|
+
*/
|
|
120
|
+
export function recoveryPromptToSendOnRetry(prompt) {
|
|
121
|
+
if (!prompt || prompt.redeliveredOnRestart)
|
|
122
|
+
return null;
|
|
123
|
+
const { redeliveredOnRestart: _redeliveredOnRestart, ...toSend } = prompt;
|
|
124
|
+
return toSend;
|
|
125
|
+
}
|
|
@@ -32,6 +32,8 @@ export const STUCK_AFTER_MS = 45_000;
|
|
|
32
32
|
* from a skewed or unset `now`, and it rendered as tens of millions of minutes.
|
|
33
33
|
*/
|
|
34
34
|
const MAX_COUNTDOWN_SECONDS = 60 * 60;
|
|
35
|
+
/** `failure.evidence.check` of a box whose agent did not start (apps/api `RUNTIME_BOOT_ERROR_PARK_REASON`). */
|
|
36
|
+
const RUNTIME_BOOT_ERROR_CHECK = 'runtime_boot_error';
|
|
35
37
|
/**
|
|
36
38
|
* Keep the server's retry visible while `/start` waits for its retry clock.
|
|
37
39
|
* The server re-attempts on its own, so this is a waiting state, not an error.
|
|
@@ -39,20 +41,28 @@ const MAX_COUNTDOWN_SECONDS = 60 * 60;
|
|
|
39
41
|
export function sessionWakeStatusNote(input) {
|
|
40
42
|
if (input.reason !== 'runtime_wake_cooldown' || !input.failure)
|
|
41
43
|
return input.note ?? null;
|
|
42
|
-
const
|
|
44
|
+
const evidence = input.failure.evidence;
|
|
45
|
+
// The computer ran and the agent in it did not start: say why, not "still starting".
|
|
46
|
+
const error = evidence?.check === RUNTIME_BOOT_ERROR_CHECK ? evidence.error : null;
|
|
47
|
+
let end = error?.length ?? 0;
|
|
48
|
+
while (error && end > 0 && /[.\s]/.test(error[end - 1]))
|
|
49
|
+
end--;
|
|
50
|
+
const bootError = error?.slice(0, end);
|
|
51
|
+
const lead = bootError ? `Could not start the agent: ${bootError}.` : 'Still starting your computer.';
|
|
52
|
+
const attempts = Math.max(1, evidence?.attempts ?? 1);
|
|
43
53
|
const nextAttempt = attempts + 1;
|
|
44
|
-
const retryAt = Date.parse(
|
|
54
|
+
const retryAt = Date.parse(evidence?.next_retry_at ?? '');
|
|
45
55
|
const seconds = Math.max(0, Math.ceil((retryAt - input.now) / 1_000));
|
|
46
56
|
if (!Number.isFinite(seconds) || seconds > MAX_COUNTDOWN_SECONDS) {
|
|
47
|
-
return
|
|
57
|
+
return `${lead} Trying again automatically (attempt ${nextAttempt}).`;
|
|
48
58
|
}
|
|
49
59
|
if (seconds === 0)
|
|
50
|
-
return
|
|
60
|
+
return `${lead} Trying again now (attempt ${nextAttempt}).`;
|
|
51
61
|
const minutes = Math.floor(seconds / 60);
|
|
52
62
|
const remainder = seconds % 60;
|
|
53
63
|
// One unit: a line break never falls between the minutes and the seconds.
|
|
54
64
|
const duration = minutes > 0 ? `${minutes}m\u00a0${remainder}s` : `${remainder}s`;
|
|
55
|
-
return
|
|
65
|
+
return `${lead} Trying again in ${duration} (attempt ${nextAttempt}).`;
|
|
56
66
|
}
|
|
57
67
|
/** A 1 s tick: the retry countdown and the stuck clock read it. */
|
|
58
68
|
function useNow() {
|