@kortix/ui 0.15.7 → 0.15.8
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 +7 -7
- package/dist/_vendor/kortix-shared.js +36 -1
- package/dist/_vendor/shared/my-kortix-agent.d.ts +7 -0
- package/dist/_vendor/shared/pixel-mark.d.ts +18 -0
- package/dist/customize/connectors/catalog/connector-categories.d.ts +2 -2
- package/dist/customize/connectors/catalog/connector-categories.js +2 -2
- package/dist/customize/connectors/detail/connector-modal.js +1 -1
- package/dist/customize/sections/gateway-view.d.ts +1 -1
- package/dist/customize/sections/gateway-view.js +1 -1
- package/dist/customize/sections/view/account-secret-resources-panel.js +4 -2
- package/dist/customize/sections/view/agent-editor-basics-fields.js +1 -1
- package/dist/customize/sections/view/gateway/gateway-logs.d.ts +1 -1
- package/dist/customize/sections/view/git-view.js +1 -1
- package/dist/customize/sections/view/permission-editor.js +1 -1
- package/dist/customize/sections/view/subscription-usage.d.ts +3 -32
- package/dist/customize/sections/view/subscription-usage.js +2 -86
- package/dist/customize/shared/entity/entity-modal.js +8 -10
- package/dist/files/project/components/drive-toolbar.d.ts +1 -1
- package/dist/files/project/components/drive-toolbar.js +1 -1
- package/dist/files/project/store/version-store.d.ts +1 -1
- package/dist/files/renderers/shared/scroll-area-compat.d.ts +6 -6
- package/dist/files/renderers/shared/scroll-area-compat.js +7 -9
- package/dist/files/renderers/shared/select-compat.js +3 -7
- package/dist/files/viewer/file-preview-modal.d.ts +10 -11
- package/dist/files/viewer/file-preview-modal.js +17 -18
- package/dist/i18n/en.d.ts +3 -0
- package/dist/i18n/en.js +7 -4
- package/dist/index.js +1 -1
- package/dist/internal/account-hub/account-hub-location.js +2 -2
- package/dist/internal/account-hub/use-account-members.d.ts +28 -1
- package/dist/internal/account-hub/use-account-members.js +27 -10
- package/dist/internal/components/agent-mark.d.ts +1 -8
- package/dist/internal/components/agent-mark.js +2 -19
- package/dist/internal/lib/navigation/modified-click.js +2 -2
- package/dist/internal/lib/pixel-mark.d.ts +3 -20
- package/dist/internal/lib/pixel-mark.js +3 -34
- package/dist/internal/stores/active-space-store.d.ts +1 -1
- package/dist/internal/stores/browser-recents-store.d.ts +1 -1
- package/dist/internal/stores/current-account-store.d.ts +1 -1
- package/dist/internal/stores/first-chat-store.d.ts +1 -1
- package/dist/internal/stores/mobile-app-promo-store.d.ts +1 -1
- package/dist/internal/stores/session-browser-store.d.ts +1 -1
- package/dist/internal/stores/session-expanded-store.d.ts +1 -1
- package/dist/internal/stores/session-filter-store.d.ts +1 -1
- package/dist/internal/stores/session-history-view-store.d.ts +1 -1
- package/dist/internal/stores/session-hover-store.d.ts +1 -1
- package/dist/internal/stores/session-hover-store.js +1 -1
- package/dist/internal/stores/session-panel-memory-store.d.ts +1 -1
- package/dist/internal/stores/sound-store.d.ts +1 -1
- package/dist/internal/stores/tab-store.d.ts +1 -1
- package/dist/internal/stores/user-preferences-store.d.ts +1 -1
- package/dist/internal/stores/web-notification-store.d.ts +1 -1
- package/dist/lib/base-ui-compat.d.ts +149 -0
- package/dist/lib/base-ui-compat.js +339 -0
- package/dist/lib/portal-container.d.ts +3 -7
- package/dist/lib/portal-container.js +5 -3
- package/dist/lib/z-stack.d.ts +4 -4
- package/dist/lib/z-stack.js +5 -5
- package/dist/primitives/accordion.d.ts +36 -5
- package/dist/primitives/accordion.js +41 -8
- package/dist/primitives/alert-dialog.d.ts +33 -11
- package/dist/primitives/alert-dialog.js +41 -19
- package/dist/primitives/avatar.d.ts +5 -2
- package/dist/primitives/avatar.js +3 -3
- package/dist/primitives/badge.js +1 -1
- package/dist/primitives/breadcrumb.js +1 -1
- package/dist/primitives/button-group.js +3 -3
- package/dist/primitives/button.js +1 -1
- package/dist/primitives/checkbox.d.ts +14 -5
- package/dist/primitives/checkbox.js +24 -9
- package/dist/primitives/collapsible.d.ts +16 -4
- package/dist/primitives/collapsible.js +18 -7
- package/dist/primitives/command-core.d.ts +121 -0
- package/dist/primitives/command-core.js +642 -0
- package/dist/primitives/command.d.ts +38 -4
- package/dist/primitives/command.js +22 -13
- package/dist/primitives/context-menu.d.ts +61 -31
- package/dist/primitives/context-menu.js +40 -53
- package/dist/primitives/dialog.d.ts +48 -10
- package/dist/primitives/dialog.js +48 -19
- package/dist/primitives/disclosure.d.ts +1 -1
- package/dist/primitives/disclosure.js +2 -2
- package/dist/primitives/drawer.d.ts +28 -9
- package/dist/primitives/drawer.js +42 -18
- package/dist/primitives/dropdown-menu.d.ts +55 -33
- package/dist/primitives/dropdown-menu.js +46 -82
- package/dist/primitives/faded-scroll-area.js +2 -1
- package/dist/primitives/hint.js +3 -3
- package/dist/primitives/hover-card.d.ts +17 -5
- package/dist/primitives/hover-card.js +45 -8
- package/dist/primitives/item.js +2 -2
- package/dist/primitives/label.d.ts +5 -2
- package/dist/primitives/label.js +10 -3
- package/dist/primitives/menu-base.d.ts +150 -0
- package/dist/primitives/menu-base.js +171 -0
- package/dist/primitives/menu-recipe.d.ts +1 -1
- package/dist/primitives/menu-recipe.js +2 -7
- package/dist/primitives/modal.d.ts +19 -52
- package/dist/primitives/modal.js +24 -28
- package/dist/primitives/navigation-menu.d.ts +36 -11
- package/dist/primitives/navigation-menu.js +31 -12
- package/dist/primitives/popover.d.ts +31 -6
- package/dist/primitives/popover.js +79 -12
- package/dist/primitives/preview-image.d.ts +18 -7
- package/dist/primitives/preview-image.js +14 -11
- package/dist/primitives/progress.d.ts +4 -2
- package/dist/primitives/progress.js +4 -3
- package/dist/primitives/project-icon-picker.js +2 -2
- package/dist/primitives/radio-group.d.ts +28 -5
- package/dist/primitives/radio-group.js +18 -10
- package/dist/primitives/scroll-area.d.ts +2 -2
- package/dist/primitives/scroll-area.js +8 -3
- package/dist/primitives/select.d.ts +55 -12
- package/dist/primitives/select.js +93 -36
- package/dist/primitives/separator.d.ts +6 -2
- package/dist/primitives/separator.js +10 -2
- package/dist/primitives/sheet.d.ts +17 -10
- package/dist/primitives/sheet.js +19 -22
- package/dist/primitives/sidebar-menu-primitives.js +8 -8
- package/dist/primitives/slider-native.d.ts +2 -2
- package/dist/primitives/slider-native.js +11 -9
- package/dist/primitives/slider.d.ts +24 -6
- package/dist/primitives/slider.js +26 -24
- package/dist/primitives/slot.d.ts +6 -0
- package/dist/primitives/slot.js +7 -0
- package/dist/primitives/split-sheet.js +1 -1
- package/dist/primitives/stepper.js +1 -1
- package/dist/primitives/switch.d.ts +16 -3
- package/dist/primitives/switch.js +7 -6
- package/dist/primitives/tabs.d.ts +36 -20
- package/dist/primitives/tabs.js +131 -102
- package/dist/primitives/toggle.d.ts +16 -3
- package/dist/primitives/toggle.js +8 -3
- package/dist/primitives/tooltip.d.ts +24 -5
- package/dist/primitives/tooltip.js +32 -10
- package/dist/primitives/type-to-confirm-dialog.d.ts +1 -1
- package/dist/primitives/type-to-confirm-dialog.js +1 -1
- package/dist/session/composer/animated-placeholder.js +1 -1
- package/dist/session/composer/chat-input/chat-input-control.js +3 -3
- package/dist/session/composer/editor/composer-editor.js +1 -1
- package/dist/session/composer/menus/menu-shell.d.ts +1 -1
- package/dist/session/composer/menus/menu-shell.js +1 -1
- package/dist/session/composer/menus/mount.js +1 -1
- package/dist/session/composer/reasoning-effort-selector.js +1 -1
- package/dist/session/header/session-site-header.js +2 -2
- package/dist/session/header/subagent-hover-card.js +2 -2
- package/dist/session/media/image-preview.js +1 -1
- package/dist/session/models/model-selector.d.ts +1 -1
- package/dist/session/models/model-selector.js +18 -12
- package/dist/session/models/subscription-switcher.d.ts +37 -0
- package/dist/session/models/subscription-switcher.js +97 -0
- package/dist/session/models/subscription-windows.d.ts +40 -0
- package/dist/session/models/subscription-windows.js +86 -0
- package/dist/session/overrides/session-overrides-control.js +3 -3
- package/dist/session/panel/diff-dialog.js +1 -1
- package/dist/session/panel/easy/detail-view.js +3 -3
- package/dist/session/panel/mobile-tool-drawer.js +2 -2
- package/dist/session/panel/panel-fallback.js +1 -1
- package/dist/session/panel/session-files-explorer.d.ts +1 -1
- package/dist/session/panel/session-files-explorer.js +1 -1
- package/dist/session/thread/session-chat.js +2 -2
- package/dist/session/thread/session-context-message-explorer.js +1 -1
- package/dist/session/thread/turn-share.js +3 -4
- package/dist/session/tool/shared/show-helpers.js +1 -1
- package/dist/session/turn/message-time-label.js +1 -1
- package/dist/styles.css +1 -1
- package/dist/test-utils/intl.d.ts +3 -0
- package/dist/workspace/projects/modal/project-icon-field.js +9 -23
- package/dist/workspace/review/review-center.js +1 -1
- package/dist/workspace/sessions/session-row.js +1 -1
- package/dist/workspace/sidebar/project-session-list.js +2 -2
- package/dist/workspace/sidebar/session-brief-hover-card.d.ts +1 -1
- package/dist/workspace/sidebar/session-brief-hover-card.js +3 -3
- package/dist/workspace/sidebar/session-title.d.ts +2 -2
- package/dist/workspace/sidebar/session-title.js +2 -2
- package/dist/workspace/sidebar/workspace-menu-section.js +1 -1
- package/dist/workspace/spaces/space-links.js +1 -1
- package/dist/workspace/spaces/space-threads-tab.js +1 -1
- package/package.json +16 -35
- package/skills/kortix-ui/SKILL.md +1 -1
- package/skills/kortix-ui/references/custom-dashboard.md +1 -1
|
@@ -1,19 +1,41 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import
|
|
3
|
+
import { Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
|
|
4
4
|
import * as React from 'react';
|
|
5
|
+
import { asChildRender, splitPosition, stateRender, FLOATING_LAYER_ATTR, } from '../lib/base-ui-compat.js';
|
|
5
6
|
import { withPortalContainer } from '../lib/portal-container.js';
|
|
6
7
|
import { cn } from '../lib/utils.js';
|
|
7
8
|
const TooltipPortal = withPortalContainer(TooltipPrimitive.Portal);
|
|
8
|
-
|
|
9
|
+
// `delayed-open` is the open value Radix gave a tooltip that opened on hover.
|
|
10
|
+
const tooltipState = (s) => (s.open ? 'delayed-open' : 'closed');
|
|
11
|
+
/** The hover delay, set on `Tooltip` (per tooltip) or `TooltipProvider` (for a subtree). */
|
|
12
|
+
const TooltipDelayContext = React.createContext(undefined);
|
|
13
|
+
// Radix's defaults, kept so an unconfigured tooltip opens as it did.
|
|
14
|
+
const DEFAULT_DELAY = 700;
|
|
15
|
+
const DEFAULT_SKIP_DELAY = 300;
|
|
16
|
+
function TooltipProvider({ delayDuration, skipDelayDuration, children, }) {
|
|
17
|
+
return (_jsx(TooltipPrimitive.Provider, { delay: delayDuration ?? DEFAULT_DELAY, timeout: skipDelayDuration ?? DEFAULT_SKIP_DELAY, children: _jsx(TooltipDelayContext.Provider, { value: delayDuration, children: children }) }));
|
|
18
|
+
}
|
|
9
19
|
/** @deprecated In feature code use `Hint` (`@kortix/ui/hint`). `Tooltip` is the primitive `Hint` builds on. */
|
|
10
|
-
|
|
11
|
-
const
|
|
20
|
+
function Tooltip({ open, defaultOpen, onOpenChange, delayDuration, disableHoverableContent, children, }) {
|
|
21
|
+
const inherited = React.useContext(TooltipDelayContext);
|
|
22
|
+
return (_jsx(TooltipPrimitive.Root, { open: open, defaultOpen: defaultOpen, onOpenChange: onOpenChange ? (next) => onOpenChange(next) : undefined, disableHoverablePopup: disableHoverableContent, children: _jsx(TooltipDelayContext.Provider, { value: delayDuration ?? inherited, children: children }) }));
|
|
23
|
+
}
|
|
24
|
+
const TooltipTrigger = React.forwardRef(({ asChild, children, ...props }, ref) => {
|
|
25
|
+
const delay = React.useContext(TooltipDelayContext);
|
|
26
|
+
const slot = asChildRender(asChild, children);
|
|
27
|
+
return (_jsx(TooltipPrimitive.Trigger, { ref: ref, delay: delay ?? DEFAULT_DELAY, ...props, render: stateRender('button', tooltipState, slot.render), children: slot.children }));
|
|
28
|
+
});
|
|
29
|
+
TooltipTrigger.displayName = 'TooltipTrigger';
|
|
12
30
|
/** @deprecated In feature code use `Hint` (`@kortix/ui/hint`). */
|
|
13
|
-
const TooltipContent = React.forwardRef(({ className, sideOffset = 4,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
31
|
+
const TooltipContent = React.forwardRef(({ className, sideOffset = 4, asChild, forceMount, children, ...rest }, ref) => {
|
|
32
|
+
const { positioner, rest: props } = splitPosition({ sideOffset, ...rest });
|
|
33
|
+
const slot = asChildRender(asChild, children);
|
|
34
|
+
return (_jsx(TooltipPortal, { keepMounted: forceMount, children: _jsx(TooltipPrimitive.Positioner, { ...positioner, ...FLOATING_LAYER_ATTR, className: "z-[9999]", children: _jsx(TooltipPrimitive.Popup, { ref: ref, "data-slot": "tooltip-content",
|
|
35
|
+
// No enter/exit animation, the same as the dropdown, select and popover
|
|
36
|
+
// panels: the tooltip paints on the frame it mounts and unmounts on the
|
|
37
|
+
// frame it closes. The hover delay lives on `TooltipProvider`, not here.
|
|
38
|
+
className: cn('bg-foreground text-background ring-foreground/5 z-[9999] overflow-hidden rounded-sm p-1 px-2 text-[length:var(--text-xs,0.8125rem)] ring-[1px]', className), ...props, render: stateRender('div', tooltipState, slot.render), children: slot.children }) }) }));
|
|
39
|
+
});
|
|
40
|
+
TooltipContent.displayName = 'TooltipContent';
|
|
19
41
|
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* workspace.
|
|
28
28
|
*
|
|
29
29
|
* The matcher is `confirmationPhraseMatches` below, exported and tested
|
|
30
|
-
* separately: this dialog renders through a
|
|
30
|
+
* separately: this dialog renders through a portal, which emits nothing
|
|
31
31
|
* under `renderToStaticMarkup`, so a test that reached for the button's
|
|
32
32
|
* `disabled` attribute in rendered output would silently be unable to fail.
|
|
33
33
|
* See `type-to-confirm-dialog.test.ts`.
|
|
@@ -29,7 +29,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
29
29
|
* workspace.
|
|
30
30
|
*
|
|
31
31
|
* The matcher is `confirmationPhraseMatches` below, exported and tested
|
|
32
|
-
* separately: this dialog renders through a
|
|
32
|
+
* separately: this dialog renders through a portal, which emits nothing
|
|
33
33
|
* under `renderToStaticMarkup`, so a test that reached for the button's
|
|
34
34
|
* `disabled` attribute in rendered output would silently be unable to fail.
|
|
35
35
|
* See `type-to-confirm-dialog.test.ts`.
|
|
@@ -115,5 +115,5 @@ export function AnimatedComposerPlaceholder({ placeholder, active, }) {
|
|
|
115
115
|
// wrapper's edge while the caret underneath it sits one inset further
|
|
116
116
|
// in — the placeholder and the cursor stop agreeing on where the line
|
|
117
117
|
// starts. See composer-text-metrics.ts.
|
|
118
|
-
className: cn('text-muted-foreground pointer-events-none absolute inset-x-1 top-0 overflow-hidden text-sm', COMPOSER_TEXT_METRICS), children: _jsx(AnimatePresence, { mode: "popLayout", initial: false, children: _jsx(m.span, { initial: swap.initial, animate: swap.animate, exit: swap.exit, transition: swap.transition, className: "block min-w-0 truncate", children: variants[index] }, `${index}:${variants[index]}`) }) }));
|
|
118
|
+
className: cn('text-muted-foreground pointer-events-none absolute inset-x-1 top-0 overflow-hidden text-base sm:text-sm', COMPOSER_TEXT_METRICS), children: _jsx(AnimatePresence, { mode: "popLayout", initial: false, children: _jsx(m.span, { initial: swap.initial, animate: swap.animate, exit: swap.exit, transition: swap.transition, className: "block min-w-0 truncate", children: variants[index] }, `${index}:${variants[index]}`) }) }));
|
|
119
119
|
}
|
|
@@ -265,7 +265,7 @@ export function ChatInputControl({ agents, selectedAgent, onAgentChange, agentLo
|
|
|
265
265
|
The panel opens from the composer card, not from the trigger: its left
|
|
266
266
|
edge is the card's left edge and its bottom edge sits just above the
|
|
267
267
|
card's top (or the top of the strip stacked on it: the queue, a notice).
|
|
268
|
-
|
|
268
|
+
The positioner still anchors to the trigger; the offsets below move the panel from
|
|
269
269
|
the trigger to the card. Measured on open and on resize. A composer
|
|
270
270
|
without a card (none found) keeps the trigger's position.
|
|
271
271
|
*/
|
|
@@ -536,12 +536,12 @@ export function ChatInputControl({ agents, selectedAgent, onAgentChange, agentLo
|
|
|
536
536
|
}
|
|
537
537
|
},
|
|
538
538
|
// The editors' selects open in their own portals, and a dialog opened
|
|
539
|
-
// from inside is outside too.
|
|
539
|
+
// from inside is outside too. The popover would close this panel under the cursor.
|
|
540
540
|
onInteractOutside: (event) => {
|
|
541
541
|
const target = event.target;
|
|
542
542
|
if (saving ||
|
|
543
543
|
foreignDialogOpen(contentRef.current) ||
|
|
544
|
-
target?.closest('[data-
|
|
544
|
+
target?.closest('[data-kortix-floating], [role="dialog"]'))
|
|
545
545
|
event.preventDefault();
|
|
546
546
|
}, onFocusOutside: (event) => {
|
|
547
547
|
if (foreignDialogOpen(contentRef.current))
|
|
@@ -459,5 +459,5 @@ export const ComposerEditor = forwardRef(function ComposerEditor({ placeholder,
|
|
|
459
459
|
// page on focus for any input under 16px, and the composer is the one
|
|
460
460
|
// field on the screen. `sm:text-sm` above 640px, which is the size
|
|
461
461
|
// `styles/components.css`'s slash-trigger rule already documents.
|
|
462
|
-
'kortix-composer-editor w-full text-sm', disabled && 'opacity-50') }), ultracodeActive ? (_jsxs("p", { "data-slot": "ultracode-hint", className: "text-muted-foreground mt-1 truncate text-xs", children: [tUltracode('hint'), _jsx("span", { "aria-hidden": true, className: "px-1", children: "\u00B7" }), tUltracode('dismiss', { key: dismissKeyLabel() })] })) : null] }));
|
|
462
|
+
'kortix-composer-editor w-full text-base sm:text-sm', disabled && 'opacity-50') }), ultracodeActive ? (_jsxs("p", { "data-slot": "ultracode-hint", className: "text-muted-foreground mt-1 truncate text-xs", children: [tUltracode('hint'), _jsx("span", { "aria-hidden": true, className: "px-1", children: "\u00B7" }), tUltracode('dismiss', { key: dismissKeyLabel() })] })) : null] }));
|
|
463
463
|
});
|
|
@@ -60,7 +60,7 @@ export interface MenuRowProps {
|
|
|
60
60
|
* row beneath a resting mouse, which fires enter, which drags the selection
|
|
61
61
|
* straight back: the keyboard and the mouse fight and the keyboard loses.
|
|
62
62
|
* `pointermove` fires only on real pointer travel, so a stationary mouse
|
|
63
|
-
* cannot claim anything. (Same reason
|
|
63
|
+
* cannot claim anything. (Same reason the command list and the menus use it.)
|
|
64
64
|
*
|
|
65
65
|
* Touch is excluded: a finger dragging across the list to scroll it is not
|
|
66
66
|
* "hovering", and repainting the `/` menu's detail pane under the drag would
|
|
@@ -50,7 +50,7 @@ export function MenuSectionHeading({ children }) {
|
|
|
50
50
|
* row beneath a resting mouse, which fires enter, which drags the selection
|
|
51
51
|
* straight back: the keyboard and the mouse fight and the keyboard loses.
|
|
52
52
|
* `pointermove` fires only on real pointer travel, so a stationary mouse
|
|
53
|
-
* cannot claim anything. (Same reason
|
|
53
|
+
* cannot claim anything. (Same reason the command list and the menus use it.)
|
|
54
54
|
*
|
|
55
55
|
* Touch is excluded: a finger dragging across the list to scroll it is not
|
|
56
56
|
* "hovering", and repainting the `/` menu's detail pane under the drag would
|
|
@@ -10,7 +10,7 @@ const CARET_GAP = 4;
|
|
|
10
10
|
*
|
|
11
11
|
* The plugin appends the popup to `document.body` and sets NO z-index, so paint
|
|
12
12
|
* order is decided purely by document order against everything else the app
|
|
13
|
-
* portals into `body` (
|
|
13
|
+
* portals into `body` (popovers, dropdowns, toasts). `60` puts the menu
|
|
14
14
|
* above the app's own overlay layers — it is opened by an explicit keystroke
|
|
15
15
|
* inside a focused editor, so nothing it can cover is more current than it.
|
|
16
16
|
*/
|
|
@@ -33,7 +33,7 @@ import { SolidCheckIcon } from '../../internal/icons/solid-check-icon.js';
|
|
|
33
33
|
import { CaretDownIcon, CellSignalFullIcon, CellSignalHighIcon, CellSignalLowIcon, CellSignalMediumIcon, CellSignalNoneIcon, GaugeIcon, } from '@phosphor-icons/react';
|
|
34
34
|
/**
|
|
35
35
|
* The value `onVariantChange(null)` means: no variant, let the model decide.
|
|
36
|
-
* A sentinel is needed because
|
|
36
|
+
* A sentinel is needed because the radio group addresses items by string
|
|
37
37
|
* and cannot carry `null`.
|
|
38
38
|
*/
|
|
39
39
|
const AUTO = '__auto__';
|
|
@@ -95,7 +95,7 @@ export function SessionSiteHeader({ sessionId, sessionTitle, isMobileView, leadi
|
|
|
95
95
|
// The name edits in place: the name button swaps for a field. The menu's
|
|
96
96
|
// Rename item opens the same field, so there is one rename surface.
|
|
97
97
|
const [isRenaming, setIsRenaming] = useState(false);
|
|
98
|
-
// Set by the menu's Rename item.
|
|
98
|
+
// Set by the menu's Rename item. The menu returns focus to the caret trigger
|
|
99
99
|
// when the menu closes, which would blur, and so save, the field that just
|
|
100
100
|
// opened; `onCloseAutoFocus` reads this and keeps focus in the field.
|
|
101
101
|
const renameFromMenu = useRef(false);
|
|
@@ -269,7 +269,7 @@ export function SessionSiteHeader({ sessionId, sessionTitle, isMobileView, leadi
|
|
|
269
269
|
: tI18nHardcoded.raw('i18nComplete.text32ad3abe4479'));
|
|
270
270
|
},
|
|
271
271
|
}), children: [forkSession.isPending ? _jsx(Loading, {}) : _jsx(GitForkIcon, {}), tI18nHardcoded.raw('i18nComplete.text0e5f7f6732e0')] }))] })), outOfContextPresent && (_jsx(DropdownMenuCheckboxItem, { className: "cursor-pointer", checked: !outOfContextHidden, onCheckedChange: (checked) => setOutOfContextHidden(historyKey, !checked), children: tHistory('showOutOfContext') })), _jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => setExportOpen(true), children: [_jsx(FileDown, {}), tI18nHardcoded.raw('i18nComplete.text5d974f9e80c3')] }), canCompact && (_jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => setCompactOpen(true), children: [_jsx(Layers, {}), contextRecord ? tReset('dialogAction') : tI18nHardcoded.raw('i18nComplete.textca838377bb5a')] })), isProjectSession && canManageLifecycle && (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => setDeleteOpen(true), children: [_jsx(TrashIcon, {}), tI18nHardcoded.raw('i18nComplete.texte2d0a54968ea')] })] }))] }));
|
|
272
|
-
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "relative z-50 w-full", children: [_jsxs("div", { className: cn('flex items-center justify-between p-2 px-3.5 pt-
|
|
272
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "relative z-50 w-full", children: [_jsxs("div", { className: cn('flex items-center justify-between p-2 px-3.5 pt-[max(0.5rem,env(safe-area-inset-top))] pr-4', // audit:allow device safe-area inset, not a spacing step
|
|
273
273
|
// Unconditional on the shell. The LEFT indent depends on the
|
|
274
274
|
// sidebar (expanded, it covers the macOS lights itself) and is
|
|
275
275
|
// gated by the data attribute — but the RIGHT one does not: this
|
|
@@ -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 { formatDistanceToNowStrict } from 'date-fns';
|
|
4
|
-
import { Slot } from '
|
|
4
|
+
import { Slot } from '../../lib/base-ui-compat.js';
|
|
5
5
|
import { useRef, useState } from 'react';
|
|
6
6
|
import { useTranslations } from '../../i18n/index.js';
|
|
7
7
|
import { HoverPrefetchLink } from '../../internal/components/hover-prefetch-link.js';
|
|
@@ -54,7 +54,7 @@ export function SubagentHoverCard({ projectId, projectSessionId, subsessions, sp
|
|
|
54
54
|
}, children: _jsxs(HoverCard, { open: !keyboard && open, onOpenChange: (value) => {
|
|
55
55
|
if (!keyboard && (!value || !suppressFocusOpen.current))
|
|
56
56
|
setOpen(value);
|
|
57
|
-
}, openDelay: 300, closeDelay: 100, children: [_jsx(PopoverAnchor, { asChild: true, children: _jsx(HoverCardTrigger, { asChild: true, children: _jsx(Slot
|
|
57
|
+
}, openDelay: 300, closeDelay: 100, children: [_jsx(PopoverAnchor, { asChild: true, children: _jsx(HoverCardTrigger, { asChild: true, children: _jsx(Slot, { ref: titleRef, "aria-keyshortcuts": "ArrowDown", onPointerEnter: () => {
|
|
58
58
|
suppressFocusOpen.current = false;
|
|
59
59
|
}, onBlur: () => {
|
|
60
60
|
suppressFocusOpen.current = false;
|
|
@@ -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 { Modal, ModalContent, ModalTitle } from '../../primitives/modal.js';
|
|
4
|
-
import { VisuallyHidden } from '
|
|
4
|
+
import { VisuallyHidden } from '../../lib/base-ui-compat.js';
|
|
5
5
|
import { useState } from 'react';
|
|
6
6
|
/**
|
|
7
7
|
* ImagePreview — wraps a clickable image thumbnail. On click, opens a full-size
|
|
@@ -101,7 +101,7 @@ export interface ModelSelectorProps {
|
|
|
101
101
|
* so effort is the right-hand pane of this popover.
|
|
102
102
|
*
|
|
103
103
|
* Controlled/uncontrolled is decided by whether `open` is `undefined`, the
|
|
104
|
-
* same rule
|
|
104
|
+
* same rule the Base UI roots use — so every existing call site keeps its
|
|
105
105
|
* internal state untouched.
|
|
106
106
|
*/
|
|
107
107
|
open?: boolean;
|
|
@@ -21,6 +21,7 @@ import { isClaudeSubscriptionModel, isSubscriptionModel, pickerModelName, should
|
|
|
21
21
|
import { useModelConnectionGate } from './use-model-connection-gate.js';
|
|
22
22
|
import { ModelPickerPanel } from './model-picker-panel.js';
|
|
23
23
|
import { effortLabel, reasoningEffortChoices } from '../composer/reasoning-effort-selector.js';
|
|
24
|
+
import { SubscriptionSwitcher, subscriptionProviderOf } from './subscription-switcher.js';
|
|
24
25
|
// Re-export for consumers
|
|
25
26
|
export { Tag };
|
|
26
27
|
export function ConnectProviderDialog({ open, onOpenChange, providers: _providers, }) {
|
|
@@ -146,8 +147,8 @@ export function ModelSelector({ models, selectedModel, onSelect, defaultControls
|
|
|
146
147
|
const tModel = useTranslations('modelSelector');
|
|
147
148
|
const tDefault = useTranslations('workspaces.models');
|
|
148
149
|
const t = useTranslations('threads');
|
|
149
|
-
// Controlled when `open` is supplied, uncontrolled otherwise —
|
|
150
|
-
// rule. `setOpen` below is the single write path every internal caller
|
|
150
|
+
// Controlled when `open` is supplied, uncontrolled otherwise — the Base UI
|
|
151
|
+
// roots' rule. `setOpen` below is the single write path every internal caller
|
|
151
152
|
// already goes through (`setOpen(false)` after picking a model or a
|
|
152
153
|
// default), so a controlled parent hears about those closes too rather than
|
|
153
154
|
// being silently desynced from a popover that shut itself.
|
|
@@ -188,6 +189,11 @@ export function ModelSelector({ models, selectedModel, onSelect, defaultControls
|
|
|
188
189
|
m.modelID === availableSelectedModel?.modelID);
|
|
189
190
|
// The pill names the model, never its plan suffix: "GPT-6 Luna", not "GPT-6 Luna (ChatGPT)".
|
|
190
191
|
const displayName = (current && pickerModelName(current)) || unsetLabel || t('noModel');
|
|
192
|
+
// A subscription model names the login that pays for it: the picker grows a
|
|
193
|
+
// subscription pane under the list (both appearances), so switching the
|
|
194
|
+
// ChatGPT or Claude plan a turn runs on needs no trip to Customize.
|
|
195
|
+
const subscriptionProvider = current ? subscriptionProviderOf(current) : null;
|
|
196
|
+
const subscriptionNode = subscriptionProvider ? _jsx(SubscriptionSwitcher, { providerId: subscriptionProvider }) : null;
|
|
191
197
|
const effortChoices = appearance === 'chip'
|
|
192
198
|
? reasoningEffortChoices(reasoning?.variants, !!reasoning?.onVariantChange)
|
|
193
199
|
: [];
|
|
@@ -373,20 +379,20 @@ export function ModelSelector({ models, selectedModel, onSelect, defaultControls
|
|
|
373
379
|
searchEmptyState) : (noModelsState) })] }));
|
|
374
380
|
const modals = (_jsxs(_Fragment, { children: [connectionModal, projectId && chatGptPossible && ProviderAccountsModal && (_jsx(ProviderAccountsModal, { projectId: projectId, providerId: "codex", open: chatGptOpen, onOpenChange: setChatGptOpen }))] }));
|
|
375
381
|
if (inline) {
|
|
376
|
-
return (_jsxs(_Fragment, { children: [modals, _jsx(Command, { shouldFilter: false, className: cn('min-h-0 flex-1 rounded-none bg-transparent', '[&_[cmdk-group]]:px-1.5 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0',
|
|
377
|
-
|
|
378
|
-
|
|
382
|
+
return (_jsxs(_Fragment, { children: [modals, _jsxs("div", { className: "flex min-h-0 flex-1 flex-col", children: [_jsx(Command, { shouldFilter: false, className: cn('min-h-0 flex-1 rounded-none bg-transparent', '[&_[cmdk-group]]:px-1.5 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0',
|
|
383
|
+
// No hairlines in a host pane: the search is a filled field, groups part by space.
|
|
384
|
+
'[&_[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] })] }));
|
|
379
385
|
}
|
|
380
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: displayName }), disabled ? null : _jsx(ChevronDown, { className: cn(TRIGGER_CARET_CLASS, 'size-4') })] })) : (_jsxs(Button, { type: "button", variant: triggerVariant, size: "sm",
|
|
381
387
|
// `min-w-0 shrink`: in a narrow toolbar (a channel's thread panel) the
|
|
382
388
|
// model name truncates; the controls beside it keep their width.
|
|
383
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: displayName }), 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
|
|
384
390
|
? 'w-[min(38rem,calc(100vw-1.5rem))]'
|
|
385
|
-
: 'w-[min(28rem,calc(100vw-1.5rem))]', 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
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
391
|
+
: '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
|
+
? {
|
|
393
|
+
choices: effortChoices,
|
|
394
|
+
selectedVariant: reasoning?.selectedVariant,
|
|
395
|
+
onChange: handleEffortChange,
|
|
396
|
+
}
|
|
397
|
+
: undefined }), subscriptionNode] }) })] })] }));
|
|
392
398
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The subscription pane of the model picker: which ChatGPT or Claude login
|
|
3
|
+
* pays for the selected subscription model in this session, and how much of
|
|
4
|
+
* its allowance is spent.
|
|
5
|
+
*
|
|
6
|
+
* The choice IS the session's provider key pool for that provider, pinned to
|
|
7
|
+
* one login — the same pool Customize → Models and the session-overrides
|
|
8
|
+
* "Provider keys" row read and write (`useSessionProviderSecretPools`). No
|
|
9
|
+
* second source of truth: picking a login here writes the pool, and the
|
|
10
|
+
* gateway resolves the turn's credential from it (resolve-candidates'
|
|
11
|
+
* `selectedPool`). "Workspace default" clears the pin, handing the provider
|
|
12
|
+
* back to rotation.
|
|
13
|
+
*
|
|
14
|
+
* Data comes from the same reads those surfaces use: `useProviderKeyChoices`
|
|
15
|
+
* (the account's usable gateway logins, personal-key scoped to this session)
|
|
16
|
+
* and the pool list. The usage shown per login is the snapshot those reads
|
|
17
|
+
* carry — the same numbers the provider sheet renders (`subscription-usage`);
|
|
18
|
+
* a login the provider has not reported on yet shows none.
|
|
19
|
+
*
|
|
20
|
+
* Only an existing session can switch: a pool belongs to a session, so a
|
|
21
|
+
* pre-create composer renders nothing.
|
|
22
|
+
*/
|
|
23
|
+
import type { SubscriptionUsage, SubscriptionUsageWindow } from '@kortix/sdk';
|
|
24
|
+
import { type FlatModel } from '@kortix/sdk/react';
|
|
25
|
+
/** The provider whose pooled logins pay for a subscription model. Null for every other model. */
|
|
26
|
+
export declare function subscriptionProviderOf(model: Pick<FlatModel, 'providerID' | 'modelID'> & {
|
|
27
|
+
provider?: string | null;
|
|
28
|
+
}): 'codex' | 'claude-agent' | null;
|
|
29
|
+
/**
|
|
30
|
+
* The window to show beside a login: the fullest one still in force that
|
|
31
|
+
* gates its model calls (`isBlockingWindow`, the rule the provider sheet's
|
|
32
|
+
* summary and the gateway's limit state share). Null when nothing is reported.
|
|
33
|
+
*/
|
|
34
|
+
export declare function peakBlockingWindow(usage: SubscriptionUsage | null | undefined, now: number): SubscriptionUsageWindow | null;
|
|
35
|
+
export declare function SubscriptionSwitcher({ providerId }: {
|
|
36
|
+
providerId: 'codex' | 'claude-agent';
|
|
37
|
+
}): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useSessionProviderSecretPools } from '@kortix/sdk/react';
|
|
4
|
+
import { useTranslations } from '../../i18n/index.js';
|
|
5
|
+
import { needsReconnection } from '../../internal/lib/account-secret-access.js';
|
|
6
|
+
import { SolidCheckIcon } from '../../internal/icons/solid-check-icon.js';
|
|
7
|
+
import { cn } from '../../lib/utils.js';
|
|
8
|
+
import { useSessionIds } from '../../providers/session-ids.js';
|
|
9
|
+
import { isClaudeSubscriptionModel, isSubscriptionModel } from './model-tags.js';
|
|
10
|
+
import { accountLine, isBlockingWindow, loginLimit, usageTone, windowLabel, } from './subscription-windows.js';
|
|
11
|
+
import { useProviderKeyChoices } from '../overrides/provider-secret-pool-editor.js';
|
|
12
|
+
/** The provider whose pooled logins pay for a subscription model. Null for every other model. */
|
|
13
|
+
export function subscriptionProviderOf(model) {
|
|
14
|
+
if (isSubscriptionModel(model))
|
|
15
|
+
return 'codex';
|
|
16
|
+
if (isClaudeSubscriptionModel(model))
|
|
17
|
+
return 'claude-agent';
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The window to show beside a login: the fullest one still in force that
|
|
22
|
+
* gates its model calls (`isBlockingWindow`, the rule the provider sheet's
|
|
23
|
+
* summary and the gateway's limit state share). Null when nothing is reported.
|
|
24
|
+
*/
|
|
25
|
+
export function peakBlockingWindow(usage, now) {
|
|
26
|
+
if (!usage)
|
|
27
|
+
return null;
|
|
28
|
+
let peak = null;
|
|
29
|
+
for (const window of usage.windows) {
|
|
30
|
+
if (!isBlockingWindow(window.id))
|
|
31
|
+
continue;
|
|
32
|
+
if (window.resets_at && Date.parse(window.resets_at) <= now)
|
|
33
|
+
continue;
|
|
34
|
+
if (!peak || window.used_percent > peak.used_percent)
|
|
35
|
+
peak = window;
|
|
36
|
+
}
|
|
37
|
+
return peak;
|
|
38
|
+
}
|
|
39
|
+
export function SubscriptionSwitcher({ providerId }) {
|
|
40
|
+
const t = useTranslations('pooledSecrets');
|
|
41
|
+
const tUsage = useTranslations('subscriptionUsage');
|
|
42
|
+
const { projectId, sessionId } = useSessionIds();
|
|
43
|
+
const pools = useSessionProviderSecretPools(projectId ?? null, sessionId ?? null);
|
|
44
|
+
const keys = useProviderKeyChoices(projectId ?? '', sessionId);
|
|
45
|
+
const logins = keys.keys.filter((secret) => secret.provider_id === providerId);
|
|
46
|
+
// Nothing to switch (no connected login, pre-create, or a failed read): no pane.
|
|
47
|
+
if (!sessionId || logins.length === 0)
|
|
48
|
+
return null;
|
|
49
|
+
const pinned = pools.data?.pools.find((pool) => pool.provider_id === providerId)?.secret_ids ?? null;
|
|
50
|
+
// A pool of several logins rotates; the pane reads that as the default.
|
|
51
|
+
const pinnedId = pinned && pinned.length === 1 ? pinned[0] : null;
|
|
52
|
+
const canEdit = pools.data?.can_edit === true;
|
|
53
|
+
const pending = pools.setPool.isPending;
|
|
54
|
+
// The clock the usage reads judge resets by: the pool read's own timestamp
|
|
55
|
+
// (react-query render data, what `subscription-usage` passes as `now`), so
|
|
56
|
+
// the pane stays pure. A pane left open ages past it like any snapshot.
|
|
57
|
+
const now = pools.dataUpdatedAt;
|
|
58
|
+
const pick = (secretId) => {
|
|
59
|
+
void pools.setPool.mutateAsync({ providerId, secretIds: secretId ? [secretId] : null });
|
|
60
|
+
};
|
|
61
|
+
const rows = [
|
|
62
|
+
{ secretId: null, label: t('projectDefaultShort'), line: t('subscriptionSwitcherDefault'), window: null, limited: false, broken: false },
|
|
63
|
+
...logins.map((secret) => {
|
|
64
|
+
const peak = peakBlockingWindow(secret.usage, now);
|
|
65
|
+
return {
|
|
66
|
+
secretId: secret.secret_id,
|
|
67
|
+
label: secret.label,
|
|
68
|
+
line: accountLine(secret.provider_account, secret.label),
|
|
69
|
+
window: peak,
|
|
70
|
+
limited: loginLimit(secret.usage ?? null, now).limited,
|
|
71
|
+
broken: needsReconnection(secret),
|
|
72
|
+
};
|
|
73
|
+
}),
|
|
74
|
+
];
|
|
75
|
+
const onKeyDown = (event) => {
|
|
76
|
+
// Same contract as the reasoning pane beside it: Escape bubbles (the
|
|
77
|
+
// popover closes), modifiers and Tab stay with the panel, the arrows walk
|
|
78
|
+
// the radios, every other key stops so cmdk never selects a model row.
|
|
79
|
+
if (event.key === 'Escape' || event.key === 'Tab')
|
|
80
|
+
return;
|
|
81
|
+
if (event.metaKey || event.ctrlKey || event.altKey)
|
|
82
|
+
return;
|
|
83
|
+
event.stopPropagation();
|
|
84
|
+
if (event.key !== 'ArrowDown' && event.key !== 'ArrowUp')
|
|
85
|
+
return;
|
|
86
|
+
event.preventDefault();
|
|
87
|
+
const radios = Array.from(event.currentTarget.querySelectorAll('[role="radio"]'));
|
|
88
|
+
const index = radios.indexOf(document.activeElement);
|
|
89
|
+
const step = event.key === 'ArrowDown' ? 1 : -1;
|
|
90
|
+
radios[(index + step + radios.length) % radios.length]?.focus();
|
|
91
|
+
};
|
|
92
|
+
return (_jsxs("div", { children: [_jsx("div", { className: "text-muted-foreground flex h-9 shrink-0 items-center border-b px-3 text-sm", children: t('subscriptionSwitcher') }), _jsx("div", { role: "radiogroup", "aria-label": t('subscriptionSwitcher'), onKeyDown: onKeyDown, className: "flex flex-col gap-px p-1.5", children: rows.map((row) => {
|
|
93
|
+
const checked = row.secretId === pinnedId || (row.secretId === null && pinnedId === null);
|
|
94
|
+
const tone = row.window ? usageTone(row.window, row.limited) : 'ok';
|
|
95
|
+
return (_jsxs("button", { type: "button", role: "radio", "aria-checked": checked, "aria-label": row.secretId ? t('subscriptionSwitcherUse', { label: row.label }) : undefined, tabIndex: checked ? 0 : -1, disabled: !canEdit || pending, onClick: () => pick(row.secretId), className: cn('flex cursor-pointer flex-col gap-0.5 rounded-md px-2 py-1 text-left text-sm outline-none', 'hover:bg-hover focus-visible:bg-hover focus-visible:ring-kortix-base focus-visible:ring-2', 'disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-60', checked && 'bg-active hover:bg-active'), children: [_jsxs("span", { className: "flex min-w-0 items-center gap-2", children: [_jsx("span", { className: "text-foreground min-w-0 flex-1 truncate font-medium", children: row.label }), row.limited ? (_jsx("span", { className: "text-foreground shrink-0 text-xs", children: tUsage('limitReached') })) : row.window ? (_jsxs("span", { className: cn('shrink-0 text-xs tabular-nums', tone === 'ok' ? 'text-muted-foreground' : 'text-foreground'), children: [windowLabel(row.window.id, tUsage), " \u00B7 ", tUsage('percent', { percent: Math.round(row.window.used_percent) })] })) : null, checked ? _jsx(SolidCheckIcon, { className: "text-ring size-4 shrink-0" }) : null] }), _jsxs("span", { className: "text-muted-foreground flex min-w-0 items-center gap-2 text-xs", children: [row.line ? _jsx("span", { className: "min-w-0 truncate", children: row.line }) : null, row.broken ? _jsx("span", { className: row.line ? 'shrink-0' : 'min-w-0 truncate', children: t('needsReconnection') }) : null, !row.line && !row.broken && row.secretId && !row.window ? (_jsx("span", { className: "min-w-0 truncate", children: tUsage('noUsageYet') })) : null] })] }, row.secretId ?? 'default'));
|
|
96
|
+
}) }), canEdit ? null : _jsx("p", { className: "text-muted-foreground px-3 pb-1.5 text-xs", children: t('readOnlyPool') })] }));
|
|
97
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pure reading of a subscription login's usage windows: tone, names,
|
|
3
|
+
* blocking windows and the limit. The model picker (`subscription-switcher`)
|
|
4
|
+
* and the provider sheet (`customize/sections/view/subscription-usage`) both
|
|
5
|
+
* read these, so they live at the session layer, below customize.
|
|
6
|
+
*/
|
|
7
|
+
import type { SubscriptionAccount, SubscriptionUsage, SubscriptionUsageWindow } from '@kortix/sdk';
|
|
8
|
+
import type { useTranslations } from '../../i18n/index.js';
|
|
9
|
+
export type UsageTone = 'ok' | 'near' | 'critical' | 'limited';
|
|
10
|
+
/** Warn at 80%, turn red at 95%, and distinguish a provider-enforced limit. */
|
|
11
|
+
export declare function usageTone(window: SubscriptionUsageWindow, limited: boolean): UsageTone;
|
|
12
|
+
/**
|
|
13
|
+
* Windows that never stop the login's model calls: code review, paid extra
|
|
14
|
+
* usage, and one model's own limit (ChatGPT `model_*`, Claude `seven_day_opus`,
|
|
15
|
+
* `7d_sonnet`). Claude's OAuth-apps window stays blocking. The server's twin
|
|
16
|
+
* is `isBlockingWindow` in packages/llm-gateway/src/usage/subscription-usage.ts.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isBlockingWindow(id: string): boolean;
|
|
19
|
+
/** The model name of a model-specific weekly window (`seven_day_opus` → `Opus`), or null. */
|
|
20
|
+
export declare function weeklyModel(id: string): string | null;
|
|
21
|
+
/** A model limit's id fragment read back as its name: `gpt_5_3_codex_spark` → `GPT-5.3 Codex Spark`. */
|
|
22
|
+
export declare function modelName(slug: string): string;
|
|
23
|
+
type Translate = ReturnType<typeof useTranslations>;
|
|
24
|
+
/** A window's name: `5-hour`, `Weekly`, `Weekly · Opus`, `Code review · Weekly`, `Extra usage`. */
|
|
25
|
+
export declare function windowLabel(id: string, t: Translate, options?: {
|
|
26
|
+
modelWeekly?: boolean;
|
|
27
|
+
}): string;
|
|
28
|
+
/**
|
|
29
|
+
* `person@example.test · Pro`: who the login signs in as. The email is left out
|
|
30
|
+
* when the label already shows it; null when the provider says nothing.
|
|
31
|
+
*/
|
|
32
|
+
export declare function accountLine(account: SubscriptionAccount | null | undefined, label: string): string | null;
|
|
33
|
+
/** The windows still in force: a window whose reset passed no longer limits anything. */
|
|
34
|
+
export declare function currentWindows(usage: SubscriptionUsage, now: number): SubscriptionUsageWindow[];
|
|
35
|
+
/** A login that cannot take a model call now, and when that ends (null: unknown). */
|
|
36
|
+
export declare function loginLimit(usage: SubscriptionUsage | null, now: number): {
|
|
37
|
+
limited: boolean;
|
|
38
|
+
until: string | null;
|
|
39
|
+
};
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/** Warn at 80%, turn red at 95%, and distinguish a provider-enforced limit. */
|
|
2
|
+
export function usageTone(window, limited) {
|
|
3
|
+
if (window.used_percent >= 100 || (limited && window.used_percent >= 90))
|
|
4
|
+
return 'limited';
|
|
5
|
+
if (window.used_percent >= 95)
|
|
6
|
+
return 'critical';
|
|
7
|
+
return window.used_percent >= 80 ? 'near' : 'ok';
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Windows that never stop the login's model calls: code review, paid extra
|
|
11
|
+
* usage, and one model's own limit (ChatGPT `model_*`, Claude `seven_day_opus`,
|
|
12
|
+
* `7d_sonnet`). Claude's OAuth-apps window stays blocking. The server's twin
|
|
13
|
+
* is `isBlockingWindow` in packages/llm-gateway/src/usage/subscription-usage.ts.
|
|
14
|
+
*/
|
|
15
|
+
export function isBlockingWindow(id) {
|
|
16
|
+
return !/^(?:code_review|extra_usage|model_|seven_day_(?!oauth_apps$)|7d_(?!oauth_apps$))/.test(id);
|
|
17
|
+
}
|
|
18
|
+
/** The model name of a model-specific weekly window (`seven_day_opus` → `Opus`), or null. */
|
|
19
|
+
export function weeklyModel(id) {
|
|
20
|
+
const model = /^(?:seven_day|7d)_([a-z]+)$/.exec(id)?.[1];
|
|
21
|
+
return model ? model[0].toUpperCase() + model.slice(1) : null;
|
|
22
|
+
}
|
|
23
|
+
const title = (value) => value.replaceAll('_', ' ').replace(/^./, (first) => first.toUpperCase());
|
|
24
|
+
/** A model limit's id fragment read back as its name: `gpt_5_3_codex_spark` → `GPT-5.3 Codex Spark`. */
|
|
25
|
+
export function modelName(slug) {
|
|
26
|
+
const words = [];
|
|
27
|
+
for (const token of slug.split('_').filter(Boolean)) {
|
|
28
|
+
const last = words.at(-1);
|
|
29
|
+
if (/^\d+$/.test(token) && last && /\d$/.test(last))
|
|
30
|
+
words[words.length - 1] = `${last}.${token}`;
|
|
31
|
+
else
|
|
32
|
+
words.push(token === 'gpt' ? 'GPT' : /^\d/.test(token) ? token : token[0].toUpperCase() + token.slice(1));
|
|
33
|
+
}
|
|
34
|
+
return words.join(' ').replace(/^GPT (\d)/, 'GPT-$1');
|
|
35
|
+
}
|
|
36
|
+
/** A window's name: `5-hour`, `Weekly`, `Weekly · Opus`, `Code review · Weekly`, `Extra usage`. */
|
|
37
|
+
export function windowLabel(id, t, options = {}) {
|
|
38
|
+
if (id === 'five_hour')
|
|
39
|
+
return t('fiveHour');
|
|
40
|
+
// Beside `Weekly · Opus`, the plain weekly window is the one every model shares.
|
|
41
|
+
if (id === 'weekly')
|
|
42
|
+
return options.modelWeekly ? t('weeklyAll') : t('weekly');
|
|
43
|
+
if (id === 'extra_usage')
|
|
44
|
+
return t('extraUsage');
|
|
45
|
+
if (id === 'seven_day_oauth_apps' || id === '7d_oauth_apps')
|
|
46
|
+
return t('weeklyModel', { model: t('apps') });
|
|
47
|
+
const model = weeklyModel(id);
|
|
48
|
+
if (model)
|
|
49
|
+
return t('weeklyModel', { model });
|
|
50
|
+
const scoped = /^(code_review|model_[a-z0-9_]+?)_(five_hour|weekly|primary|secondary)$/.exec(id);
|
|
51
|
+
if (scoped) {
|
|
52
|
+
const scope = scoped[1] === 'code_review' ? t('codeReview') : modelName(scoped[1].slice('model_'.length));
|
|
53
|
+
const span = scoped[2] === 'five_hour' ? t('fiveHour') : scoped[2] === 'weekly' ? t('weekly') : null;
|
|
54
|
+
return span ? `${scope} · ${span}` : scope;
|
|
55
|
+
}
|
|
56
|
+
return title(id);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* `person@example.test · Pro`: who the login signs in as. The email is left out
|
|
60
|
+
* when the label already shows it; null when the provider says nothing.
|
|
61
|
+
*/
|
|
62
|
+
export function accountLine(account, label) {
|
|
63
|
+
if (!account)
|
|
64
|
+
return null;
|
|
65
|
+
const email = account.email && !label.toLowerCase().includes(account.email.toLowerCase()) ? account.email : null;
|
|
66
|
+
const plan = account.plan ? account.plan[0].toUpperCase() + account.plan.slice(1) : null;
|
|
67
|
+
return [email, plan].filter(Boolean).join(' · ') || null;
|
|
68
|
+
}
|
|
69
|
+
/** The windows still in force: a window whose reset passed no longer limits anything. */
|
|
70
|
+
export function currentWindows(usage, now) {
|
|
71
|
+
return usage.windows.filter((window) => !window.resets_at || Date.parse(window.resets_at) > now);
|
|
72
|
+
}
|
|
73
|
+
/** A login that cannot take a model call now, and when that ends (null: unknown). */
|
|
74
|
+
export function loginLimit(usage, now) {
|
|
75
|
+
if (!usage)
|
|
76
|
+
return { limited: false, until: null };
|
|
77
|
+
const blocking = currentWindows(usage, now).filter((window) => isBlockingWindow(window.id));
|
|
78
|
+
const full = blocking.filter((window) => window.used_percent >= 100);
|
|
79
|
+
// A rejection whose window already reset is history, not a limit.
|
|
80
|
+
const rejected = usage.limited && blocking.length === usage.windows.filter((window) => isBlockingWindow(window.id)).length;
|
|
81
|
+
if (!full.length && !rejected)
|
|
82
|
+
return { limited: false, until: null };
|
|
83
|
+
const resets = (full.length ? full : blocking).map((window) => window.resets_at).filter((at) => Boolean(at));
|
|
84
|
+
// Capacity is back only when the LAST full window resets.
|
|
85
|
+
return { limited: true, until: resets.length ? resets.reduce((a, b) => (Date.parse(a) > Date.parse(b) ? a : b)) : null };
|
|
86
|
+
}
|
|
@@ -31,7 +31,7 @@ export function SessionOverridesControlContent({ rows, disabled = false, saving
|
|
|
31
31
|
const focused = rows.find((row) => row.id === focusedId) ?? rows[0];
|
|
32
32
|
const controlsDisabled = disabled || saving;
|
|
33
33
|
return (_jsxs("div", {
|
|
34
|
-
//
|
|
34
|
+
// The positioner reports how much room it actually has; without this the panel is
|
|
35
35
|
// taller than the gap above the composer on a short or narrow viewport and
|
|
36
36
|
// its first row slides off the top of the screen.
|
|
37
37
|
className: "flex h-[28rem] max-h-[var(--radix-popover-content-available-height,28rem)] flex-col overflow-hidden", children: [_jsxs("div", { className: "border-border flex min-h-0 flex-1 flex-col sm:flex-row", children: [_jsx("ul", { className: "border-border flex shrink-0 gap-0.5 overflow-x-auto border-b p-1.5 sm:w-48 sm:flex-col sm:overflow-y-auto sm:border-r sm:border-b-0", "aria-label": t('sessionOverrides'), children: rows.map((row) => {
|
|
@@ -61,11 +61,11 @@ export function SessionOverridesControl({ onSave, ...contentProps }) {
|
|
|
61
61
|
setOpen(next); }, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx(Button, { type: "button", variant: "ghost", size: "icon", disabled: contentProps.saving, "aria-label": t('sessionOverrides'), className: "text-muted-foreground hover:text-foreground data-[state=open]:text-foreground hit-area-3", children: _jsx(GearSixIcon, { className: "size-4 shrink-0" }) }) }), _jsx(PopoverContent, { "aria-label": t('sessionOverrides'), onEscapeKeyDown: (event) => { if (contentProps.saving)
|
|
62
62
|
event.preventDefault(); }, side: "top", align: "end", sideOffset: 8, collisionPadding: 12, className: "w-[min(620px,calc(100vw-2rem))] overflow-hidden p-0",
|
|
63
63
|
// The model, agent and effort editors are themselves popovers rendered
|
|
64
|
-
// into their own portal.
|
|
64
|
+
// into their own portal. The popover sees that portal as "outside", so an
|
|
65
65
|
// unguarded interaction there closes THIS panel under the user's cursor.
|
|
66
66
|
onInteractOutside: (event) => {
|
|
67
67
|
const target = event.target;
|
|
68
|
-
if (contentProps.saving || target?.closest('[data-
|
|
68
|
+
if (contentProps.saving || target?.closest('[data-kortix-floating]'))
|
|
69
69
|
event.preventDefault();
|
|
70
70
|
}, children: _jsx(SessionOverridesControlContent, { ...contentProps, onSave: saveAndClose }) })] }));
|
|
71
71
|
}
|
|
@@ -4,7 +4,7 @@ import { useTranslations } from '../../i18n/index.js';
|
|
|
4
4
|
import { Modal, ModalContent, ModalTitle } from '../../primitives/modal.js';
|
|
5
5
|
import { SessionDiffViewer } from './session-diff-viewer.js';
|
|
6
6
|
import { cn } from '../../lib/utils.js';
|
|
7
|
-
import { VisuallyHidden } from '
|
|
7
|
+
import { VisuallyHidden } from '../../lib/base-ui-compat.js';
|
|
8
8
|
import { useState } from 'react';
|
|
9
9
|
export function DiffDialog({ sessionId, open, onOpenChange }) {
|
|
10
10
|
const tHardcodedUi = useTranslations('hardcodedUi');
|