@kortix/ui 0.15.9 → 0.15.11
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/kortix-shared.js +467 -2
- package/dist/_vendor/shared/app-config.d.ts +6 -30
- package/dist/_vendor/shared/channel-descriptors.d.ts +0 -34
- package/dist/_vendor/shared/channel-header.d.ts +2 -1
- package/dist/_vendor/shared/connector-sections.d.ts +0 -25
- package/dist/_vendor/shared/file-tags.d.ts +2 -1
- package/dist/_vendor/shared/index.d.ts +1 -0
- package/dist/_vendor/shared/pasted-content.d.ts +0 -4
- package/dist/_vendor/shared/pixel-mark.d.ts +0 -17
- package/dist/_vendor/shared/project-glyphs.d.ts +0 -1
- package/dist/_vendor/shared/session/attachment-tile.d.ts +32 -0
- package/dist/_vendor/shared/session/stop-refusal.d.ts +15 -0
- package/dist/_vendor/shared/session/tool-row-text.d.ts +58 -0
- package/dist/_vendor/shared/session-delivery.d.ts +2 -0
- package/dist/customize/agents/agent-model-view.d.ts +11 -1
- package/dist/customize/agents/agent-model-view.js +12 -1
- package/dist/customize/agents/agent-page.js +19 -6
- package/dist/customize/agents/agent-tabs.d.ts +2 -0
- package/dist/customize/agents/agent-tabs.js +2 -0
- package/dist/customize/connectors/connectors-page.js +1 -1
- package/dist/customize/connectors/detail/connector-page.js +9 -4
- package/dist/customize/connectors/detail/connector-triggers.js +1 -1
- package/dist/customize/connectors/install/use-install.js +1 -1
- package/dist/customize/connectors/use-agent-access.d.ts +1 -0
- package/dist/customize/providers/provider-accordion.js +5 -5
- package/dist/customize/providers/provider-connect.d.ts +3 -3
- package/dist/customize/providers/provider-connect.js +8 -16
- package/dist/customize/providers/provider-sheet.js +4 -4
- package/dist/customize/sections/component/teams-byo-wizard.js +4 -1
- package/dist/customize/sections/connector-connection-form.d.ts +0 -1
- package/dist/customize/sections/connector-connection-form.js +0 -9
- package/dist/customize/sections/view/review-center-connected.js +7 -3
- package/dist/customize/settings/tabs/workspace-keys.js +53 -11
- package/dist/customize/shared/feature-gate-screen.js +1 -1
- package/dist/customize/triggers/runtime-triggers.js +13 -2
- package/dist/customize/triggers/schedule/event-account-picker.js +1 -1
- package/dist/customize/triggers/schedule/event-trigger-copy.js +1 -1
- package/dist/customize/triggers/schedule/schedule-detail-sheet.js +5 -4
- package/dist/customize/triggers/schedule/then-fields.d.ts +5 -1
- package/dist/customize/triggers/schedule/then-fields.js +23 -3
- package/dist/customize/triggers/schedule/trigger-callouts.js +1 -1
- package/dist/customize/triggers/schedule/trigger-composer-logic.d.ts +27 -0
- package/dist/customize/triggers/schedule/trigger-composer-logic.js +51 -5
- package/dist/customize/triggers/schedule/trigger-composer.js +19 -13
- package/dist/customize/triggers/schedule/trigger-edit-logic.js +25 -5
- package/dist/customize/triggers/schedule/trigger-filter.d.ts +10 -3
- package/dist/customize/triggers/schedule/trigger-filter.js +7 -6
- package/dist/customize/triggers/schedule/trigger-readonly.js +1 -1
- package/dist/customize/triggers/schedule/trigger-runs-panel.js +1 -1
- package/dist/customize/triggers/schedule/use-event-app-connect.js +2 -1
- package/dist/customize/triggers/schedule/when-event.js +1 -1
- package/dist/customize/triggers/schedule/when-schedule.d.ts +5 -1
- package/dist/customize/triggers/schedule/when-schedule.js +16 -1
- package/dist/customize/triggers/schedule-view.js +4 -2
- package/dist/i18n/en.d.ts +56 -7
- package/dist/i18n/en.js +65 -16
- package/dist/internal/billing/compute-pricing.d.ts +7 -1
- package/dist/internal/billing/compute-pricing.js +7 -1
- package/dist/internal/hooks/connectors/invalidate-connections.d.ts +10 -0
- package/dist/internal/hooks/connectors/invalidate-connections.js +18 -0
- package/dist/internal/hooks/connectors/use-finish-sign-in.js +1 -1
- package/dist/internal/hooks/connectors/use-pipedream-connect-member.js +1 -1
- package/dist/internal/hooks/connectors/use-pipedream-connect-project.js +1 -1
- package/dist/internal/hooks/projects/use-new-project-session.d.ts +2 -0
- package/dist/internal/hooks/projects/use-new-project-session.js +4 -1
- package/dist/internal/hooks/use-review-session-summary.d.ts +1 -1
- package/dist/internal/hooks/use-review-session-summary.js +1 -1
- package/dist/internal/layout/project-settings-nav.d.ts +17 -0
- package/dist/internal/layout/project-settings-nav.js +24 -0
- package/dist/internal/lib/browser-noise/rules/injected-scripts.js +2 -2
- package/dist/internal/lib/capability-tab-routes.d.ts +8 -0
- package/dist/internal/lib/capability-tab-routes.js +11 -0
- package/dist/internal/notifications/notification-inbox.d.ts +4 -10
- package/dist/internal/notifications/notification-inbox.js +8 -9
- package/dist/internal/stores/composer-prefill-store.d.ts +7 -0
- package/dist/internal/stores/composer-prefill-store.js +1 -0
- package/dist/internal/stores/connector-gate-store.d.ts +3 -1
- package/dist/internal/stores/connector-gate-store.js +13 -3
- package/dist/internal/stores/upgrade-dialog-store.d.ts +4 -0
- package/dist/internal/stores/upgrade-dialog-store.js +2 -0
- package/dist/lib/routes.d.ts +4 -11
- package/dist/lib/routes.js +3 -5
- package/dist/markdown/unified-markdown-utils.d.ts +7 -0
- package/dist/markdown/unified-markdown-utils.js +19 -0
- package/dist/markdown/unified-markdown.js +16 -3
- package/dist/primitives/alert-dialog.js +1 -1
- package/dist/primitives/dialog.js +3 -1
- package/dist/primitives/drawer.js +1 -1
- package/dist/primitives/modal.js +1 -1
- package/dist/primitives/preview-image.js +1 -1
- package/dist/primitives/sheet.js +1 -1
- package/dist/session/actions/session-label.js +2 -2
- package/dist/session/agents/agent-strip.d.ts +10 -5
- package/dist/session/agents/agent-strip.js +40 -12
- package/dist/session/agents/held-messages.d.ts +6 -2
- package/dist/session/agents/held-messages.js +6 -3
- package/dist/session/composer/ComposerCard.js +8 -3
- package/dist/session/composer/agent-selector.d.ts +2 -0
- package/dist/session/composer/agent-selector.js +5 -0
- package/dist/session/composer/attachment-tile.d.ts +2 -26
- package/dist/session/composer/attachment-tile.js +3 -47
- package/dist/session/composer/composer-chat-input.d.ts +3 -1
- package/dist/session/composer/composer-chat-input.js +2 -2
- package/dist/session/composer/composer-logic.d.ts +7 -0
- package/dist/session/composer/composer-logic.js +18 -0
- package/dist/session/composer/composer-reset.d.ts +8 -14
- package/dist/session/composer/composer-toolbar.d.ts +3 -1
- package/dist/session/composer/composer-toolbar.js +3 -3
- package/dist/session/composer/composer.d.ts +9 -0
- package/dist/session/composer/composer.js +22 -11
- package/dist/session/composer/draft/home-composer-focus-handoff.d.ts +7 -0
- package/dist/session/composer/draft/home-composer-focus-handoff.js +94 -0
- package/dist/session/composer/draft/use-composer-draft.d.ts +3 -1
- package/dist/session/composer/draft/use-composer-draft.js +22 -2
- package/dist/session/composer/editor/composer-editor.d.ts +4 -2
- package/dist/session/composer/editor/composer-editor.js +13 -7
- package/dist/session/composer/hooks/use-composer-focus.js +4 -2
- package/dist/session/header/session-site-header.d.ts +3 -1
- package/dist/session/header/session-site-header.js +3 -2
- package/dist/session/index.d.ts +1 -0
- package/dist/session/index.js +1 -0
- package/dist/session/models/chatgpt-connection-button.js +5 -9
- package/dist/session/models/connect-model-step.d.ts +29 -0
- package/dist/session/models/connect-model-step.js +50 -0
- package/dist/session/models/model-connection-gate.d.ts +2 -1
- package/dist/session/models/model-connection-gate.js +6 -3
- package/dist/session/models/model-connection-layout.d.ts +2 -0
- package/dist/session/models/model-connection-layout.js +4 -0
- package/dist/session/models/model-selector.d.ts +1 -1
- package/dist/session/models/model-selector.js +9 -6
- package/dist/session/models/subscription-offer.d.ts +4 -0
- package/dist/session/models/subscription-offer.js +11 -3
- package/dist/session/models/use-workspace-model-gate.d.ts +11 -0
- package/dist/session/models/use-workspace-model-gate.js +62 -0
- package/dist/session/models/workspace-model-gate.d.ts +46 -0
- package/dist/session/models/workspace-model-gate.js +66 -0
- package/dist/session/overrides/session-overrides-toolbar.js +2 -4
- package/dist/session/prompts/ask-deck.d.ts +5 -1
- package/dist/session/prompts/ask-deck.js +15 -3
- package/dist/session/prompts/question-labels.d.ts +16 -0
- package/dist/session/prompts/question-labels.js +34 -0
- package/dist/session/prompts/question-prompt.js +6 -6
- package/dist/session/prompts/session-connect-card.d.ts +63 -0
- package/dist/session/prompts/{session-connect-prompt.js → session-connect-card.js} +53 -42
- package/dist/session/status/provisioning-failure.d.ts +23 -2
- package/dist/session/status/provisioning-failure.js +53 -3
- package/dist/session/status/stop-refusal.d.ts +6 -12
- package/dist/session/status/stop-refusal.js +6 -19
- package/dist/session/thread/agent-run-props.d.ts +19 -0
- package/dist/session/thread/agent-run-props.js +54 -0
- package/dist/session/thread/session-chat.js +317 -298
- package/dist/session/thread/transcript.d.ts +19 -2
- package/dist/session/thread/transcript.js +93 -25
- package/dist/session/tool/tool-part-renderer.js +7 -2
- package/dist/session/tool/tools/bash-tool.d.ts +3 -52
- package/dist/session/tool/tools/bash-tool.js +3 -86
- package/dist/session/tool/tools/kortix-action-tool.js +10 -2
- package/dist/session/turn/answer-streaming.d.ts +21 -0
- package/dist/session/turn/answer-streaming.js +34 -0
- package/dist/session/turn/queued-prompt-bubbles.d.ts +5 -0
- package/dist/session/turn/queued-prompt-bubbles.js +12 -0
- package/dist/session/turn/turn-viewport.d.ts +66 -10
- package/dist/session/turn/turn-viewport.js +92 -12
- package/dist/session/turn/turn-work-accordion.d.ts +3 -1
- package/dist/session/turn/turn-work-accordion.js +2 -2
- package/dist/session/turn/user-message.js +7 -5
- package/dist/styles.css +1 -1
- package/dist/test-utils/intl.d.ts +56 -7
- package/dist/workspace/admin/project-admin-dashboard.js +2 -4
- package/dist/workspace/home/existing-repo-setup-prompt.d.ts +5 -8
- package/dist/workspace/home/existing-repo-setup-prompt.js +16 -42
- package/dist/workspace/home/first-chat.d.ts +7 -1
- package/dist/workspace/home/first-chat.js +12 -5
- package/dist/workspace/home/no-agent-home.d.ts +3 -1
- package/dist/workspace/home/no-agent-home.js +2 -2
- package/dist/workspace/inbox/workspace-inbox.d.ts +6 -16
- package/dist/workspace/inbox/workspace-inbox.js +9 -51
- package/dist/workspace/layout/project-home.js +17 -16
- package/dist/workspace/layout/use-project-home-send.d.ts +2 -0
- package/dist/workspace/layout/use-project-home-send.js +29 -15
- package/dist/workspace/new/advanced-fields.d.ts +4 -1
- package/dist/workspace/new/advanced-fields.js +2 -2
- package/dist/workspace/new/workspace-name.d.ts +9 -0
- package/dist/workspace/new/workspace-name.js +20 -0
- package/dist/workspace/projects/session-starter.d.ts +6 -4
- package/dist/workspace/projects/session-starter.js +8 -14
- package/dist/workspace/review/review-center.d.ts +6 -2
- package/dist/workspace/review/review-center.js +45 -25
- package/dist/workspace/sidebar/session-grouping.d.ts +1 -1
- package/dist/workspace/sidebar/session-grouping.js +1 -1
- package/dist/workspace/sidebar/workspace-menu-model.d.ts +3 -5
- package/dist/workspace/sidebar/workspace-menu-model.js +1 -1
- package/dist/workspace/spaces/space-details-panel.js +2 -2
- package/dist/workspace/spaces/space-triggers.js +2 -2
- package/dist/workspace/spaces/space-view.js +11 -5
- package/package.json +15 -7
- package/skills/kortix-ui/references/modules.md +1 -1
- package/dist/customize/connectors/invalidate-connections.d.ts +0 -2
- package/dist/customize/connectors/invalidate-connections.js +0 -4
- package/dist/internal/notifications/use-inbox-summary.d.ts +0 -17
- package/dist/internal/notifications/use-inbox-summary.js +0 -28
- package/dist/session/prompts/session-connect-prompt.d.ts +0 -40
|
@@ -5,7 +5,7 @@ import { Button } from '../../primitives/button.js';
|
|
|
5
5
|
import { cn } from '../../lib/utils.js';
|
|
6
6
|
import { useSessionIds } from '../../providers/session-ids.js';
|
|
7
7
|
import { useUiComponents, useUiViewerId } from '../../providers/ui-provider.js';
|
|
8
|
-
import {
|
|
8
|
+
import { useModelAccess, useProjectSession, useSessionProviderSecretPools, } from '@kortix/sdk/react';
|
|
9
9
|
import { useState } from 'react';
|
|
10
10
|
import { chatGptActionApplies } from './chatgpt-connection-action.js';
|
|
11
11
|
import { sessionPersonalUser } from '../overrides/provider-pool-draft.js';
|
|
@@ -23,22 +23,18 @@ export function ChatGptConnectionSlot({ action, className = 'mt-2 pl-7', }) {
|
|
|
23
23
|
return _jsx(ChatGptConnectionButton, { action: action, projectId: projectId, sessionId: sessionId, className: className });
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* Opens the ChatGPT accounts dialog
|
|
27
|
-
* secrets and the LLM gateway on. Shown only where connecting or
|
|
26
|
+
* Opens the ChatGPT accounts dialog. Shown only where connecting or
|
|
28
27
|
* reconnecting an account can fix this session (`chatGptActionApplies`).
|
|
29
28
|
*/
|
|
30
29
|
function ChatGptConnectionButton({ action, projectId, sessionId, className, }) {
|
|
31
30
|
const t = useTranslations('pooledSecrets');
|
|
32
31
|
const viewerId = useUiViewerId();
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const session = useProjectSession(projectId, sessionId, { enabled });
|
|
37
|
-
const pools = useSessionProviderSecretPools(enabled ? projectId : null, sessionId);
|
|
32
|
+
const access = useModelAccess(projectId);
|
|
33
|
+
const session = useProjectSession(projectId, sessionId);
|
|
34
|
+
const pools = useSessionProviderSecretPools(projectId, sessionId);
|
|
38
35
|
const [open, setOpen] = useState(false);
|
|
39
36
|
const { ProviderAccountsModal } = useUiComponents();
|
|
40
37
|
const applies = !!ProviderAccountsModal &&
|
|
41
|
-
enabled &&
|
|
42
38
|
!(access.data?.disabledProviders ?? []).includes('codex') &&
|
|
43
39
|
chatGptActionApplies({
|
|
44
40
|
action,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Where "Back to workspaces" goes: the chooser, never the door that reopens this workspace. */
|
|
2
|
+
export declare const CONNECT_MODEL_STEP_BACK_HREF = "/workspaces";
|
|
3
|
+
/**
|
|
4
|
+
* The "Connect a model" step: what every workspace page shows while the viewer
|
|
5
|
+
* can run no model (`useWorkspaceModelGate`). New workspaces land here right
|
|
6
|
+
* after setup, and the workspace opens on its own once a model works: the
|
|
7
|
+
* provider dialog's save refreshes the model list the gate reads.
|
|
8
|
+
*
|
|
9
|
+
* - The two plan tiles first (ChatGPT, Claude): most people already pay for
|
|
10
|
+
* one, and each opens the provider dialog with that provider expanded.
|
|
11
|
+
* - "Add provider key" opens the same dialog on its provider list.
|
|
12
|
+
* - "Upgrade plan" only for a viewer who may change the project's models,
|
|
13
|
+
* when the workspace's plan has no Kortix models
|
|
14
|
+
* (`model_access.requires_provider_key`) and billing is on.
|
|
15
|
+
* - Every member gets the tiles and the key: the gate is per viewer, and a
|
|
16
|
+
* member may connect a login or a key for themselves (the server refuses
|
|
17
|
+
* only a connection shared with everyone, 403). A member who cannot change
|
|
18
|
+
* the project's models also reads who can connect one for everyone.
|
|
19
|
+
*
|
|
20
|
+
* There is no skip: with no model, nothing in the workspace can run. "Back to
|
|
21
|
+
* workspaces" is the way out, to another workspace or to Log out.
|
|
22
|
+
*
|
|
23
|
+
* The host mounts the upgrade dialog (`GlobalUpgradeModal` in `apps/web`):
|
|
24
|
+
* "Upgrade plan" opens it through the upgrade store.
|
|
25
|
+
*/
|
|
26
|
+
export declare function ConnectModelStep({ projectId, workspaceName, }: {
|
|
27
|
+
projectId: string;
|
|
28
|
+
workspaceName: string | null | undefined;
|
|
29
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { CreditCardIcon, KeyIcon } from '@phosphor-icons/react';
|
|
4
|
+
import { useTranslations } from '../../i18n/index.js';
|
|
5
|
+
import { AuthFrame } from '../../internal/auth/auth-card-shell.js';
|
|
6
|
+
import { Rise, StepHeader } from '../../internal/auth/auth-primitives.js';
|
|
7
|
+
import { useAccountState } from '../../internal/billing/use-account-state.js';
|
|
8
|
+
import { Button } from '../../primitives/button.js';
|
|
9
|
+
import { UiLink } from '../../providers/ui-provider.js';
|
|
10
|
+
import { ModelConnectionLayoutContext } from './model-connection-layout.js';
|
|
11
|
+
import { ConnectPlanRows } from './subscription-offer.js';
|
|
12
|
+
import { useModelConnectionGate } from './use-model-connection-gate.js';
|
|
13
|
+
/** Where "Back to workspaces" goes: the chooser, never the door that reopens this workspace. */
|
|
14
|
+
export const CONNECT_MODEL_STEP_BACK_HREF = '/workspaces';
|
|
15
|
+
/**
|
|
16
|
+
* The "Connect a model" step: what every workspace page shows while the viewer
|
|
17
|
+
* can run no model (`useWorkspaceModelGate`). New workspaces land here right
|
|
18
|
+
* after setup, and the workspace opens on its own once a model works: the
|
|
19
|
+
* provider dialog's save refreshes the model list the gate reads.
|
|
20
|
+
*
|
|
21
|
+
* - The two plan tiles first (ChatGPT, Claude): most people already pay for
|
|
22
|
+
* one, and each opens the provider dialog with that provider expanded.
|
|
23
|
+
* - "Add provider key" opens the same dialog on its provider list.
|
|
24
|
+
* - "Upgrade plan" only for a viewer who may change the project's models,
|
|
25
|
+
* when the workspace's plan has no Kortix models
|
|
26
|
+
* (`model_access.requires_provider_key`) and billing is on.
|
|
27
|
+
* - Every member gets the tiles and the key: the gate is per viewer, and a
|
|
28
|
+
* member may connect a login or a key for themselves (the server refuses
|
|
29
|
+
* only a connection shared with everyone, 403). A member who cannot change
|
|
30
|
+
* the project's models also reads who can connect one for everyone.
|
|
31
|
+
*
|
|
32
|
+
* There is no skip: with no model, nothing in the workspace can run. "Back to
|
|
33
|
+
* workspaces" is the way out, to another workspace or to Log out.
|
|
34
|
+
*
|
|
35
|
+
* The host mounts the upgrade dialog (`GlobalUpgradeModal` in `apps/web`):
|
|
36
|
+
* "Upgrade plan" opens it through the upgrade store.
|
|
37
|
+
*/
|
|
38
|
+
export function ConnectModelStep({ projectId, workspaceName, }) {
|
|
39
|
+
const t = useTranslations('sessionUi.modelGate');
|
|
40
|
+
const { canWriteProviders, openConnectProvider, openUpgrade, showUpgradeOption, modal } = useModelConnectionGate(undefined, { projectId });
|
|
41
|
+
const accountState = useAccountState();
|
|
42
|
+
const offerUpgrade = canWriteProviders &&
|
|
43
|
+
showUpgradeOption &&
|
|
44
|
+
accountState.data?.model_access?.requires_provider_key === true;
|
|
45
|
+
const name = workspaceName?.trim() || t('stepThisWorkspace');
|
|
46
|
+
const description = canWriteProviders
|
|
47
|
+
? t(offerUpgrade ? 'stepBodyUpgrade' : 'stepBody', { workspace: name })
|
|
48
|
+
: t('stepBodyMember', { workspace: name });
|
|
49
|
+
return (_jsxs(AuthFrame, { footerVariant: "none", backHref: CONNECT_MODEL_STEP_BACK_HREF, children: [modal, _jsx(Rise, { children: _jsx(StepHeader, { title: t('stepTitle'), description: description }) }, "connect-model-header"), _jsx(Rise, { delay: 0.06, children: _jsxs("div", { className: "flex flex-col gap-5", "data-testid": "connect-model-step", children: [_jsx(ModelConnectionLayoutContext.Provider, { value: "above", children: _jsx(ConnectPlanRows, { projectId: projectId, dismissible: false, className: "sm:grid-cols-1" }) }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsxs(Button, { type: "button", variant: "outline", size: "lg", className: "w-full gap-1.5", onClick: () => openConnectProvider('providers'), children: [_jsx(KeyIcon, { className: "size-4 shrink-0" }), t('noModelAddProviderKey')] }), offerUpgrade ? (_jsxs(Button, { type: "button", variant: "outline", size: "lg", className: "w-full gap-1.5", onClick: openUpgrade, children: [_jsx(CreditCardIcon, { className: "size-4 shrink-0" }), t('noModelUpgradePlan')] })) : null, _jsx(Button, { asChild: true, variant: "ghost", size: "lg", className: "w-full", children: _jsx(UiLink, { href: CONNECT_MODEL_STEP_BACK_HREF, children: t('stepBack') }) })] })] }) }, "connect-model-body")] }));
|
|
50
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* No model can run: the composer shows the same "Connect ChatGPT" and "Connect
|
|
3
3
|
* Claude" rows the project home offers (`ConnectPlanRows`), a gap below the
|
|
4
|
-
* composer,
|
|
4
|
+
* composer by default, and above it on first-chat home. The rows are not
|
|
5
|
+
* dismissible. Sending is already disabled by `modelUnavailable`.
|
|
5
6
|
*
|
|
6
7
|
* It used to be a heading ("Connect a model to start"), two bordered tiles,
|
|
7
8
|
* "Use an API key" and "Upgrade". On the project home it stacked on top of the
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { CreditCardIcon, ImageBrokenIcon, KeyIcon } from '@phosphor-icons/react';
|
|
4
4
|
import { AnimatePresence, m, useReducedMotion } from 'motion/react';
|
|
5
|
-
import { useState } from 'react';
|
|
5
|
+
import { useContext, useState } from 'react';
|
|
6
6
|
import { useTranslations } from '../../i18n/index.js';
|
|
7
7
|
import { Button } from '../../primitives/button.js';
|
|
8
|
+
import { ModelConnectionLayoutContext } from './model-connection-layout.js';
|
|
8
9
|
import { ConnectPlanRows } from './subscription-offer.js';
|
|
9
10
|
import { useModelConnectionGate } from './use-model-connection-gate.js';
|
|
10
11
|
// Enter waits a beat (delay) so the composer paints first, then the bar slides
|
|
@@ -16,7 +17,8 @@ const BAR_EXIT = { type: 'spring', duration: 0.35, bounce: 0 };
|
|
|
16
17
|
/**
|
|
17
18
|
* No model can run: the composer shows the same "Connect ChatGPT" and "Connect
|
|
18
19
|
* Claude" rows the project home offers (`ConnectPlanRows`), a gap below the
|
|
19
|
-
* composer,
|
|
20
|
+
* composer by default, and above it on first-chat home. The rows are not
|
|
21
|
+
* dismissible. Sending is already disabled by `modelUnavailable`.
|
|
20
22
|
*
|
|
21
23
|
* It used to be a heading ("Connect a model to start"), two bordered tiles,
|
|
22
24
|
* "Use an API key" and "Upgrade". On the project home it stacked on top of the
|
|
@@ -26,7 +28,8 @@ const BAR_EXIT = { type: 'spring', duration: 0.35, bounce: 0 };
|
|
|
26
28
|
* `show` must only flip on settled data (see `entitlementsPending`).
|
|
27
29
|
*/
|
|
28
30
|
export function ModelConnectionBar({ show }) {
|
|
29
|
-
|
|
31
|
+
const above = useContext(ModelConnectionLayoutContext) === 'above';
|
|
32
|
+
return show ? (_jsxs("div", { className: above ? 'mb-4 flex flex-col gap-2' : 'mt-4 flex flex-col gap-1', children: [_jsx(NoModelReason, {}), _jsx(ConnectPlanRows, { dismissible: false })] })) : null;
|
|
30
33
|
}
|
|
31
34
|
/**
|
|
32
35
|
* Why Send is disabled, and the two ways out. A Free account sees no Kortix
|
|
@@ -82,7 +82,7 @@ export interface ModelSelectorProps {
|
|
|
82
82
|
appearance?: 'chip' | 'field' | 'inline';
|
|
83
83
|
projectId?: string;
|
|
84
84
|
/**
|
|
85
|
-
* Offer the member's own ChatGPT subscription
|
|
85
|
+
* Offer the member's own ChatGPT subscription at
|
|
86
86
|
* the end of the list. Only an interactive session can use a personal
|
|
87
87
|
* account; a scheduled or background run cannot, so its pickers leave this off.
|
|
88
88
|
*/
|
|
@@ -7,7 +7,7 @@ import { MODEL_SELECTOR_PROVIDER_IDS, ProviderLogo } from '../../internal/lib/pr
|
|
|
7
7
|
import { cn } from '../../lib/utils.js';
|
|
8
8
|
import { TRIGGER_CARET_CLASS, triggerVariants } from '../../primitives/trigger-variants.js';
|
|
9
9
|
import { useProviderModalStore } from '../../internal/stores/provider-modal-store.js';
|
|
10
|
-
import {
|
|
10
|
+
import { useModelAccess, useModelStore, } from '@kortix/sdk/react';
|
|
11
11
|
import { CheckIcon as Check, CaretDownIcon as ChevronDown, CaretRightIcon as CaretRight, CreditCardIcon as CreditCard, KeyIcon as KeyRound, PlusIcon as Plus, SlidersHorizontalIcon as SlidersHorizontal, StarIcon as Star, } from '@phosphor-icons/react';
|
|
12
12
|
import { useTranslations } from '../../i18n/index.js';
|
|
13
13
|
import { useSessionIds } from '../../providers/session-ids.js';
|
|
@@ -164,13 +164,12 @@ export function ModelSelector({ models, selectedModel, onSelect, defaultControls
|
|
|
164
164
|
const [toggledGroups, setToggledGroups] = useState(new Map());
|
|
165
165
|
const { canConnectProvider, openConnectProvider, openUpgrade, modal: connectionModal, entitlementsPending, isSelectableModel, showUpgradeOption, } = useModelConnectionGate(models);
|
|
166
166
|
const projectId = useSessionIds().projectId ?? null;
|
|
167
|
-
// Bring your own ChatGPT subscription
|
|
167
|
+
// Bring your own ChatGPT subscription. Any member
|
|
168
168
|
// connects their own account from here; Customize is not needed. Hidden when
|
|
169
169
|
// a manager disabled the ChatGPT provider for the project.
|
|
170
170
|
const tPooled = useTranslations('pooledSecrets');
|
|
171
|
-
const pooledSecrets = useFeatureFlag(projectId, 'pooled_provider_secrets');
|
|
172
171
|
const { ProviderAccountsModal } = useUiComponents();
|
|
173
|
-
const chatGptPossible = !!ProviderAccountsModal && offerProviderAccounts && !!projectId
|
|
172
|
+
const chatGptPossible = !!ProviderAccountsModal && offerProviderAccounts && !!projectId;
|
|
174
173
|
const modelAccess = useModelAccess(chatGptPossible ? projectId : null);
|
|
175
174
|
const chatGptAvailable = chatGptPossible && !(modelAccess.data?.disabledProviders ?? []).includes('codex');
|
|
176
175
|
const [chatGptOpen, setChatGptOpen] = useState(false);
|
|
@@ -189,6 +188,10 @@ export function ModelSelector({ models, selectedModel, onSelect, defaultControls
|
|
|
189
188
|
m.modelID === availableSelectedModel?.modelID);
|
|
190
189
|
// The pill names the model, never its plan suffix: "GPT-6 Luna", not "GPT-6 Luna (ChatGPT)".
|
|
191
190
|
const displayName = (current && pickerModelName(current)) || unsetLabel || t('noModel');
|
|
191
|
+
const triggerLoading = !current && (modelsLoading || entitlementsPending);
|
|
192
|
+
const triggerLabel = triggerLoading
|
|
193
|
+
? _jsx("span", { className: "bg-primary/10 inline-block h-3.5 w-20 animate-pulse rounded-md", "aria-hidden": "true" })
|
|
194
|
+
: displayName;
|
|
192
195
|
// A subscription model names the login that pays for it: the picker grows a
|
|
193
196
|
// subscription pane under the list (both appearances), so switching the
|
|
194
197
|
// ChatGPT or Claude plan a turn runs on needs no trip to Customize.
|
|
@@ -383,10 +386,10 @@ export function ModelSelector({ models, selectedModel, onSelect, defaultControls
|
|
|
383
386
|
// No hairlines in a host pane: the search is a filled field, groups part by space.
|
|
384
387
|
'[&_[data-slot=command-input-wrapper]]:bg-muted [&_[data-slot=command-input-wrapper]]:mx-2 [&_[data-slot=command-input-wrapper]]:h-8 [&_[data-slot=command-input-wrapper]]:gap-2 [&_[data-slot=command-input-wrapper]]:rounded-md [&_[data-slot=command-input-wrapper]]:border-b-0 [&_[data-slot=command-input-wrapper]]:px-2.5', '[&_[data-slot=command-input]]:h-8 [&_[data-slot=command-input]]:text-sm', '[&_[data-slot=command-separator]]:hidden [&_[data-slot=command-group]]:py-1'), children: listBody }), subscriptionNode] })] }));
|
|
385
388
|
}
|
|
386
|
-
return (_jsxs(_Fragment, { children: [modals, _jsxs(CommandPopover, { open: disabled ? false : open, onOpenChange: (next) => !disabled && setOpen(next), children: [_jsx(CommandPopoverTrigger, { children: appearance === 'field' ? (_jsxs("button", { type: "button", disabled: disabled, className: cn(triggerVariants(), 'h-9 w-full'), children: [_jsx("span", { className: "truncate", children:
|
|
389
|
+
return (_jsxs(_Fragment, { children: [modals, _jsxs(CommandPopover, { open: disabled ? false : open, onOpenChange: (next) => !disabled && setOpen(next), children: [_jsx(CommandPopoverTrigger, { children: appearance === 'field' ? (_jsxs("button", { type: "button", disabled: disabled, "aria-label": triggerLoading ? tModel('loading') : undefined, className: cn(triggerVariants(), 'h-9 w-full'), children: [_jsx("span", { className: "truncate", children: triggerLabel }), disabled ? null : _jsx(ChevronDown, { className: cn(TRIGGER_CARET_CLASS, 'size-4') })] })) : (_jsxs(Button, { type: "button", "aria-label": triggerLoading ? tModel('loading') : undefined, variant: triggerVariant, size: "sm",
|
|
387
390
|
// `min-w-0 shrink`: in a narrow toolbar (a channel's thread panel) the
|
|
388
391
|
// model name truncates; the controls beside it keep their width.
|
|
389
|
-
className: cn('min-w-0 shrink rounded-lg hit-area-y-3', triggerVariant === 'ghost' && 'text-muted-foreground'), children: [_jsx("span", { className: cn('max-w-30 truncate', triggerLabelClassName), children:
|
|
392
|
+
className: cn('min-w-0 shrink rounded-lg hit-area-y-3', triggerVariant === 'ghost' && 'text-muted-foreground'), children: [_jsx("span", { className: cn('max-w-30 truncate', triggerLabelClassName), children: triggerLabel }), showEffort && (_jsx("span", { className: "shrink-0", children: currentEffort ? effortLabel(currentEffort) : t('auto') })), _jsx(ChevronDown, { className: cn('duration-moderate size-3 transition-transform ease-out', open && 'rotate-180') })] })) }), _jsx(CommandPopoverContent, { side: "top", align: "start", sideOffset: 8, className: showEffort
|
|
390
393
|
? 'w-[min(38rem,calc(100vw-1.5rem))]'
|
|
391
394
|
: 'w-[min(28rem,calc(100vw-1.5rem))]', children: _jsxs("div", { className: "flex min-w-0 flex-col", children: [_jsx(ModelPickerPanel, { browseModels: browseModels, pickableModels: pickableModels, searchModels: visibleModels, search: search, onSearchChange: setSearch, searchRight: searchRight, selected: availableSelectedModel ?? null, onPick: handleSelect, isFavorite: pickerModelStore.isFavorite, setFavorite: pickerModelStore.setFavorite, loading: modelsLoading || entitlementsPending, emptyState: noModelsState, searchEmpty: searchEmptyState, onConnectChatGpt: chatGptAvailable ? handleOpenChatGpt : undefined, onForeignDialog: closePicker, connectLabel: tPooled('connect'), effort: showEffort
|
|
392
395
|
? {
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
* arrow under its send button (`pr-3.5`), so the host must place the rows at
|
|
9
9
|
* the composer card's width.
|
|
10
10
|
*
|
|
11
|
+
* Above the composer (`ModelConnectionLayoutContext`, first-chat home only)
|
|
12
|
+
* the two plans render as side-by-side bordered tiles, the plan on a second
|
|
13
|
+
* line, so they read as the first step rather than as suggestions.
|
|
14
|
+
*
|
|
11
15
|
* `dismissible`: hovering a row swaps its arrow for a ✕ in the same slot. The ✕
|
|
12
16
|
* hides that row for this project in this browser (`localStorage`). Only the
|
|
13
17
|
* optional offer is dismissible; with no model at all there is nothing else to
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useWorkspaceModels } from '@kortix/sdk/react';
|
|
4
|
-
import { useState } from 'react';
|
|
4
|
+
import { useContext, useState } from 'react';
|
|
5
5
|
import { useTranslations } from '../../i18n/index.js';
|
|
6
6
|
import { Close } from '../../icons/close.js';
|
|
7
7
|
import { SolidRightArrow } from '../../icons/solid-right-arrow.js';
|
|
@@ -9,6 +9,7 @@ import { ClaudeCode } from '../../internal/icons/claude-code.js';
|
|
|
9
9
|
import { ProviderLogo } from '../../internal/lib/provider-branding.js';
|
|
10
10
|
import { cn } from '../../internal/lib/utils.js';
|
|
11
11
|
import { hasRunnableSubscriptionModel, isRunnableModel } from './model-availability.js';
|
|
12
|
+
import { ModelConnectionLayoutContext } from './model-connection-layout.js';
|
|
12
13
|
import { useModelConnectionGate } from './use-model-connection-gate.js';
|
|
13
14
|
const PLANS = [
|
|
14
15
|
{ providerId: 'openai', name: 'ChatGPT', labelKey: 'connectChatGpt', planKey: 'chatGptPlan' },
|
|
@@ -47,6 +48,10 @@ function writeDismissed(projectId, ids) {
|
|
|
47
48
|
* arrow under its send button (`pr-3.5`), so the host must place the rows at
|
|
48
49
|
* the composer card's width.
|
|
49
50
|
*
|
|
51
|
+
* Above the composer (`ModelConnectionLayoutContext`, first-chat home only)
|
|
52
|
+
* the two plans render as side-by-side bordered tiles, the plan on a second
|
|
53
|
+
* line, so they read as the first step rather than as suggestions.
|
|
54
|
+
*
|
|
50
55
|
* `dismissible`: hovering a row swaps its arrow for a ✕ in the same slot. The ✕
|
|
51
56
|
* hides that row for this project in this browser (`localStorage`). Only the
|
|
52
57
|
* optional offer is dismissible; with no model at all there is nothing else to
|
|
@@ -55,6 +60,7 @@ function writeDismissed(projectId, ids) {
|
|
|
55
60
|
* `projectId` omitted: the gate reads the `[id]` route segment.
|
|
56
61
|
*/
|
|
57
62
|
export function ConnectPlanRows({ projectId, dismissible, className, }) {
|
|
63
|
+
const above = useContext(ModelConnectionLayoutContext) === 'above';
|
|
58
64
|
const t = useTranslations('sessionUi.modelGate');
|
|
59
65
|
const { canConnectProvider, openConnectProvider, modal } = useModelConnectionGate(undefined, projectId === undefined ? undefined : { projectId });
|
|
60
66
|
const [dismissed, setDismissed] = useState(() => dismissible ? readDismissed(projectId) : []);
|
|
@@ -65,9 +71,11 @@ export function ConnectPlanRows({ projectId, dismissible, className, }) {
|
|
|
65
71
|
if (projectId)
|
|
66
72
|
writeDismissed(projectId, next);
|
|
67
73
|
};
|
|
68
|
-
return (_jsxs(_Fragment, { children: [modal, canConnectProvider && plans.length > 0 ? (_jsx("div", { role: "group", "aria-label": t('offerTitle'), className: cn('flex flex-col', className), children: plans.map((plan) => (_jsxs("div", { className: "group relative", children: [_jsxs("button", { type: "button", onClick: () => openConnectProvider('providers', plan.providerId), className:
|
|
74
|
+
return (_jsxs(_Fragment, { children: [modal, canConnectProvider && plans.length > 0 ? (_jsx("div", { role: "group", "aria-label": t('offerTitle'), className: cn(above ? 'grid grid-cols-1 gap-2 sm:grid-cols-2' : 'flex flex-col', className), children: plans.map((plan) => (_jsxs("div", { className: "group relative", children: [_jsxs("button", { type: "button", onClick: () => openConnectProvider('providers', plan.providerId), className: cn('hover:bg-muted/60 focus-visible:ring-kortix-base flex w-full min-w-0 items-center gap-3 rounded-lg pr-3.5 text-left transition-colors outline-none focus-visible:ring-[0.6px]',
|
|
75
|
+
// Above the composer: a bordered tile, the plan on a second line.
|
|
76
|
+
above ? 'border-border bg-popover border py-2.5 pl-3' : 'py-2 pl-2.5'), children: [plan.providerId === 'anthropic' ? (
|
|
69
77
|
// Claude plans run through Claude Code, so the row shows its mark.
|
|
70
|
-
_jsx(ClaudeCode, { className: "size-5 shrink-0" })) : (_jsx(ProviderLogo, { providerID: plan.providerId, size: "xs", className: "size-5 [&_img]:size-5" })), _jsx("span", { className: "text-foreground shrink-0 text-sm", children: t(plan.labelKey) }), _jsx("span", { className: "text-muted-foreground truncate text-sm", children: t(plan.planKey) }), _jsx(SolidRightArrow, { className: cn('text-muted-foreground ml-auto size-4 shrink-0 transition-opacity', dismissible && 'group-focus-within:opacity-0 group-hover:opacity-0') })] }), dismissible ? (
|
|
78
|
+
_jsx(ClaudeCode, { className: "size-5 shrink-0" })) : (_jsx(ProviderLogo, { providerID: plan.providerId, size: "xs", className: "size-5 [&_img]:size-5" })), above ? (_jsxs("span", { className: "flex min-w-0 flex-col", children: [_jsx("span", { className: "text-foreground truncate text-sm leading-5", children: t(plan.labelKey) }), _jsx("span", { className: "text-muted-foreground truncate text-xs leading-4", children: t(plan.planKey) })] })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "text-foreground shrink-0 text-sm", children: t(plan.labelKey) }), _jsx("span", { className: "text-muted-foreground truncate text-sm", children: t(plan.planKey) })] })), _jsx(SolidRightArrow, { className: cn('text-muted-foreground ml-auto size-4 shrink-0 transition-opacity', dismissible && 'group-focus-within:opacity-0 group-hover:opacity-0') })] }), dismissible ? (
|
|
71
79
|
// A sibling, not a child: a button cannot hold a button. It sits
|
|
72
80
|
// over the arrow's slot — `w-11` is `pr-3.5` + the arrow +
|
|
73
81
|
// `pr-3.5` — so the ✕ centres where the arrow was.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type WorkspaceModelGateView } from './workspace-model-gate.js';
|
|
2
|
+
/**
|
|
3
|
+
* Whether `projectId` may open for the signed-in viewer: `'open'`,
|
|
4
|
+
* `'pending'` (no answer yet, and this browser never saw it ready) or
|
|
5
|
+
* `'blocked'` (no model can run). See `workspace-model-gate.ts` for the rules.
|
|
6
|
+
*
|
|
7
|
+
* Reads `/model-picker` through its shared cache entry
|
|
8
|
+
* (`qk.project.modelPicker`), the one the composer, the model picker and the
|
|
9
|
+
* shell prefetch read, so it adds no request to a workspace load.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useWorkspaceModelGate(projectId: string): WorkspaceModelGateView;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useQuery } from '@tanstack/react-query';
|
|
3
|
+
import { useEffect, useMemo } from 'react';
|
|
4
|
+
import { getWorkspaceModelPicker } from '@kortix/sdk';
|
|
5
|
+
import { contract, flattenModels, projectLlmCatalogToProviderList, qk, useFeatureFlag, } from '@kortix/sdk/react';
|
|
6
|
+
import { useUiViewerId } from '../../providers/ui-provider.js';
|
|
7
|
+
import { isRunnableModel } from './model-availability.js';
|
|
8
|
+
import { readModelReady, resolveWorkspaceModelGate, writeModelReady, } from './workspace-model-gate.js';
|
|
9
|
+
/**
|
|
10
|
+
* While the workspace is blocked, re-read the model list on this cadence, so a
|
|
11
|
+
* connection made elsewhere (another tab, another device, a person who manages
|
|
12
|
+
* the workspace) opens it without a reload. The same cadence as the access
|
|
13
|
+
* gate's approval poll. A connection made on this screen does not wait for
|
|
14
|
+
* it: the provider dialog's save invalidates the same query at once
|
|
15
|
+
* (`refreshWorkspaceProviderState`).
|
|
16
|
+
*/
|
|
17
|
+
const BLOCKED_RECHECK_MS = 15_000;
|
|
18
|
+
/**
|
|
19
|
+
* Whether `projectId` may open for the signed-in viewer: `'open'`,
|
|
20
|
+
* `'pending'` (no answer yet, and this browser never saw it ready) or
|
|
21
|
+
* `'blocked'` (no model can run). See `workspace-model-gate.ts` for the rules.
|
|
22
|
+
*
|
|
23
|
+
* Reads `/model-picker` through its shared cache entry
|
|
24
|
+
* (`qk.project.modelPicker`), the one the composer, the model picker and the
|
|
25
|
+
* shell prefetch read, so it adds no request to a workspace load.
|
|
26
|
+
*/
|
|
27
|
+
export function useWorkspaceModelGate(projectId) {
|
|
28
|
+
const viewerId = useUiViewerId();
|
|
29
|
+
// A program agent runs code instead of a model (flag `program_agents`), so a
|
|
30
|
+
// project that turned them on may work with no model at all.
|
|
31
|
+
const programAgents = useFeatureFlag(projectId, 'program_agents').enabled;
|
|
32
|
+
const enabled = !!projectId && !programAgents;
|
|
33
|
+
const query = useQuery({
|
|
34
|
+
queryKey: qk.project.modelPicker(projectId),
|
|
35
|
+
queryFn: () => getWorkspaceModelPicker(projectId),
|
|
36
|
+
enabled,
|
|
37
|
+
...contract('config'),
|
|
38
|
+
retry: false,
|
|
39
|
+
refetchInterval: (current) => current.state.data && !flattenCatalog(current.state.data).some(isRunnableModel)
|
|
40
|
+
? BLOCKED_RECHECK_MS
|
|
41
|
+
: false,
|
|
42
|
+
});
|
|
43
|
+
const models = useMemo(() => (query.data ? flattenCatalog(query.data) : undefined), [query.data]);
|
|
44
|
+
// Read once per viewer and workspace: the write below must not flip a
|
|
45
|
+
// decision that is already on screen.
|
|
46
|
+
const rememberedReady = useMemo(() => readModelReady(viewerId, projectId), [viewerId, projectId]);
|
|
47
|
+
const view = resolveWorkspaceModelGate({
|
|
48
|
+
enabled,
|
|
49
|
+
models,
|
|
50
|
+
failed: query.isError,
|
|
51
|
+
rememberedReady,
|
|
52
|
+
});
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
// Only a server answer is recorded; a remembered or failed-open verdict is not.
|
|
55
|
+
if (enabled && models)
|
|
56
|
+
writeModelReady(viewerId, projectId, view === 'open');
|
|
57
|
+
}, [enabled, models, projectId, view, viewerId]);
|
|
58
|
+
return view;
|
|
59
|
+
}
|
|
60
|
+
function flattenCatalog(catalog) {
|
|
61
|
+
return flattenModels(projectLlmCatalogToProviderList(catalog));
|
|
62
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The workspace model gate: a workspace opens only when the viewer can run at
|
|
3
|
+
* least one model. Without one, every workspace page shows the "Connect a
|
|
4
|
+
* model" step instead (`apps/web` `ConnectModelScreen`).
|
|
5
|
+
*
|
|
6
|
+
* "Can run a model" is the composer's own test (`isRunnableModel`) over the
|
|
7
|
+
* server-resolved `/model-picker` list. That list already applies the plan
|
|
8
|
+
* (a Free account sees no Kortix model), the viewer's own Claude login, the
|
|
9
|
+
* project's ChatGPT login and keys, and the model switches. So a Credits or
|
|
10
|
+
* Enterprise workspace opens on Kortix models, and a Free workspace opens once
|
|
11
|
+
* a ChatGPT plan, a Claude plan or an API key is connected.
|
|
12
|
+
*
|
|
13
|
+
* Pure and framework-free: the hook (`use-workspace-model-gate.ts`) feeds it.
|
|
14
|
+
*/
|
|
15
|
+
export type WorkspaceModelGateView = 'open' | 'pending' | 'blocked';
|
|
16
|
+
export interface WorkspaceModelGateInput {
|
|
17
|
+
/** False turns the gate off: no project yet, or the project runs program agents. */
|
|
18
|
+
enabled: boolean;
|
|
19
|
+
/** The flattened `/model-picker` list, or `undefined` while no answer is in. */
|
|
20
|
+
models: ReadonlyArray<{
|
|
21
|
+
enabled?: boolean;
|
|
22
|
+
available?: boolean;
|
|
23
|
+
}> | undefined;
|
|
24
|
+
/** The `/model-picker` read failed and holds no answer. */
|
|
25
|
+
failed: boolean;
|
|
26
|
+
/** This browser saw a runnable model in this workspace for this viewer before. */
|
|
27
|
+
rememberedReady: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* - A settled answer decides: one runnable model opens the workspace, none
|
|
31
|
+
* blocks it.
|
|
32
|
+
* - A failed read opens the workspace. The server still refuses a session with
|
|
33
|
+
* no model (`no_model_available`), so an outage of `/model-picker` must not
|
|
34
|
+
* lock every workspace.
|
|
35
|
+
* - No answer yet: a workspace this browser saw ready opens at once (no wait
|
|
36
|
+
* on every load); any other waits, so a blocked workspace never flashes.
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolveWorkspaceModelGate(input: WorkspaceModelGateInput): WorkspaceModelGateView;
|
|
39
|
+
/**
|
|
40
|
+
* Whether this browser saw a runnable model for this viewer in this workspace.
|
|
41
|
+
* A per-viewer hint that only skips the wait; the server answer always wins.
|
|
42
|
+
* False when storage is blocked (private mode, a preview frame).
|
|
43
|
+
*/
|
|
44
|
+
export declare function readModelReady(viewerId: string | null | undefined, projectId: string): boolean;
|
|
45
|
+
/** Record the server's answer, so the next load of this workspace waits only when it was blocked. */
|
|
46
|
+
export declare function writeModelReady(viewerId: string | null | undefined, projectId: string, ready: boolean): void;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The workspace model gate: a workspace opens only when the viewer can run at
|
|
3
|
+
* least one model. Without one, every workspace page shows the "Connect a
|
|
4
|
+
* model" step instead (`apps/web` `ConnectModelScreen`).
|
|
5
|
+
*
|
|
6
|
+
* "Can run a model" is the composer's own test (`isRunnableModel`) over the
|
|
7
|
+
* server-resolved `/model-picker` list. That list already applies the plan
|
|
8
|
+
* (a Free account sees no Kortix model), the viewer's own Claude login, the
|
|
9
|
+
* project's ChatGPT login and keys, and the model switches. So a Credits or
|
|
10
|
+
* Enterprise workspace opens on Kortix models, and a Free workspace opens once
|
|
11
|
+
* a ChatGPT plan, a Claude plan or an API key is connected.
|
|
12
|
+
*
|
|
13
|
+
* Pure and framework-free: the hook (`use-workspace-model-gate.ts`) feeds it.
|
|
14
|
+
*/
|
|
15
|
+
import { isRunnableModel } from './model-availability.js';
|
|
16
|
+
/**
|
|
17
|
+
* - A settled answer decides: one runnable model opens the workspace, none
|
|
18
|
+
* blocks it.
|
|
19
|
+
* - A failed read opens the workspace. The server still refuses a session with
|
|
20
|
+
* no model (`no_model_available`), so an outage of `/model-picker` must not
|
|
21
|
+
* lock every workspace.
|
|
22
|
+
* - No answer yet: a workspace this browser saw ready opens at once (no wait
|
|
23
|
+
* on every load); any other waits, so a blocked workspace never flashes.
|
|
24
|
+
*/
|
|
25
|
+
export function resolveWorkspaceModelGate(input) {
|
|
26
|
+
if (!input.enabled)
|
|
27
|
+
return 'open';
|
|
28
|
+
if (input.models)
|
|
29
|
+
return input.models.some(isRunnableModel) ? 'open' : 'blocked';
|
|
30
|
+
if (input.failed)
|
|
31
|
+
return 'open';
|
|
32
|
+
return input.rememberedReady ? 'open' : 'pending';
|
|
33
|
+
}
|
|
34
|
+
const READY_KEY_PREFIX = 'kortix:model-ready:';
|
|
35
|
+
function readyKey(viewerId, projectId) {
|
|
36
|
+
return `${READY_KEY_PREFIX}${viewerId}:${projectId}`;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Whether this browser saw a runnable model for this viewer in this workspace.
|
|
40
|
+
* A per-viewer hint that only skips the wait; the server answer always wins.
|
|
41
|
+
* False when storage is blocked (private mode, a preview frame).
|
|
42
|
+
*/
|
|
43
|
+
export function readModelReady(viewerId, projectId) {
|
|
44
|
+
if (!viewerId || !projectId || typeof window === 'undefined')
|
|
45
|
+
return false;
|
|
46
|
+
try {
|
|
47
|
+
return window.localStorage.getItem(readyKey(viewerId, projectId)) === '1';
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** Record the server's answer, so the next load of this workspace waits only when it was blocked. */
|
|
54
|
+
export function writeModelReady(viewerId, projectId, ready) {
|
|
55
|
+
if (!viewerId || !projectId || typeof window === 'undefined')
|
|
56
|
+
return;
|
|
57
|
+
try {
|
|
58
|
+
if (ready)
|
|
59
|
+
window.localStorage.setItem(readyKey(viewerId, projectId), '1');
|
|
60
|
+
else
|
|
61
|
+
window.localStorage.removeItem(readyKey(viewerId, projectId));
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// Storage blocked: every load waits for the answer, which is still correct.
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -125,12 +125,11 @@ export function SessionOverridesToolbar({ projectId, sessionId, agentName, onCom
|
|
|
125
125
|
const tI18nComplete = useTranslations('hardcodedUi.i18nComplete');
|
|
126
126
|
const tPooled = useTranslations('pooledSecrets');
|
|
127
127
|
const tScope = useTranslations('sessionScope');
|
|
128
|
-
const pooledSecretsEnabled = useFeatureFlag(projectId, 'pooled_provider_secrets').enabled;
|
|
129
128
|
const drivesEnabled = useFeatureFlag(projectId, 'drives').enabled;
|
|
130
129
|
const tDrives = useTranslations('drives');
|
|
131
130
|
// Drives mount when the sandbox is created: an unsent session has none.
|
|
132
131
|
const sessionDrives = useSessionDrives(projectId, drivesEnabled ? sessionId : undefined);
|
|
133
|
-
const providerPools = useSessionProviderSecretPools(
|
|
132
|
+
const providerPools = useSessionProviderSecretPools(projectId, sessionId);
|
|
134
133
|
// `project.secret.read` is a manager-tier leaf. Without it the catalog reads
|
|
135
134
|
// `unavailable`, and the row only ever said "Secret access is unavailable" —
|
|
136
135
|
// an axis the viewer can neither see nor change. Drop it on a SETTLED denial;
|
|
@@ -291,7 +290,7 @@ export function SessionOverridesToolbar({ projectId, sessionId, agentName, onCom
|
|
|
291
290
|
// card it showed. Credentials are not a session-minting decision: the agent
|
|
292
291
|
// may use every account it is entitled to and names one at call time
|
|
293
292
|
// (`kortix connectors call --account`, `accounts` to see them).
|
|
294
|
-
if (
|
|
293
|
+
if (managesSession && (!secretsDenied || (!!sessionId && providerPools.data?.can_edit === true)))
|
|
295
294
|
list.push(providerKeysRow(projectId, sessionId, providerPoolDraft, providerDrafts, providerPools.isError, providerPools.isLoading, saving, onProviderDraftChange, onProviderSecretPoolsChange, tPooled));
|
|
296
295
|
list.push(sandboxRow(sandboxSlot, sandbox, tI18nComplete));
|
|
297
296
|
if (sessionId && drivesEnabled) {
|
|
@@ -314,7 +313,6 @@ export function SessionOverridesToolbar({ projectId, sessionId, agentName, onCom
|
|
|
314
313
|
controlsDisabled,
|
|
315
314
|
draft,
|
|
316
315
|
onChange,
|
|
317
|
-
pooledSecretsEnabled,
|
|
318
316
|
managesSession,
|
|
319
317
|
providerPoolDraft,
|
|
320
318
|
providerDrafts,
|
|
@@ -23,8 +23,12 @@ import { type ReactNode } from 'react';
|
|
|
23
23
|
export declare const DECK_KINDS: ReadonlySet<SessionAsk['kind']>;
|
|
24
24
|
/** The deck's order: oldest first, skipped asks after the rest. Pure; exported for tests. */
|
|
25
25
|
export declare function deckOrder(asks: readonly SessionAsk[], skipped: readonly string[], hidden: ReadonlySet<string>): SessionAsk[];
|
|
26
|
-
export declare function AskDeck({ projectId, onOpenSession, empty, paused, }: {
|
|
26
|
+
export declare function AskDeck({ projectId, onOpenSession, empty, paused, selectedAskId, onClearSelection, onHiddenAskIdsChange, onCurrentAskChange, }: {
|
|
27
27
|
projectId: string;
|
|
28
|
+
selectedAskId?: string | null;
|
|
29
|
+
onClearSelection?: () => void;
|
|
30
|
+
onHiddenAskIdsChange?: (ids: ReadonlySet<string>) => void;
|
|
31
|
+
onCurrentAskChange?: (id: string | null) => void;
|
|
28
32
|
/** The host shows something else over the deck: it draws nothing and its
|
|
29
33
|
* keys answer nothing, but stays mounted so staged answers keep Undo. */
|
|
30
34
|
paused?: boolean;
|
|
@@ -63,7 +63,7 @@ export function deckOrder(asks, skipped, hidden) {
|
|
|
63
63
|
return a.asked_at < b.asked_at ? -1 : a.asked_at > b.asked_at ? 1 : 0;
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
|
-
export function AskDeck({ projectId, onOpenSession, empty, paused = false, }) {
|
|
66
|
+
export function AskDeck({ projectId, onOpenSession, empty, paused = false, selectedAskId, onClearSelection, onHiddenAskIdsChange, onCurrentAskChange, }) {
|
|
67
67
|
const t = useTranslations('hardcodedUi.askDeck');
|
|
68
68
|
const queryClient = useQueryClient();
|
|
69
69
|
const { data, isLoading, isError, refetch } = useSessionAsks(projectId);
|
|
@@ -71,9 +71,15 @@ export function AskDeck({ projectId, onOpenSession, empty, paused = false, }) {
|
|
|
71
71
|
const [skipped, setSkipped] = useState([]);
|
|
72
72
|
const staged = useRef(new Map());
|
|
73
73
|
const [hidden, setHidden] = useState(new Set());
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
onHiddenAskIdsChange?.(hidden);
|
|
76
|
+
}, [hidden, onHiddenAskIdsChange]);
|
|
74
77
|
// Connector approvals keep the full parameter review in the inbox list below.
|
|
75
78
|
const deck = useMemo(() => deckOrder((data?.asks ?? []).filter((ask) => DECK_KINDS.has(ask.kind)), skipped, hidden), [data, skipped, hidden]);
|
|
76
|
-
const current = deck[0] ?? null;
|
|
79
|
+
const current = deck.find((ask) => ask.id === selectedAskId) ?? deck[0] ?? null;
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
onCurrentAskChange?.(paused ? null : current?.id ?? null);
|
|
82
|
+
}, [current?.id, paused, onCurrentAskChange]);
|
|
77
83
|
const send = useCallback(async (entry) => {
|
|
78
84
|
staged.current.delete(entry.ask.id);
|
|
79
85
|
try {
|
|
@@ -164,7 +170,13 @@ export function AskDeck({ projectId, onOpenSession, empty, paused = false, }) {
|
|
|
164
170
|
return empty;
|
|
165
171
|
return _jsx(EmptyState, { icon: CheckIcon, title: t('emptyTitle'), description: t('emptyDescription') });
|
|
166
172
|
}
|
|
167
|
-
return (_jsxs("section", { "aria-label": t('label'), className: "flex w-full flex-col gap-3", children: [_jsxs("div", { className: "text-muted-foreground flex items-center justify-between text-xs", children: [_jsx("span", { children: t('remaining', { count: deck.length }) }), _jsxs("span", { className: "hidden items-center gap-2 sm:flex", children: [_jsx(Kbd, { children: "\u2190" }), " ", t('no'), " ", _jsx(Kbd, { children: "\u2192" }), " ", t('yes'), " ", _jsx(Kbd, { children: "S" }), " ", t('skip')] })] }), _jsx(AskCard, { ask: current, onDecide: (verdict, answers) =>
|
|
173
|
+
return (_jsxs("section", { "aria-label": t('label'), className: "flex w-full flex-col gap-3", children: [_jsxs("div", { className: "text-muted-foreground flex items-center justify-between text-xs", children: [_jsx("span", { children: t('remaining', { count: deck.length }) }), _jsxs("span", { className: "hidden items-center gap-2 sm:flex", children: [_jsx(Kbd, { children: "\u2190" }), " ", t('no'), " ", _jsx(Kbd, { children: "\u2192" }), " ", t('yes'), " ", _jsx(Kbd, { children: "S" }), " ", t('skip')] })] }), _jsx(AskCard, { ask: current, onDecide: (verdict, answers) => {
|
|
174
|
+
onClearSelection?.();
|
|
175
|
+
decide(current, verdict, answers);
|
|
176
|
+
}, onSkip: () => {
|
|
177
|
+
onClearSelection?.();
|
|
178
|
+
skip(current);
|
|
179
|
+
}, onOpenSession: onOpenSession }, current.id)] }));
|
|
168
180
|
}
|
|
169
181
|
/**
|
|
170
182
|
* One ask, drawn exactly as the session draws it: the docked strip holds the
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { QuestionInfo } from '../../internal/session-types/index.js';
|
|
2
|
+
/** A question's text as one plain line: the first non-empty line, markdown marks removed. */
|
|
3
|
+
export declare function questionPlainLine(question: string): string;
|
|
4
|
+
/**
|
|
5
|
+
* The label of each row on the Confirm tab, and whether the rows stack.
|
|
6
|
+
*
|
|
7
|
+
* A header labels its row only when no other question in the call shares it.
|
|
8
|
+
* An agent that gives every question the same header (the stage name, "You")
|
|
9
|
+
* would otherwise label every row "You". A row without a distinct header
|
|
10
|
+
* shows its question text instead, and then the rows stack (label above the
|
|
11
|
+
* answer), because a question does not fit the narrow label column.
|
|
12
|
+
*/
|
|
13
|
+
export declare function confirmRowLabels(questions: Pick<QuestionInfo, 'header' | 'question'>[]): {
|
|
14
|
+
labels: string[];
|
|
15
|
+
stacked: boolean;
|
|
16
|
+
};
|