@kortix/ui 0.14.16 → 0.14.19
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 +2 -2
- package/dist/_vendor/kortix-shared.js +38 -2
- 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 +20 -1
- package/dist/_vendor/shared/channel-message.d.ts +1 -1
- package/dist/_vendor/shared/my-kortix-agent.d.ts +1 -1
- package/dist/_vendor/shared/space-slug.d.ts +3 -4
- package/dist/_vendor/shared/utils/ambiguous-write.d.ts +3 -3
- package/dist/customize/agents/agent-instructions.d.ts +8 -0
- package/dist/customize/agents/agent-instructions.js +38 -12
- package/dist/customize/agents/agent-overview.d.ts +6 -3
- package/dist/customize/agents/agent-overview.js +8 -2
- package/dist/customize/agents/agent-page-chrome.d.ts +45 -27
- package/dist/customize/agents/agent-page-chrome.js +60 -37
- package/dist/customize/agents/agent-page.js +88 -99
- package/dist/customize/agents/agent-tabs.d.ts +15 -14
- package/dist/customize/agents/agent-tabs.js +19 -16
- package/dist/customize/agents/agents-page.js +8 -6
- package/dist/customize/connectors/detail/account-info.js +1 -1
- package/dist/customize/project-settings/project-admin-sections.d.ts +6 -2
- package/dist/customize/project-settings/project-admin-sections.js +5 -3
- package/dist/customize/project-settings/project-settings-sections.js +1 -1
- package/dist/customize/sections/component/channel-access-panel.js +16 -0
- package/dist/customize/sections/component/channel-mocks.d.ts +5 -0
- package/dist/customize/sections/component/channel-mocks.js +14 -2
- package/dist/customize/sections/component/discord-channel-row.d.ts +6 -0
- package/dist/customize/sections/component/discord-channel-row.js +48 -0
- package/dist/customize/sections/gateway-access-tab.js +1 -1
- package/dist/customize/sections/view/channels-view.js +18 -1
- package/dist/customize/sections/view/git-view.js +2 -2
- package/dist/customize/sections/view/secret-delivery.js +1 -1
- package/dist/customize/sections/view/secrets-view.js +1 -1
- package/dist/customize/settings/rail.js +2 -2
- package/dist/customize/settings/tabs/experimental-tab.d.ts +2 -2
- package/dist/customize/settings/tabs/experimental-tab.js +3 -6
- package/dist/customize/settings/tabs/general-tab.js +5 -4
- package/dist/customize/shared/capability-library.js +19 -22
- 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/customize-tab-bar.d.ts +1 -2
- package/dist/customize/shared/customize-tab-bar.js +10 -11
- 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/files/project/components/drive-create-dialog.js +3 -3
- package/dist/i18n/en.d.ts +99 -18
- package/dist/i18n/en.js +125 -44
- package/dist/i18n/ui-catalog/remaining-ui-translation-keys.generated.js +1 -1
- package/dist/internal/branding/branding-provider.d.ts +15 -4
- package/dist/internal/branding/branding-provider.js +12 -7
- package/dist/internal/connector-logo/connector-logo.js +2 -0
- package/dist/internal/connector-logo/connector-mark-files.js +1 -0
- package/dist/internal/hooks/channels/use-channels-installations.d.ts +7 -2
- package/dist/internal/hooks/channels/use-channels-installations.js +31 -1
- package/dist/internal/hooks/projects/use-new-project-session.d.ts +6 -14
- package/dist/internal/hooks/projects/use-new-project-session.js +12 -97
- package/dist/internal/hooks/use-notification-center.d.ts +11 -8
- package/dist/internal/hooks/use-notification-center.js +22 -10
- package/dist/internal/icons/discord.d.ts +9 -0
- package/dist/internal/icons/discord.js +9 -0
- package/dist/internal/layout/connect-mcp-modal.js +1 -1
- package/dist/internal/lib/browser-noise/rules/expected-states.js +1 -1
- package/dist/internal/lib/error-handler.js +1 -1
- package/dist/internal/lib/use-project-feature-flags.js +5 -3
- package/dist/markdown/doc-editor/doc-menus.d.ts +6 -0
- package/dist/markdown/doc-editor/doc-menus.js +74 -9
- package/dist/markdown/markdown-frontmatter.d.ts +0 -3
- package/dist/markdown/markdown-frontmatter.js +45 -5
- package/dist/session/actions/project-session-list-helpers.d.ts +4 -14
- package/dist/session/actions/project-session-list-helpers.js +5 -16
- package/dist/session/actions/session-label.d.ts +5 -9
- package/dist/session/actions/session-label.js +6 -10
- package/dist/session/participants/session-participants.d.ts +7 -5
- package/dist/session/participants/session-participants.js +11 -7
- package/dist/session/status/provisioning-failure.d.ts +26 -6
- package/dist/session/status/provisioning-failure.js +39 -12
- package/dist/session/thread/optimistic-turn.js +11 -2
- package/dist/session/thread/session-chat.js +73 -25
- package/dist/session/thread/transcript.d.ts +9 -0
- package/dist/session/thread/transcript.js +44 -5
- package/dist/session/tool/tools/channel-send-card.js +1 -0
- package/dist/session/turn/channel-brand.js +4 -0
- package/dist/session/turn/message-author.d.ts +13 -8
- package/dist/session/turn/message-author.js +34 -16
- package/dist/session/turn/peer-message-row.js +24 -6
- package/dist/session/turn/user-message.js +1 -1
- package/dist/session/voice/call-audio.d.ts +32 -0
- package/dist/session/voice/call-audio.js +146 -0
- package/dist/session/voice/screen-share.d.ts +24 -0
- package/dist/session/voice/screen-share.js +75 -0
- package/dist/session/voice/use-voice-call.d.ts +15 -0
- package/dist/session/voice/use-voice-call.js +220 -0
- package/dist/session/voice/voice-call-bar.d.ts +4 -0
- package/dist/session/voice/voice-call-bar.js +39 -0
- package/dist/session/voice/voice-call-state.d.ts +96 -0
- package/dist/session/voice/voice-call-state.js +103 -0
- package/dist/session/voice/voice-call-store.d.ts +12 -0
- package/dist/session/voice/voice-call-store.js +10 -0
- package/dist/session/voice/voice-call-url.d.ts +24 -0
- package/dist/session/voice/voice-call-url.js +33 -0
- package/dist/session/voice/voice-call.d.ts +15 -0
- package/dist/session/voice/voice-call.js +54 -0
- package/dist/styles.css +1 -1
- package/dist/workspace/admin/project-admin-dashboard.js +9 -4
- package/dist/workspace/layout/project-home.js +13 -14
- package/dist/workspace/sidebar/footer/project-manifest-issues-alert.d.ts +1 -1
- package/dist/workspace/sidebar/footer/project-manifest-issues-alert.js +4 -3
- package/dist/workspace/sidebar/project-session-list.js +14 -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/dist/workspace/sidebar/session-filter-menu.js +1 -0
- package/dist/workspace/sidebar/session-grouping.d.ts +4 -0
- package/dist/workspace/sidebar/session-grouping.js +2 -0
- package/dist/workspace/sidebar/session-source-icons.js +2 -0
- package/dist/workspace/space/space-page.js +2 -2
- package/package.json +9 -9
- package/skills/kortix-ui/SKILL.md +2 -2
- package/skills/kortix-ui/references/custom-dashboard.md +1 -1
- package/skills/kortix-ui/references/modules.md +1 -1
- package/dist/customize/agents/agent-section-rail.d.ts +0 -21
- package/dist/customize/agents/agent-section-rail.js +0 -23
- package/dist/internal/hooks/projects/use-warm-project-session.d.ts +0 -270
- package/dist/internal/hooks/projects/use-warm-project-session.js +0 -362
- package/dist/internal/hooks/projects/warm-session-seed.d.ts +0 -66
- package/dist/internal/hooks/projects/warm-session-seed.js +0 -80
- package/dist/internal/hooks/projects/warm-session-taken-registry.d.ts +0 -61
- package/dist/internal/hooks/projects/warm-session-taken-registry.js +0 -141
|
@@ -9,59 +9,13 @@ import { createScopedSession } from '../../../session/scope/create-scoped-sessio
|
|
|
9
9
|
import { confirmCommitted, errorCode, getRequiredConnectorConnections, isAmbiguousCreateFailure, resolveCreateFailure, } from './new-session-failure.js';
|
|
10
10
|
import { NEW_SESSION_GUARD_MAX_MS, hasLandedOnNewSession, useNewSessionGuardStore, } from './new-session-guard.js';
|
|
11
11
|
import { useProjectCanRun } from './use-project-can-run.js';
|
|
12
|
-
import { createWarmSession, primeTakenWarmSession, tabIsVisible, takeWarmSessionEntry, } from './use-warm-project-session.js';
|
|
13
|
-
import { reconcileSessionsAfterCreate, seedAdoptedWarmSession, } from './warm-session-seed.js';
|
|
14
12
|
import { useConnectorGateStore } from '../../stores/connector-gate-store.js';
|
|
15
13
|
import { useUpgradeDialogStore } from '../../stores/upgrade-dialog-store.js';
|
|
16
14
|
import { ApiError, createProjectSession, getProjectSession, getProjectSessionScope, markSessionFresh, setProjectSessionScope, platformConfig, } from '@kortix/sdk';
|
|
17
15
|
import { prefetchSessionStart, qk, upsertCachedProjectSession } from '@kortix/sdk/react';
|
|
18
16
|
import { randomUUID } from '../../lib/utils/random-uuid.js';
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
// one exactly as before. The warm session already exists — it is an
|
|
22
|
-
// ordinary session created a few seconds ago — so this is a synchronous,
|
|
23
|
-
// network-free hand-off that skips the sandbox boot the user would
|
|
24
|
-
// otherwise watch after pressing Enter. `takeWarmSessionEntry` returns
|
|
25
|
-
// null whenever there is nothing suitable, so the create path below stays
|
|
26
|
-
// the authority on billing and connector requirements.
|
|
27
|
-
async function takeOrCreateSession() {
|
|
28
|
-
// A space thread always creates: a warm session belongs to no space.
|
|
29
|
-
const warm = opts.create?.space_id
|
|
30
|
-
? null
|
|
31
|
-
: takeWarmSessionEntry(projectId, {
|
|
32
|
-
create: opts?.create,
|
|
33
|
-
// Replenish after /start, not beside the claim and /start requests.
|
|
34
|
-
replenish: false,
|
|
35
|
-
});
|
|
36
|
-
if (warm) {
|
|
37
|
-
// The first prompt is a DURABLE inbox row, never a client-side
|
|
38
|
-
// replay (the start stash carries picks only — see the producers).
|
|
39
|
-
// The ordinary path gets that row from `create.pending_prompt` in
|
|
40
|
-
// the create transaction; an adopted warm session was created
|
|
41
|
-
// seconds ago with an EMPTY body, so its prompt has to land now,
|
|
42
|
-
// through the server's claim (`primeTakenWarmSession`): one
|
|
43
|
-
// transaction that inserts the row, drops the warm marker, and kicks
|
|
44
|
-
// the drain. Without this the local take navigated into a session
|
|
45
|
-
// that had never heard the prompt — the "my first message
|
|
46
|
-
// disappears" bug, on the warm path.
|
|
47
|
-
//
|
|
48
|
-
// A refused claim (another tab took it, marker already gone) is not
|
|
49
|
-
// an error the user should see: fall through to the ordinary create,
|
|
50
|
-
// which carries the same prompt.
|
|
51
|
-
const pending = opts?.create?.pending_prompt;
|
|
52
|
-
const primed = pending
|
|
53
|
-
? await primeTakenWarmSession(projectId, warm, {
|
|
54
|
-
pending_prompt: pending,
|
|
55
|
-
...(opts?.create?.agent_name ? { agent_name: opts.create.agent_name } : {}),
|
|
56
|
-
...(opts?.create?.sandbox_slug ? { sandbox_slug: opts.create.sandbox_slug } : {}),
|
|
57
|
-
})
|
|
58
|
-
: true;
|
|
59
|
-
if (primed) {
|
|
60
|
-
onAdopt(warm.session);
|
|
61
|
-
router.prefetch(uiRoutes().session(projectId, warm.sessionId));
|
|
62
|
-
return warm.sessionId;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
17
|
+
function makeCreateSession(projectId, opts, router, queryClient) {
|
|
18
|
+
return async function createSessionRow() {
|
|
65
19
|
const sessionId = randomUUID();
|
|
66
20
|
markSessionFresh(sessionId);
|
|
67
21
|
opts.onCreating?.(sessionId);
|
|
@@ -92,8 +46,7 @@ function makeTakeOrCreateSession(projectId, opts, router, queryClient, onAdopt)
|
|
|
92
46
|
upsertCachedProjectSession(queryClient, projectId, created);
|
|
93
47
|
}
|
|
94
48
|
return sessionId;
|
|
95
|
-
}
|
|
96
|
-
return takeOrCreateSession;
|
|
49
|
+
};
|
|
97
50
|
}
|
|
98
51
|
export function useNewProjectSession(projectId) {
|
|
99
52
|
const t = useTranslations('threads');
|
|
@@ -183,15 +136,7 @@ export function useNewProjectSession(projectId) {
|
|
|
183
136
|
return;
|
|
184
137
|
}
|
|
185
138
|
releaseTimerRef.current = setTimeout(release, NEW_SESSION_GUARD_MAX_MS);
|
|
186
|
-
|
|
187
|
-
// sessions-list cache with it (JAY-599/T21). Set only when a warm
|
|
188
|
-
// session was actually adopted THIS call — a closure local, not a ref,
|
|
189
|
-
// so back-to-back activations of this same hook instance never leak one
|
|
190
|
-
// call's row into another's `onReady`.
|
|
191
|
-
let adoptedWarmSession = null;
|
|
192
|
-
const takeOrCreateSession = makeTakeOrCreateSession(projectId, opts, router, queryClient, (session) => {
|
|
193
|
-
adoptedWarmSession = session;
|
|
194
|
-
});
|
|
139
|
+
const createSessionRow = makeCreateSession(projectId, opts, router, queryClient);
|
|
195
140
|
// A space thread shows up in the timeline at once, so it gets no toast.
|
|
196
141
|
const inSpace = Boolean(opts.create?.space_id);
|
|
197
142
|
// `threads.*`, not `hardcodedUi.i18nComplete.*`. The two
|
|
@@ -202,8 +147,8 @@ export function useNewProjectSession(projectId) {
|
|
|
202
147
|
// `threads.sessionStarted` are the canonical entries and are
|
|
203
148
|
// correctly translated in all nine catalogs.
|
|
204
149
|
const createSession = () => inSpace
|
|
205
|
-
?
|
|
206
|
-
: loadingToast(t('startingSession'),
|
|
150
|
+
? createSessionRow()
|
|
151
|
+
: loadingToast(t('startingSession'), createSessionRow(), {
|
|
207
152
|
success: t('sessionStarted'),
|
|
208
153
|
});
|
|
209
154
|
createScopedSession({
|
|
@@ -216,49 +161,19 @@ export function useNewProjectSession(projectId) {
|
|
|
216
161
|
// Keep the claim engaged through the navigation: the effect above
|
|
217
162
|
// releases it once the browser is actually showing this session.
|
|
218
163
|
useNewSessionGuardStore.getState().target(projectId, sessionId);
|
|
219
|
-
// Adoption: this only ever runs once create (+ any scope
|
|
220
|
-
// replacement) has already SUCCEEDED, so a warm session that got
|
|
221
|
-
// taken but never made it this far (a scope-replacement failure,
|
|
222
|
-
// say) never seeds a phantom row here — see warm-session-seed.ts.
|
|
223
|
-
if (adoptedWarmSession) {
|
|
224
|
-
// Every cached shape, not just the flat key. The sidebar caches
|
|
225
|
-
// PAGES now (`useProjectSessions`), so a write aimed at the flat
|
|
226
|
-
// list left a brand-new session invisible there until the next
|
|
227
|
-
// refetch — the one surface the user is watching when they start
|
|
228
|
-
// one. `seedAdoptedWarmSession` still owns what an adopted row
|
|
229
|
-
// looks like; the cache write is the only part that moved.
|
|
230
|
-
const [adopted] = seedAdoptedWarmSession(undefined, adoptedWarmSession, new Date().toISOString());
|
|
231
|
-
if (adopted)
|
|
232
|
-
upsertCachedProjectSession(queryClient, projectId, adopted);
|
|
233
|
-
}
|
|
234
164
|
// The row exists — kick provisioning so it overlaps the navigation.
|
|
235
|
-
|
|
236
|
-
// server
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
const replenish = () => {
|
|
240
|
-
if (!tabIsVisible())
|
|
241
|
-
return;
|
|
242
|
-
void createWarmSession(projectId, undefined, { excludeSessionId: sessionId });
|
|
243
|
-
};
|
|
244
|
-
void started.then(replenish, replenish);
|
|
245
|
-
}
|
|
246
|
-
// Warm adoption defers the list reconcile until that /start settles,
|
|
247
|
-
// so the refetch cannot observe the row still marker-hidden and wipe
|
|
248
|
-
// the seed above — see reconcileSessionsAfterCreate.
|
|
249
|
-
reconcileSessionsAfterCreate({
|
|
250
|
-
adoptedWarm: adoptedWarmSession !== null,
|
|
251
|
-
started,
|
|
252
|
-
invalidate: () => queryClient.invalidateQueries({ queryKey: qk.project.sessionsScope(projectId) }),
|
|
253
|
-
});
|
|
165
|
+
void prefetchSessionStart(queryClient, projectId, sessionId);
|
|
166
|
+
// The row is visible server-side the moment the create returns, so
|
|
167
|
+
// reconcile the cached lists now.
|
|
168
|
+
void queryClient.invalidateQueries({ queryKey: qk.project.sessionsScope(projectId) });
|
|
254
169
|
opts?.onNavigate?.(sessionId);
|
|
255
170
|
// The space view stays on screen, so no navigation lands to release the claim.
|
|
256
171
|
if (inSpace) {
|
|
257
172
|
release();
|
|
258
173
|
return;
|
|
259
174
|
}
|
|
260
|
-
// nav-contract: prefetch-only — the session id is minted
|
|
261
|
-
//
|
|
175
|
+
// nav-contract: prefetch-only — the session id is minted client-side
|
|
176
|
+
// at the click, so no anchor can name it. `createSessionRow`
|
|
262
177
|
// prefetches the route the moment the id exists.
|
|
263
178
|
router.push(uiRoutes().session(projectId, sessionId));
|
|
264
179
|
},
|
|
@@ -3,14 +3,15 @@
|
|
|
3
3
|
* The strict `notification_center` gate controls session mute/watch actions.
|
|
4
4
|
* Inbox surfaces also work when artifacts and artifact_comments are both on.
|
|
5
5
|
*
|
|
6
|
-
* - With a project id: `useFeatureFlag`, fail-closed, on the shared
|
|
7
|
-
* `qk.project.
|
|
6
|
+
* - With a project id: `useFeatureFlag`, fail-closed, on the shared bare
|
|
7
|
+
* project row (`qk.project.summary(id)`) that the project shell reads.
|
|
8
8
|
* - Without one (`/projects`, `/new`, standalone `/settings`): on when any
|
|
9
9
|
* project already in this client's query cache has the flag on. The scan
|
|
10
|
-
* reads the cached project details and project lists. It sends no request,
|
|
10
|
+
* reads the cached project rows, project details and project lists. It sends no request,
|
|
11
11
|
* so a cold load of such a page with nothing cached reads off.
|
|
12
12
|
* - `NotificationHost` uses `useNotificationHostGate`: while a project's
|
|
13
|
-
*
|
|
13
|
+
* row loads, a cached detail, a cached project list or its previous answer
|
|
14
|
+
* decides.
|
|
14
15
|
*/
|
|
15
16
|
import type { KortixProject } from '@kortix/sdk';
|
|
16
17
|
import { type QueryClient } from '@tanstack/react-query';
|
|
@@ -22,8 +23,9 @@ type FlagHolder = {
|
|
|
22
23
|
export declare function notificationCenterOn(project: FlagHolder): boolean;
|
|
23
24
|
export declare function notificationInboxOn(project: FlagHolder): boolean;
|
|
24
25
|
/**
|
|
25
|
-
* The flag for one project from the query cache: its
|
|
26
|
-
* project list that holds it. Undefined when
|
|
26
|
+
* The flag for one project from the query cache: its row, else its detail,
|
|
27
|
+
* else a cached project list that holds it. Undefined when none holds it.
|
|
28
|
+
* Sends no request.
|
|
27
29
|
*/
|
|
28
30
|
export declare function cachedNotificationCenterAnswer(client: QueryClient | null, projectId: string | null | undefined): boolean | undefined;
|
|
29
31
|
export declare function cachedNotificationInboxAnswer(client: QueryClient | null, projectId: string | null | undefined): boolean | undefined;
|
|
@@ -37,11 +39,12 @@ export declare function useNotificationCenter(projectId?: string | null): boolea
|
|
|
37
39
|
export declare function useNotificationInboxEnabled(projectId?: string | null): boolean;
|
|
38
40
|
/**
|
|
39
41
|
* The inbox gate of `NotificationHost`, except while the
|
|
40
|
-
* project's
|
|
42
|
+
* project's row loads. Then a cached detail or project list answers, else the
|
|
41
43
|
* previous answer stays. So entering a flag-on project from `/projects` or
|
|
42
44
|
* from another flag-on project does not unmount the host and subscribe Web
|
|
43
45
|
* Push again. Only a loaded detail without the flag turns it off. A cold
|
|
44
|
-
* load of a project page starts off.
|
|
46
|
+
* load of a project page starts off. Only a loaded row (or, before it, a
|
|
47
|
+
* loaded detail) without the flag turns it off.
|
|
45
48
|
*/
|
|
46
49
|
export declare function useNotificationHostGate(projectId?: string | null): boolean;
|
|
47
50
|
export {};
|
|
@@ -11,8 +11,9 @@ export function notificationInboxOn(project) {
|
|
|
11
11
|
return notificationCenterOn(project) || (project?.experimental?.artifacts === true && project.experimental.artifact_comments === true);
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
* The flag for one project from the query cache: its
|
|
15
|
-
* project list that holds it. Undefined when
|
|
14
|
+
* The flag for one project from the query cache: its row, else its detail,
|
|
15
|
+
* else a cached project list that holds it. Undefined when none holds it.
|
|
16
|
+
* Sends no request.
|
|
16
17
|
*/
|
|
17
18
|
export function cachedNotificationCenterAnswer(client, projectId) {
|
|
18
19
|
return cachedFlagAnswer(client, projectId, notificationCenterOn);
|
|
@@ -20,6 +21,9 @@ export function cachedNotificationCenterAnswer(client, projectId) {
|
|
|
20
21
|
function cachedFlagAnswer(client, projectId, enabled) {
|
|
21
22
|
if (!client || !projectId)
|
|
22
23
|
return undefined;
|
|
24
|
+
const row = client.getQueryData(qk.project.summary(projectId));
|
|
25
|
+
if (row)
|
|
26
|
+
return enabled(row);
|
|
23
27
|
const detail = client.getQueryData(qk.project.detail(projectId));
|
|
24
28
|
if (detail?.project)
|
|
25
29
|
return enabled(detail.project);
|
|
@@ -41,7 +45,8 @@ export function cachedNotificationCenter(client, projectId) {
|
|
|
41
45
|
}
|
|
42
46
|
const [ROOT, LIST_SCOPE] = qk.projects.scope();
|
|
43
47
|
const [, DETAIL_SCOPE, , DETAIL] = qk.project.detail('');
|
|
44
|
-
|
|
48
|
+
const [, , , SUMMARY] = qk.project.summary('');
|
|
49
|
+
/** A project-list, project-row or project-detail entry that holds a project with the flag on. */
|
|
45
50
|
function holdsFlagOn(query, enabled) {
|
|
46
51
|
const key = query.queryKey;
|
|
47
52
|
const data = query.state.data;
|
|
@@ -52,6 +57,8 @@ function holdsFlagOn(query, enabled) {
|
|
|
52
57
|
if (key[1] === DETAIL_SCOPE && key.length === 4 && key[3] === DETAIL) {
|
|
53
58
|
return enabled(data?.project);
|
|
54
59
|
}
|
|
60
|
+
if (key[1] === DETAIL_SCOPE && key.length === 4 && key[3] === SUMMARY)
|
|
61
|
+
return enabled(data);
|
|
55
62
|
return false;
|
|
56
63
|
}
|
|
57
64
|
/** True when any project in the query cache has the flag on. */
|
|
@@ -106,23 +113,28 @@ export function useNotificationInboxEnabled(projectId) {
|
|
|
106
113
|
}
|
|
107
114
|
/**
|
|
108
115
|
* The inbox gate of `NotificationHost`, except while the
|
|
109
|
-
* project's
|
|
116
|
+
* project's row loads. Then a cached detail or project list answers, else the
|
|
110
117
|
* previous answer stays. So entering a flag-on project from `/projects` or
|
|
111
118
|
* from another flag-on project does not unmount the host and subscribe Web
|
|
112
119
|
* Push again. Only a loaded detail without the flag turns it off. A cold
|
|
113
|
-
* load of a project page starts off.
|
|
120
|
+
* load of a project page starts off. Only a loaded row (or, before it, a
|
|
121
|
+
* loaded detail) without the flag turns it off.
|
|
114
122
|
*/
|
|
115
123
|
export function useNotificationHostGate(projectId) {
|
|
116
124
|
const client = useQueryClient();
|
|
117
|
-
// The global host sits outside the access boundary. Read the shell's
|
|
118
|
-
//
|
|
125
|
+
// The global host sits outside the access boundary. Read the shell's project
|
|
126
|
+
// row from the cache (the detail when no row is cached): no request for a potentially revoked project, and no
|
|
119
127
|
// observer. An observer added a detail query without a queryFn (also for the
|
|
120
128
|
// empty id of a page outside any project), and every refetch of it logged
|
|
121
129
|
// "No queryFn was passed".
|
|
122
|
-
const
|
|
130
|
+
const subscribe = useCacheSubscription(client, !!projectId);
|
|
131
|
+
const row = useSyncExternalStore(subscribe, () => (projectId ? client.getQueryState(qk.project.summary(projectId)) : undefined), () => undefined);
|
|
132
|
+
const detail = useSyncExternalStore(subscribe, () => (projectId ? client.getQueryState(qk.project.detail(projectId)) : undefined), () => undefined);
|
|
133
|
+
const rowLoaded = !!row && row.status !== 'pending';
|
|
134
|
+
const detailLoaded = !!detail && detail.status !== 'pending';
|
|
123
135
|
const flag = {
|
|
124
|
-
isLoading: !
|
|
125
|
-
enabled: notificationInboxOn(detail?.data?.project),
|
|
136
|
+
isLoading: !rowLoaded && !detailLoaded,
|
|
137
|
+
enabled: notificationInboxOn(rowLoaded ? row?.data : detail?.data?.project),
|
|
126
138
|
};
|
|
127
139
|
const anyProject = useAnyCachedNotificationInbox(client, !projectId);
|
|
128
140
|
const [previous, setPrevious] = useState(false);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** @internal Kortix apps only. No semver: it may change in any release. */
|
|
2
|
+
/** Discord's blurple (discord.com brand guidelines). */
|
|
3
|
+
export declare const DISCORD_BLURPLE = "#5865F2";
|
|
4
|
+
/** The Discord logo's Clyde glyph in a 24 × 24 box (Simple Icons, CC0). */
|
|
5
|
+
export declare const DISCORD_PATH = "M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028 14.09 14.09 0 0 0 1.226-1.994.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z";
|
|
6
|
+
/** The Discord mark: Clyde in blurple. */
|
|
7
|
+
export declare const Discord: ({ className }: {
|
|
8
|
+
className?: string;
|
|
9
|
+
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from '../lib/utils.js';
|
|
4
|
+
/** Discord's blurple (discord.com brand guidelines). */
|
|
5
|
+
export const DISCORD_BLURPLE = '#5865F2';
|
|
6
|
+
/** The Discord logo's Clyde glyph in a 24 × 24 box (Simple Icons, CC0). */
|
|
7
|
+
export const DISCORD_PATH = 'M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028 14.09 14.09 0 0 0 1.226-1.994.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z';
|
|
8
|
+
/** The Discord mark: Clyde in blurple. */
|
|
9
|
+
export const Discord = ({ className }) => (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", className: cn('size-4', className), "aria-hidden": "true", children: _jsx("path", { fill: DISCORD_BLURPLE, d: DISCORD_PATH }) }));
|
|
@@ -61,7 +61,7 @@ export function ConnectMcpModal({ open, onOpenChange, }) {
|
|
|
61
61
|
return (_jsx(Modal, { open: open, onOpenChange: onOpenChange, children: _jsx(ModalContent, { className: "space-y-0 lg:max-w-3xl", closeClassName: "max-sm:bg-background border-0 overflow-hidden", children: _jsxs("div", { className: "grid sm:grid-cols-5 lg:min-h-128", children: [_jsxs("div", { "aria-hidden": "true", className: "dark bg-background relative isolate flex h-48 items-center justify-center overflow-hidden rounded-t-xl border-b sm:col-span-2 sm:h-auto sm:rounded-tr-none sm:border-r sm:border-b-0 lg:rounded-bl-xl", children: [_jsx(BeamsShader, {}), _jsx("div", { className: "relative grid grid-cols-4 gap-2.5 sm:grid-cols-2", children: ART_CLIENTS.map(({ id, Logo }) => (
|
|
62
62
|
// `bg-foreground` is white under the art's `dark` scope: the marks carry their
|
|
63
63
|
// own brand colors (Codex brings its own white tile).
|
|
64
|
-
_jsx("span", { className: "bg-foreground flex size-16 items-center justify-center rounded-xl shadow-lg", children: _jsx(Logo, { className: "size-8" }) }, id))) })] }), _jsxs("div", { className: "flex min-w-0 flex-col gap-5 p-5 sm:col-span-3 lg:p-8", children: [_jsxs("header", { className: "space-y-1.5 pr-10", children: [_jsx(ModalTitle, { className: "text-lg font-medium text-balance", children: t('title') }), _jsx(ModalDescription, { className: "text-pretty", children: t('description') })] }), _jsxs("div", { className: "bg-muted flex min-w-0 items-center gap-3 rounded-md border p-3", children: [_jsx("code", { className: "min-w-0 flex-1 text-xs break-all select-text", children: url }), _jsx(ClientAction, { client: CLIENTS[0], url: url })] }), _jsx("ul", { className: "divide-border divide-y", children: CLIENTS.map((client) => (_jsxs("li", { className: "flex items-center gap-3 py-2.5", children: [_jsx("span", { className: "bg-muted flex size-9 shrink-0 items-center justify-center rounded-sm", children: _jsx(client.Logo, { className: "size-5" }) }), _jsxs("div", { className: "min-w-0 flex-1 space-y-0.5", children: [_jsx("p", { className: "text-sm font-medium", children: client.name ?? t('anyClient') }), _jsx("p", { className: "text-muted-foreground truncate text-xs", children: t(`via.${client.id}`) })] }), _jsx(ClientAction, { client: client, url: url })] }, client.id))) }), _jsxs("footer", { className: "mt-auto flex items-center justify-between pt-2", children: [_jsx(Button, { asChild: true, variant: "ghost", size: "sm", className: "text-muted-foreground gap-1", children: _jsxs(Link, { href: "/docs/
|
|
64
|
+
_jsx("span", { className: "bg-foreground flex size-16 items-center justify-center rounded-xl shadow-lg", children: _jsx(Logo, { className: "size-8" }) }, id))) })] }), _jsxs("div", { className: "flex min-w-0 flex-col gap-5 p-5 sm:col-span-3 lg:p-8", children: [_jsxs("header", { className: "space-y-1.5 pr-10", children: [_jsx(ModalTitle, { className: "text-lg font-medium text-balance", children: t('title') }), _jsx(ModalDescription, { className: "text-pretty", children: t('description') })] }), _jsxs("div", { className: "bg-muted flex min-w-0 items-center gap-3 rounded-md border p-3", children: [_jsx("code", { className: "min-w-0 flex-1 text-xs break-all select-text", children: url }), _jsx(ClientAction, { client: CLIENTS[0], url: url })] }), _jsx("ul", { className: "divide-border divide-y", children: CLIENTS.map((client) => (_jsxs("li", { className: "flex items-center gap-3 py-2.5", children: [_jsx("span", { className: "bg-muted flex size-9 shrink-0 items-center justify-center rounded-sm", children: _jsx(client.Logo, { className: "size-5" }) }), _jsxs("div", { className: "min-w-0 flex-1 space-y-0.5", children: [_jsx("p", { className: "text-sm font-medium", children: client.name ?? t('anyClient') }), _jsx("p", { className: "text-muted-foreground truncate text-xs", children: t(`via.${client.id}`) })] }), _jsx(ClientAction, { client: client, url: url })] }, client.id))) }), _jsxs("footer", { className: "mt-auto flex items-center justify-between pt-2", children: [_jsx(Button, { asChild: true, variant: "ghost", size: "sm", className: "text-muted-foreground gap-1", children: _jsxs(Link, { href: "/docs/guide#other-ai-tools-mcp", target: "_blank", children: [t('docs'), _jsx(ArrowUpRightIcon, { className: "size-3.5 shrink-0" })] }) }), _jsx(Button, { type: "button", onClick: () => onOpenChange(false), children: t('done') })] })] })] }) }) }));
|
|
65
65
|
}
|
|
66
66
|
// The secondary fill sits close to the row; a ring on hover marks the target.
|
|
67
67
|
const ACTION_CLASS = 'hover:border-ring hover:border hover:ring-ring/15 hover:ring-2 hit-area-y-3 hit-area-l-3 shrink-0 border border-transparent';
|
|
@@ -165,7 +165,7 @@ const MODEL_NOT_SERVABLE_NOISE_PATTERNS = [
|
|
|
165
165
|
//
|
|
166
166
|
// This is the frontend mirror of the API's request-deadline 503
|
|
167
167
|
// (`apps/api/src/middleware/request-deadline.ts`, de-noised from Sentry by
|
|
168
|
-
// https://github.com/kortix-ai/
|
|
168
|
+
// https://github.com/kortix-ai/CompanyOS/pull/4524). The API bounds every
|
|
169
169
|
// non-streaming request to a 25s server deadline that returns a clean 503 +
|
|
170
170
|
// `Retry-After: 10`, and react-query retries background polls (the session-audit
|
|
171
171
|
// route that produced Better Stack pattern `b1db01e5…` is polled every 5–15s
|
|
@@ -135,7 +135,7 @@ export const handleApiError = (error, context, tI18nComplete) => {
|
|
|
135
135
|
// deadline — packages/sdk/src/core/http/api-client.ts) is intentionally NOT
|
|
136
136
|
// captured here. It is the frontend mirror of the API's request-deadline 503
|
|
137
137
|
// (apps/api/src/middleware/request-deadline.ts, de-noised from Sentry by
|
|
138
|
-
// https://github.com/kortix-ai/
|
|
138
|
+
// https://github.com/kortix-ai/CompanyOS/pull/4524): the API has a 25s server
|
|
139
139
|
// deadline that returns a clean 503 + Retry-After, and react-query retries
|
|
140
140
|
// background polls, so a 30s client abort is an EXPECTED, retryable
|
|
141
141
|
// degradation under momentary API saturation — not an actionable bug. The
|
|
@@ -23,7 +23,6 @@ import { useFeatureFlag } from '@kortix/sdk/react';
|
|
|
23
23
|
export function useProjectFeatureFlags(projectId) {
|
|
24
24
|
const marketplace = useFeatureFlag(projectId, 'marketplace');
|
|
25
25
|
const reminders = useFeatureFlag(projectId, 'reminders');
|
|
26
|
-
const warmSessions = useFeatureFlag(projectId, 'warm_sessions');
|
|
27
26
|
const secretsEgress = useFeatureFlag(projectId, 'secrets_egress');
|
|
28
27
|
const pooledProviderSecrets = useFeatureFlag(projectId, 'pooled_provider_secrets');
|
|
29
28
|
const usRegion = useFeatureFlag(projectId, 'us_region');
|
|
@@ -35,6 +34,7 @@ export function useProjectFeatureFlags(projectId) {
|
|
|
35
34
|
const sessionLogRestore = useFeatureFlag(projectId, 'session_log_restore');
|
|
36
35
|
const projectChannels = useFeatureFlag(projectId, 'project_channels');
|
|
37
36
|
const agentRooms = useFeatureFlag(projectId, 'agent_rooms');
|
|
37
|
+
const sharedDrives = useFeatureFlag(projectId, 'shared_drives');
|
|
38
38
|
const goals = useFeatureFlag(projectId, 'goals');
|
|
39
39
|
const artifacts = useFeatureFlag(projectId, 'artifacts');
|
|
40
40
|
const artifactComments = useFeatureFlag(projectId, 'artifact_comments');
|
|
@@ -43,11 +43,11 @@ export function useProjectFeatureFlags(projectId) {
|
|
|
43
43
|
const sessionGroups = useFeatureFlag(projectId, 'session_groups');
|
|
44
44
|
const chrome = useFeatureFlag(projectId, 'chrome');
|
|
45
45
|
const agentTeams = useFeatureFlag(projectId, 'agent_teams');
|
|
46
|
+
const voiceCall = useFeatureFlag(projectId, 'voice_call');
|
|
46
47
|
return {
|
|
47
48
|
flags: {
|
|
48
49
|
marketplace: marketplace.enabled,
|
|
49
50
|
reminders: reminders.enabled,
|
|
50
|
-
warm_sessions: warmSessions.enabled,
|
|
51
51
|
secrets_egress: secretsEgress.enabled,
|
|
52
52
|
pooled_provider_secrets: pooledProviderSecrets.enabled,
|
|
53
53
|
us_region: usRegion.enabled,
|
|
@@ -59,6 +59,7 @@ export function useProjectFeatureFlags(projectId) {
|
|
|
59
59
|
session_log_restore: sessionLogRestore.enabled,
|
|
60
60
|
project_channels: projectChannels.enabled,
|
|
61
61
|
agent_rooms: agentRooms.enabled,
|
|
62
|
+
shared_drives: sharedDrives.enabled,
|
|
62
63
|
goals: goals.enabled,
|
|
63
64
|
artifacts: artifacts.enabled,
|
|
64
65
|
artifact_comments: artifactComments.enabled,
|
|
@@ -67,8 +68,9 @@ export function useProjectFeatureFlags(projectId) {
|
|
|
67
68
|
session_groups: sessionGroups.enabled,
|
|
68
69
|
chrome: chrome.enabled,
|
|
69
70
|
agent_teams: agentTeams.enabled,
|
|
71
|
+
voice_call: voiceCall.enabled,
|
|
70
72
|
},
|
|
71
73
|
// The trailing hook's loading state — keep this on the LAST hook above.
|
|
72
|
-
isLoading:
|
|
74
|
+
isLoading: voiceCall.isLoading,
|
|
73
75
|
};
|
|
74
76
|
}
|
|
@@ -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
|
}
|
|
@@ -10,9 +10,6 @@ export interface ParsedMarkdown {
|
|
|
10
10
|
frontmatter: Record<string, FrontmatterValue> | null;
|
|
11
11
|
body: string;
|
|
12
12
|
}
|
|
13
|
-
/** Extract a leading `---\n…\n---` frontmatter block. Returns the parsed
|
|
14
|
-
* object plus the markdown body. If no block is found, returns the original
|
|
15
|
-
* content untouched. */
|
|
16
13
|
export declare function parseFrontmatter(content: string): ParsedMarkdown;
|
|
17
14
|
/**
|
|
18
15
|
* Render markdown content; if a leading YAML frontmatter block is present, it
|
|
@@ -9,6 +9,47 @@ import { UnifiedMarkdown } from './unified-markdown.js';
|
|
|
9
9
|
/** Extract a leading `---\n…\n---` frontmatter block. Returns the parsed
|
|
10
10
|
* object plus the markdown body. If no block is found, returns the original
|
|
11
11
|
* content untouched. */
|
|
12
|
+
/**
|
|
13
|
+
* `key: value` with a bare `[\w.-]` key at column 0, split at the first colon.
|
|
14
|
+
* String scanning, not a `\s*:\s*(.*)` regex: that one backtracked
|
|
15
|
+
* quadratically on a long run of spaces (CodeQL js/polynomial-redos).
|
|
16
|
+
*/
|
|
17
|
+
function topEntry(line) {
|
|
18
|
+
const colon = line.indexOf(':');
|
|
19
|
+
if (colon <= 0)
|
|
20
|
+
return null;
|
|
21
|
+
const key = line.slice(0, colon).trimEnd();
|
|
22
|
+
return /^[\w.-]+$/.test(key) ? [key, line.slice(colon + 1)] : null;
|
|
23
|
+
}
|
|
24
|
+
/** An indented `key: value`; the key may be quoted (`"*": allow`) or bare: word characters, `.`, `*`, `/` and `-`. */
|
|
25
|
+
function nestedEntry(line) {
|
|
26
|
+
const rest = line.trimStart();
|
|
27
|
+
if (rest.length === line.length)
|
|
28
|
+
return null;
|
|
29
|
+
const quote = rest[0];
|
|
30
|
+
let key;
|
|
31
|
+
let after;
|
|
32
|
+
if (quote === '"' || quote === "'") {
|
|
33
|
+
const close = rest.indexOf(quote, 1);
|
|
34
|
+
if (close <= 1)
|
|
35
|
+
return null;
|
|
36
|
+
key = rest.slice(1, close);
|
|
37
|
+
after = rest.slice(close + 1).trimStart();
|
|
38
|
+
if (!after.startsWith(':'))
|
|
39
|
+
return null;
|
|
40
|
+
after = after.slice(1);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
const colon = rest.indexOf(':');
|
|
44
|
+
if (colon <= 0)
|
|
45
|
+
return null;
|
|
46
|
+
key = rest.slice(0, colon).trimEnd();
|
|
47
|
+
if (!/^[\w.*/-]+$/.test(key))
|
|
48
|
+
return null;
|
|
49
|
+
after = rest.slice(colon + 1);
|
|
50
|
+
}
|
|
51
|
+
return [key, after];
|
|
52
|
+
}
|
|
12
53
|
export function parseFrontmatter(content) {
|
|
13
54
|
const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);
|
|
14
55
|
if (!match)
|
|
@@ -27,15 +68,14 @@ export function parseFrontmatter(content) {
|
|
|
27
68
|
// usually is — `"*": allow`. Matching only [\w.-] dropped that line, left
|
|
28
69
|
// the parent an empty object, and printed a bare em-dash where the
|
|
29
70
|
// permissions belong. Wildcards and path-ish keys are accepted bare too.
|
|
30
|
-
const nested = line
|
|
71
|
+
const nested = nestedEntry(line);
|
|
31
72
|
if (nested && currentParent && typeof result[currentParent] === 'object') {
|
|
32
|
-
|
|
33
|
-
result[currentParent][key] = nested[4].trim();
|
|
73
|
+
result[currentParent][nested[0]] = nested[1].trim();
|
|
34
74
|
continue;
|
|
35
75
|
}
|
|
36
|
-
const top = line
|
|
76
|
+
const top = topEntry(line);
|
|
37
77
|
if (top) {
|
|
38
|
-
const [
|
|
78
|
+
const [key, value] = top;
|
|
39
79
|
const trimmed = value.trim();
|
|
40
80
|
if (!trimmed) {
|
|
41
81
|
result[key] = {};
|