@kortix/ui 0.15.6 → 0.15.7

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.
Files changed (56) hide show
  1. package/dist/customize/providers/provider-accordion.js +3 -2
  2. package/dist/customize/providers/provider-connect.d.ts +7 -0
  3. package/dist/customize/providers/provider-connect.js +21 -2
  4. package/dist/customize/providers/provider-sheet.js +3 -2
  5. package/dist/customize/sections/gateway-view.d.ts +1 -1
  6. package/dist/customize/sections/gateway-view.js +29 -14
  7. package/dist/customize/sections/llm-provider/chatgpt-subscription-connect.d.ts +3 -1
  8. package/dist/customize/sections/llm-provider/chatgpt-subscription-connect.js +2 -2
  9. package/dist/customize/sections/view/account-secret-resources-panel.js +4 -3
  10. package/dist/customize/sections/view/review-center-connected.js +15 -3
  11. package/dist/customize/sections/view/subscription-usage.d.ts +288 -7
  12. package/dist/customize/sections/view/subscription-usage.js +257 -30
  13. package/dist/i18n/en.d.ts +37 -47
  14. package/dist/i18n/en.js +40 -50
  15. package/dist/i18n/ui-catalog/app-registry-translation-keys.generated.js +5 -0
  16. package/dist/internal/auth/auth-primitives.d.ts +27 -0
  17. package/dist/internal/auth/auth-primitives.js +21 -0
  18. package/dist/internal/billing/index.d.ts +1 -0
  19. package/dist/internal/billing/index.js +2 -0
  20. package/dist/internal/billing/use-free-grant-unspent.d.ts +10 -0
  21. package/dist/internal/billing/use-free-grant-unspent.js +20 -0
  22. package/dist/internal/lib/billing/billing-gate-state.d.ts +20 -0
  23. package/dist/internal/lib/billing/billing-gate-state.js +22 -0
  24. package/dist/internal/lib/error-handler.js +0 -2
  25. package/dist/internal/notifications/notification-inbox.js +1 -1
  26. package/dist/internal/stores/upgrade-dialog-store.d.ts +0 -2
  27. package/dist/internal/stores/upgrade-dialog-store.js +0 -2
  28. package/dist/markdown/setup-links/approval-decision.d.ts +1 -1
  29. package/dist/markdown/setup-links/approval-decision.js +1 -1
  30. package/dist/session/prompts/ask-deck.d.ts +14 -2
  31. package/dist/session/prompts/ask-deck.js +6 -2
  32. package/dist/styles.css +1 -1
  33. package/dist/test-utils/intl.d.ts +37 -47
  34. package/dist/workspace/admin/settings-search.js +4 -12
  35. package/dist/workspace/inbox/workspace-inbox.js +11 -2
  36. package/dist/workspace/layout/new-session-create.d.ts +4 -2
  37. package/dist/workspace/layout/new-session-create.js +11 -0
  38. package/dist/workspace/review/approval-modal.d.ts +6 -6
  39. package/dist/workspace/review/approval-modal.js +10 -14
  40. package/dist/workspace/review/review-center.d.ts +9 -2
  41. package/dist/workspace/review/review-center.js +257 -125
  42. package/dist/workspace/review/review-detail.d.ts +20 -10
  43. package/dist/workspace/review/review-detail.js +39 -44
  44. package/dist/workspace/review/review-meta.d.ts +27 -6
  45. package/dist/workspace/review/review-meta.js +46 -34
  46. package/dist/workspace/sidebar/footer/project-download-app-nav.d.ts +10 -0
  47. package/dist/workspace/sidebar/footer/project-download-app-nav.js +53 -0
  48. package/dist/workspace/sidebar/footer/promo-nav-row.d.ts +2 -1
  49. package/dist/workspace/sidebar/footer/promo-nav-row.js +1 -1
  50. package/dist/workspace/sidebar/project-sidebar.d.ts +6 -1
  51. package/dist/workspace/sidebar/project-sidebar.js +3 -2
  52. package/dist/workspace/sidebar/workspace-menu-model.d.ts +19 -13
  53. package/dist/workspace/sidebar/workspace-menu-model.js +7 -8
  54. package/package.json +3 -3
  55. package/dist/customize/sections/view/subscription-usage-tab.d.ts +0 -25
  56. package/dist/customize/sections/view/subscription-usage-tab.js +0 -121
package/dist/i18n/en.d.ts CHANGED
@@ -98,16 +98,6 @@ declare const catalog: {
98
98
  access: string;
99
99
  actions: string;
100
100
  coolingDown: string;
101
- usageFiveHour: string;
102
- usageWeekly: string;
103
- usageWeeklyModel: string;
104
- usagePercent: string;
105
- usagePercentResets: string;
106
- usageLimitReached: string;
107
- usageLimitResets: string;
108
- usageNotSeen: string;
109
- usageObserved: string;
110
- usageAriaLabel: string;
111
101
  member: string;
112
102
  members: string;
113
103
  actionsFor: string;
@@ -1779,6 +1769,8 @@ declare const catalog: {
1779
1769
  title: string;
1780
1770
  description: string;
1781
1771
  confirmDescription: string;
1772
+ unknownDescription: string;
1773
+ closedDescription: string;
1782
1774
  notReceived: string;
1783
1775
  confirmNotReceived: string;
1784
1776
  resendIn: string;
@@ -6197,6 +6189,11 @@ declare const catalog: {
6197
6189
  textadca5dfd1e42: string;
6198
6190
  text16ba47efb9f2: string;
6199
6191
  textfd8b8dae4421: string;
6192
+ text674900a77b79: string;
6193
+ text765a8cb04cf5: string;
6194
+ texta68ee4167406: string;
6195
+ texta69c4dece144: string;
6196
+ textab3aff8f7642: string;
6200
6197
  };
6201
6198
  publicShareConfirm: {
6202
6199
  title: string;
@@ -6377,6 +6374,10 @@ declare const catalog: {
6377
6374
  deniedDescription: string;
6378
6375
  failed: string;
6379
6376
  };
6377
+ reviewPane: {
6378
+ emptyTitle: string;
6379
+ emptyDescription: string;
6380
+ };
6380
6381
  };
6381
6382
  commandPalette: {
6382
6383
  title: string;
@@ -9786,45 +9787,34 @@ declare const catalog: {
9786
9787
  fiveHour: string;
9787
9788
  weekly: string;
9788
9789
  weeklyModel: string;
9789
- reconnect: string;
9790
- disabledTitle: string;
9791
- disabledDescription: string;
9792
- text0: string;
9793
- text1: string;
9794
- text2: string;
9795
- text3: string;
9796
- text4: string;
9797
- text5: string;
9798
- text6: string;
9799
- text7: string;
9800
- text8: string;
9801
- text9: string;
9802
- text10: string;
9803
- text11: string;
9804
- text12: string;
9805
- text13: string;
9806
- text14: string;
9807
- text15: string;
9808
- text16: string;
9809
- text17: string;
9810
- text18: string;
9811
- text19: string;
9812
- text20: string;
9813
- text21: string;
9814
- text22: string;
9815
- text23: string;
9816
- text24: string;
9817
- text25: string;
9818
- text26: string;
9819
- resets: string;
9790
+ inactive: string;
9791
+ limitReached: string;
9792
+ checking: string;
9793
+ title: string;
9820
9794
  observed: string;
9821
9795
  meterLabel: string;
9822
- refreshLabel: string;
9823
- fiveHourNotReported: string;
9824
- fableIncluded: string;
9825
- chatgptUsage: string;
9826
- claudeUsage: string;
9827
- allSubscriptions: string;
9796
+ extraUsage: string;
9797
+ apps: string;
9798
+ codeReview: string;
9799
+ percent: string;
9800
+ percentResets: string;
9801
+ percentBack: string;
9802
+ resetPassed: string;
9803
+ notStarted: string;
9804
+ reconnectToSee: string;
9805
+ availableNow: string;
9806
+ availableCount: string;
9807
+ nextBack: string;
9808
+ rowPeak: string;
9809
+ rowSomeLimited: string;
9810
+ rowAllLimited: string;
9811
+ rowAllLimitedBack: string;
9812
+ noUsageYet: string;
9813
+ refreshFailed: string;
9814
+ loadFailed: string;
9815
+ rowSomeLimitedBack: string;
9816
+ weeklyAll: string;
9817
+ notReported: string;
9828
9818
  };
9829
9819
  gatewayRouting: {
9830
9820
  exceptions: string;
package/dist/i18n/en.js CHANGED
@@ -99,16 +99,6 @@ const catalog = {
99
99
  "access": "Access",
100
100
  "actions": "Actions",
101
101
  "coolingDown": "Cooling down",
102
- "usageFiveHour": "5-hour",
103
- "usageWeekly": "Weekly",
104
- "usageWeeklyModel": "Weekly · {model}",
105
- "usagePercent": "{percent}% used",
106
- "usagePercentResets": "{percent}% · resets {time}",
107
- "usageLimitReached": "Limit reached",
108
- "usageLimitResets": "Limit reached · resets {time}",
109
- "usageNotSeen": "Usage appears after the first request",
110
- "usageObserved": "Updated {time}",
111
- "usageAriaLabel": "{window}: {percent}% used",
112
102
  "member": "member",
113
103
  "members": "members",
114
104
  "actionsFor": "Actions for {label}",
@@ -1780,6 +1770,8 @@ const catalog = {
1780
1770
  "title": "Check your email",
1781
1771
  "description": "We sent a link to <address>{email}</address>. Open it to continue.",
1782
1772
  "confirmDescription": "We sent a confirmation email to <address>{email}</address>. Confirm your email to continue.",
1773
+ "unknownDescription": "We emailed <address>{email}</address> — a sign-in link, or a confirmation link for a new account.",
1774
+ "closedDescription": "If <address>{email}</address> has an account, its sign-in link is on its way.",
1783
1775
  "notReceived": "Didn't receive the link?",
1784
1776
  "confirmNotReceived": "Didn't receive the confirmation email?",
1785
1777
  "resendIn": "Resend in {seconds}",
@@ -6197,7 +6189,12 @@ const catalog = {
6197
6189
  "textfd8fee75dbb5": "IdP groups map to roles in this workspace",
6198
6190
  "textadca5dfd1e42": "Bundle members into groups and give the whole group a role: one grant instead of dozens, revoked just as easily.",
6199
6191
  "text16ba47efb9f2": "A complete, filterable trail of every admin and agent action in this workspace: who did what, where, and when.",
6200
- "textfd8b8dae4421": "Danger zone"
6192
+ "textfd8b8dae4421": "Danger zone",
6193
+ "text674900a77b79": "LLM",
6194
+ "text765a8cb04cf5": "LLM Hold Refund",
6195
+ "texta68ee4167406": "Proxy",
6196
+ "texta69c4dece144": "Storage",
6197
+ "textab3aff8f7642": "Top-up Bonus"
6201
6198
  },
6202
6199
  "publicShareConfirm": {
6203
6200
  "title": "Create a public link?",
@@ -6377,6 +6374,10 @@ const catalog = {
6377
6374
  "denied": "Access denied",
6378
6375
  "deniedDescription": "My Kortix gets your answer.",
6379
6376
  "failed": "Could not send your decision. Try again."
6377
+ },
6378
+ "reviewPane": {
6379
+ "emptyTitle": "Select an item",
6380
+ "emptyDescription": "Its details open here. Press J and K to move through the list."
6380
6381
  }
6381
6382
  },
6382
6383
  "commandPalette": {
@@ -9784,48 +9785,37 @@ const catalog = {
9784
9785
  "issue": "Issue #{number}"
9785
9786
  },
9786
9787
  "subscriptionUsage": {
9787
- "fiveHour": "5-hour limit",
9788
- "weekly": "Weekly limit",
9788
+ "fiveHour": "5-hour",
9789
+ "weekly": "Weekly",
9789
9790
  "weeklyModel": "Weekly · {model}",
9790
- "reconnect": "Reconnect",
9791
- "disabledTitle": "Subscription usage is unavailable",
9792
- "disabledDescription": "Subscription connections are not enabled for this workspace.",
9793
- "text0": "Reconnect needed",
9794
- "text1": "Inactive",
9795
- "text2": "Refresh failed",
9796
- "text3": "Awaiting usage",
9797
- "text4": "Limit reached",
9798
- "text5": "Last known usage",
9799
- "text6": "Usage reported",
9800
- "text7": "Subscription",
9801
- "text8": "used",
9802
- "text9": "Reset time passed · refresh for current usage",
9803
- "text10": "Reset time not reported",
9804
- "text11": "Checking provider usage…",
9805
- "text12": "No usage reported yet. Refresh after using this subscription.",
9806
- "text13": "Could not update. Showing last known data.",
9807
- "text14": "Waiting for provider data",
9808
- "text15": "Checking…",
9809
- "text16": "Refresh",
9810
- "text17": "Subscription usage",
9811
- "text18": "Track the limits of your connected ChatGPT and Claude subscriptions.",
9812
- "text19": "Usage could not load",
9813
- "text20": "Try loading your connected subscriptions again.",
9814
- "text21": "Retry",
9815
- "text22": "No connected subscriptions",
9816
- "text23": "Connect ChatGPT or Claude in Providers to see reported usage and reset times.",
9817
- "text24": "Connect a subscription",
9818
- "text25": "Usage is shared across apps that use the same subscription. Checks automatically every minute while this tab is open.",
9819
- "text26": "Limits vary by plan. Only windows reported by your connection appear here; missing data does not mean unlimited usage. File limits are not reported. API spend appears in Costs.",
9820
- "resets": "Resets {time}",
9791
+ "inactive": "Inactive",
9792
+ "limitReached": "Limit reached",
9793
+ "checking": "Checking provider usage…",
9794
+ "title": "Subscription usage",
9821
9795
  "observed": "Observed {time}",
9822
9796
  "meterLabel": "{label}: {percent}% used",
9823
- "refreshLabel": "Refresh {label} usage",
9824
- "fiveHourNotReported": "Five-hour window not reported by this connection.",
9825
- "fableIncluded": "Fable usage also counts toward your overall weekly allowance.",
9826
- "chatgptUsage": "ChatGPT subscription usage",
9827
- "claudeUsage": "Claude subscription usage",
9828
- "allSubscriptions": "All subscriptions"
9797
+ "extraUsage": "Extra usage",
9798
+ "apps": "Apps",
9799
+ "codeReview": "Code review",
9800
+ "percent": "{percent}%",
9801
+ "percentResets": "{percent}% · resets {time}",
9802
+ "percentBack": "{percent}% · back {time}",
9803
+ "resetPassed": "Reset · updating",
9804
+ "notStarted": "Not started",
9805
+ "reconnectToSee": "Reconnect to see usage",
9806
+ "availableNow": "Available now",
9807
+ "availableCount": "{available} of {total, plural, one {# account} other {# accounts}}",
9808
+ "nextBack": "Next back",
9809
+ "rowPeak": "{window} · {percent}% used",
9810
+ "rowSomeLimited": "{limited} of {total} at limit",
9811
+ "rowAllLimited": "At limit",
9812
+ "rowAllLimitedBack": "At limit · back {time}",
9813
+ "noUsageYet": "No usage reported yet.",
9814
+ "refreshFailed": "Could not refresh · showing last known usage.",
9815
+ "loadFailed": "Usage could not load.",
9816
+ "rowSomeLimitedBack": "{limited} of {total} at limit · next back {time}",
9817
+ "weeklyAll": "Weekly · all models",
9818
+ "notReported": "Not reported"
9829
9819
  },
9830
9820
  "gatewayRouting": {
9831
9821
  "exceptions": "Exceptions",
@@ -49,6 +49,8 @@ export const APP_REGISTRY_TRANSLATION_KEYS = {
49
49
  'How this works': 'textbdbd7706de64',
50
50
  'IdP groups map to roles on your workspaces': 'textb978cac03a79',
51
51
  'Kortix prepares a machine the first time you start a session here. Nothing needs to be set up in advance.': 'text5c48b158361a',
52
+ LLM: 'text674900a77b79',
53
+ 'LLM Hold Refund': 'text765a8cb04cf5',
52
54
  'LLM Overage': 'text3f6365f81e08',
53
55
  'Machine Bonus': 'text917ffd97c41a',
54
56
  Members: 'text1044a4c056d0',
@@ -65,6 +67,7 @@ export const APP_REGISTRY_TRANSLATION_KEYS = {
65
67
  Workspace: 'text985959785319',
66
68
  Workspaces: 'text04e2a9728af7',
67
69
  Promotional: 'texta9b8859fba62',
70
+ Proxy: 'texta68ee4167406',
68
71
  Purchase: 'text5b5e9c65b400',
69
72
  'Reflects on recent activity and curates .kortix/memory, opening a memory CR each run.': 'textb762cc8a7284',
70
73
  Refund: 'text6b37bd35081f',
@@ -86,11 +89,13 @@ export const APP_REGISTRY_TRANSLATION_KEYS = {
86
89
  Skills: 'text66d0f523a379',
87
90
  'Spend & gateway': 'text9e0bb75942fd',
88
91
  'Stream events out via audit webhooks': 'textc12b32f6ae34',
92
+ Storage: 'texta69c4dece144',
89
93
  Su: 'text2d88a3a2842e',
90
94
  'Sync membership automatically from your identity provider': 'texte164235035e6',
91
95
  Th: 'text3bff939c10f4',
92
96
  'This workspace’s environment is ready': 'text108fd36702c5',
93
97
  'Tier Grant': 'text16a2a5617354',
98
+ 'Top-up Bonus': 'textab3aff8f7642',
94
99
  Tokens: 'texta039dfb9628b',
95
100
  Triggers: 'texte62f2148a64d',
96
101
  Tu: 'text62afcc74654d',
@@ -55,6 +55,33 @@ export declare function InfoStrip({ message }: {
55
55
  export declare function SuccessStrip({ message }: {
56
56
  message: string;
57
57
  }): import("react").JSX.Element;
58
+ /**
59
+ * The device-code row of an RFC 8628 approval page (Capture sign-in, computer
60
+ * pairing): the code the person checks against their other screen, and the
61
+ * time left to decide. `countdown` is the formatted `m:ss` remaining.
62
+ */
63
+ export declare function DeviceCodeHeader({ code, countdown }: {
64
+ code: string;
65
+ countdown: string;
66
+ }): import("react").JSX.Element;
67
+ /**
68
+ * The approve/deny pair of an approval page. One shared busy state: either
69
+ * mutation pending disables both buttons, its spinner on the button that is
70
+ * running. Failures render as the strip above the pair — pass only the errors
71
+ * the page shows. `approveDisabled` adds a page-side gate (no workspace
72
+ * picked yet), on top of the busy state.
73
+ */
74
+ export declare function ApproveDenyActions({ approveLabel, denyLabel, onApprove, onDeny, approvePending, denyPending, approveError, denyError, approveDisabled, }: {
75
+ approveLabel: React.ReactNode;
76
+ denyLabel: React.ReactNode;
77
+ onApprove: () => void;
78
+ onDeny: () => void;
79
+ approvePending: boolean;
80
+ denyPending: boolean;
81
+ approveError?: string | null;
82
+ denyError?: string | null;
83
+ approveDisabled?: boolean;
84
+ }): import("react").JSX.Element;
58
85
  export declare function CodeInput({ value, onChange, disabled, autoFocus, invalid, }: {
59
86
  value: string;
60
87
  onChange: (next: string) => void;
@@ -10,6 +10,8 @@ import { m, useReducedMotion } from 'motion/react';
10
10
  import { useRef } from 'react';
11
11
  import { inputFocusClasses, inputSurfaceClasses } from '../../primitives/input.js';
12
12
  import { KortixLogo } from '../../primitives/kortix-logo.js';
13
+ import { Button } from '../../primitives/button.js';
14
+ import Loading from '../../primitives/loading.js';
13
15
  import { applyBackspace, applyBoxInput, CODE_LENGTH, insertDigits, } from './code-input-logic.js';
14
16
  import { useTranslations } from '../../i18n/index.js';
15
17
  import { cn } from '../lib/utils.js';
@@ -60,6 +62,25 @@ export function InfoStrip({ message }) {
60
62
  export function SuccessStrip({ message }) {
61
63
  return (_jsxs("div", { className: "bg-muted text-foreground mb-5 flex items-center gap-2 rounded-md px-3 py-2.5", children: [_jsx(InfoCircleSolid, { weight: "fill", className: "text-kortix-green size-4 shrink-0" }), _jsx("span", { className: "text-sm", children: message })] }));
62
64
  }
65
+ /**
66
+ * The device-code row of an RFC 8628 approval page (Capture sign-in, computer
67
+ * pairing): the code the person checks against their other screen, and the
68
+ * time left to decide. `countdown` is the formatted `m:ss` remaining.
69
+ */
70
+ export function DeviceCodeHeader({ code, countdown }) {
71
+ return (_jsxs("div", { className: "flex items-center justify-between gap-3 rounded-md border px-3.5 py-3", children: [_jsx("span", { className: "text-foreground font-mono text-lg font-medium tracking-widest tabular-nums", children: code }), _jsx("span", { className: "text-muted-foreground font-mono text-xs tabular-nums", children: countdown })] }));
72
+ }
73
+ /**
74
+ * The approve/deny pair of an approval page. One shared busy state: either
75
+ * mutation pending disables both buttons, its spinner on the button that is
76
+ * running. Failures render as the strip above the pair — pass only the errors
77
+ * the page shows. `approveDisabled` adds a page-side gate (no workspace
78
+ * picked yet), on top of the busy state.
79
+ */
80
+ export function ApproveDenyActions({ approveLabel, denyLabel, onApprove, onDeny, approvePending, denyPending, approveError, denyError, approveDisabled = false, }) {
81
+ const busy = approvePending || denyPending;
82
+ return (_jsxs("div", { className: "space-y-3", children: [approveError ? _jsx(ErrorStrip, { message: approveError }) : null, denyError ? _jsx(ErrorStrip, { message: denyError }) : null, _jsxs(Button, { size: "lg", className: "w-full", onClick: onApprove, disabled: busy || approveDisabled, children: [approvePending ? _jsx(Loading, { className: "size-4 shrink-0" }) : null, approveLabel] }), _jsxs(Button, { variant: "outline", size: "lg", className: "text-destructive border-destructive/30 hover:bg-destructive/5 hover:text-destructive focus-visible:ring-destructive/35 w-full", onClick: onDeny, disabled: busy, children: [denyPending ? _jsx(Loading, { className: "text-destructive! size-4 shrink-0" }) : null, denyLabel] })] }));
83
+ }
63
84
  /* ─── Six-box code input ───────────────────────────────────────────────── */
64
85
  export function CodeInput({ value, onChange, disabled, autoFocus = true, invalid = false, }) {
65
86
  const refs = useRef([]);
@@ -10,6 +10,7 @@ export { useTransactions } from './use-transactions.js';
10
10
  export { SESSION_COST_PAGE_SIZE, useSessionCostDetail, useSessionCostProjects, useSessionCosts, } from './use-session-costs.js';
11
11
  export { COST_PAGE_SIZE, useCostByProject, useCostSummary } from './use-cost-explorer.js';
12
12
  export { useDownloadRestriction } from './use-download-restriction.js';
13
+ export { useFreeGrantUnspent } from './use-free-grant-unspent.js';
13
14
  export type { AccountState, PlanFamily, ResolvedPlanView } from '@kortix/sdk';
14
15
  /**
15
16
  * The plan the account BEHAVES as. Prefer this over
@@ -27,6 +27,8 @@ export { SESSION_COST_PAGE_SIZE, useSessionCostDetail, useSessionCostProjects, u
27
27
  export { COST_PAGE_SIZE, useCostByProject, useCostSummary } from './use-cost-explorer.js';
28
28
  // Download restriction for free tier
29
29
  export { useDownloadRestriction } from './use-download-restriction.js';
30
+ // The on-open paywall gate for a further workspace (KRTX-4713)
31
+ export { useFreeGrantUnspent } from './use-free-grant-unspent.js';
30
32
  /**
31
33
  * The plan the account BEHAVES as. Prefer this over
32
34
  * `accountStateSelectors.tierKey` for anything a person reads and for any
@@ -0,0 +1,10 @@
1
+ /** @internal Kortix apps only. No semver: it may change in any release. */
2
+ import type { AccountState } from '@kortix/sdk';
3
+ /**
4
+ * Whether the person's free credits are unspent while the workspace being
5
+ * opened has none (KRTX-4713) — the decision is `freeGrantUnspentElsewhere`;
6
+ * this hook reads the claimed workspace's state it needs. `undefined` while
7
+ * that read is in flight (or it errored), so a caller never decides from a
8
+ * half-read account: hold the modal, never greet with a paywall.
9
+ */
10
+ export declare function useFreeGrantUnspent(state: AccountState | null | undefined): boolean | undefined;
@@ -0,0 +1,20 @@
1
+ 'use client';
2
+ import { freeGrantUnspentElsewhere } from '../lib/billing/billing-gate-state.js';
3
+ import { useAccountState } from './use-account-state.js';
4
+ /**
5
+ * Whether the person's free credits are unspent while the workspace being
6
+ * opened has none (KRTX-4713) — the decision is `freeGrantUnspentElsewhere`;
7
+ * this hook reads the claimed workspace's state it needs. `undefined` while
8
+ * that read is in flight (or it errored), so a caller never decides from a
9
+ * half-read account: hold the modal, never greet with a paywall.
10
+ */
11
+ export function useFreeGrantUnspent(state) {
12
+ const claimedWorkspaceId = state?.credits?.free_grant?.eligible === false
13
+ ? (state.credits.free_grant.claimed_workspace_id ?? null)
14
+ : null;
15
+ const { data: claimedState } = useAccountState({
16
+ accountId: claimedWorkspaceId ?? undefined,
17
+ enabled: !!claimedWorkspaceId,
18
+ });
19
+ return freeGrantUnspentElsewhere(state, claimedState);
20
+ }
@@ -30,6 +30,10 @@ export type AccountStateLike = Pick<AccountState, 'billing_state' | 'has_active_
30
30
  total?: number | null;
31
31
  lifetime_granted?: number | null;
32
32
  lifetime_purchased?: number | null;
33
+ free_grant?: {
34
+ eligible: boolean;
35
+ claimed_workspace_id: string | null;
36
+ } | null;
33
37
  } | null;
34
38
  subscription?: {
35
39
  subscription_id?: string | null;
@@ -61,6 +65,22 @@ export declare const RUN_FLOOR_USD = 0.01;
61
65
  * subscription there, never only "Continue on Free" (review finding 10).
62
66
  */
63
67
  export declare function billingModalNeedsTopUp(accountState: AccountStateLike | null | undefined, state: BillingState | null): boolean;
68
+ /**
69
+ * Whether the person's free credits are unspent while THIS workspace has none
70
+ * (KRTX-4713). A further workspace on Free holds no grant by design — the
71
+ * person's free credits live in their first workspace, reported as
72
+ * `free_grant: { eligible: false, claimed_workspace_id }`. Opening that
73
+ * workspace must never greet them with the Out-of-credits modal while those
74
+ * credits still cover a run: the modal waits for an actual blocked turn (the
75
+ * send gate, a 402). Returns
76
+ *
77
+ * - `false` — not the case: no claim elsewhere, or the claimed wallet is dry
78
+ * (a true zero balance — the modal may open);
79
+ * - `true` — the claimed workspace's wallet still runs: hold the modal;
80
+ * - `undefined` — a claim exists but the claimed workspace's state has not
81
+ * loaded: hold the modal until it does (`useFreeGrantUnspent` reads it).
82
+ */
83
+ export declare function freeGrantUnspentElsewhere(state: AccountStateLike | null | undefined, claimedState: AccountStateLike | null | undefined): boolean | undefined;
64
84
  /**
65
85
  * Warn below this wallet value (dollars) on an account that is still running,
66
86
  * or below a fifth of what the account has been given, whichever is lower
@@ -76,6 +76,28 @@ export function billingModalNeedsTopUp(accountState, state) {
76
76
  const balance = accountState?.credits?.total;
77
77
  return typeof balance === 'number' && balance < RUN_FLOOR_USD;
78
78
  }
79
+ /**
80
+ * Whether the person's free credits are unspent while THIS workspace has none
81
+ * (KRTX-4713). A further workspace on Free holds no grant by design — the
82
+ * person's free credits live in their first workspace, reported as
83
+ * `free_grant: { eligible: false, claimed_workspace_id }`. Opening that
84
+ * workspace must never greet them with the Out-of-credits modal while those
85
+ * credits still cover a run: the modal waits for an actual blocked turn (the
86
+ * send gate, a 402). Returns
87
+ *
88
+ * - `false` — not the case: no claim elsewhere, or the claimed wallet is dry
89
+ * (a true zero balance — the modal may open);
90
+ * - `true` — the claimed workspace's wallet still runs: hold the modal;
91
+ * - `undefined` — a claim exists but the claimed workspace's state has not
92
+ * loaded: hold the modal until it does (`useFreeGrantUnspent` reads it).
93
+ */
94
+ export function freeGrantUnspentElsewhere(state, claimedState) {
95
+ const grant = state?.credits?.free_grant;
96
+ if (grant?.eligible !== false || !grant.claimed_workspace_id)
97
+ return false;
98
+ const canRun = claimedState?.credits?.can_run;
99
+ return typeof canRun === 'boolean' ? canRun : undefined;
100
+ }
79
101
  /**
80
102
  * Warn below this wallet value (dollars) on an account that is still running,
81
103
  * or below a fifth of what the account has been given, whichever is lower
@@ -214,7 +214,6 @@ export const handleApiError = (error, context, tI18nComplete) => {
214
214
  (typeof errAny === 'object' ? errAny : null);
215
215
  const v2Code = v2Detail?.code ?? errAny?.code;
216
216
  const v2Message = v2Detail?.message ?? v2Detail?.error ?? errAny?.message;
217
- const v2Balance = typeof v2Detail?.balance === 'number' ? v2Detail.balance : 0;
218
217
  // The blocked account (e.g. the project's team account), surfaced by the
219
218
  // billing 402s. Scopes the upgrade dialog so a non-billing member sees the
220
219
  // team's gated CTA, not their own primary account. Absent → primary account.
@@ -241,7 +240,6 @@ export const handleApiError = (error, context, tI18nComplete) => {
241
240
  useUpgradeDialogStore.getState().openUpgradeDialog({
242
241
  reason: v2Code,
243
242
  message: v2Message ?? '',
244
- balance: v2Balance,
245
243
  accountId: v2AccountId,
246
244
  hasSubscription: typeof v2Detail?.has_subscription === 'boolean' ? v2Detail.has_subscription : undefined,
247
245
  // The unambiguous state (billing-state.ts). Preferred over `code`, which
@@ -66,7 +66,7 @@ export function NotificationInboxView({ rows, state, unreadCount, prompt, settin
66
66
  const needsCount = tabUnreadCount(rows, 'needs');
67
67
  const doneCount = tabUnreadCount(rows, 'done');
68
68
  const settingsLabel = (_jsxs(_Fragment, { children: [_jsx(GearSixIcon, { className: "size-3.5 shrink-0" }), t('inbox.settings')] }));
69
- const list = (_jsx("div", { className: "min-h-0 flex-1 overflow-y-auto", children: _jsxs("div", { className: cn('mx-auto flex w-full max-w-4xl flex-col gap-4 px-4 py-6 pb-20', !bare && 'md:px-8'), children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [header ? _jsx("h1", { className: "text-foreground text-xl font-medium text-balance", children: t('inbox.title') }) : null, _jsx("p", { className: "text-muted-foreground text-sm text-pretty", children: t('inbox.description') })] }), _jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [_jsx(Tabs, { value: tab, onValueChange: (value) => setTab(value), children: _jsxs(TabsList, { children: [_jsxs(TabsTrigger, { value: "all", className: "gap-1.5", children: [t('inbox.tabAll'), unreadCount > 0 ? _jsx(CountBadge, { count: unreadCount }) : null] }), _jsxs(TabsTrigger, { value: "needs", className: "gap-1.5", children: [t('inbox.tabNeedsYou'), needsCount > 0 ? _jsx(CountBadge, { count: needsCount, tone: "waiting" }) : null] }), _jsxs(TabsTrigger, { value: "done", className: "gap-1.5", children: [t('inbox.tabDone'), doneCount > 0 ? _jsx(CountBadge, { count: doneCount }) : null] })] }) }), unreadCount > 0 ? (_jsxs(Button, { variant: "outline", size: "sm", className: "gap-1.5", onClick: onMarkAllRead, children: [_jsx(ChecksIcon, { className: "size-3.5 shrink-0" }), t('inbox.markAllRead')] })) : null] }), prompt ? (_jsxs(BannerAlert, { variant: "default", children: [_jsx(BannerAlertMedia, { children: _jsx(BellIcon, {}) }), _jsx(BannerAlertTitle, { children: prompt }), _jsx(BannerAlertActions, { children: _jsxs(ButtonGroup, { children: [_jsx(Button, { variant: "secondary", size: "xs", onClick: onTurnOn, children: t('inbox.turnOn') }), _jsx(Hint, { label: t('inbox.dismiss'), side: "top", children: _jsx(Button, { variant: "secondary", size: "icon-sm", "aria-label": t('inbox.dismiss'), onClick: onDismissPrompt, children: _jsx(XIcon, { className: "size-3.5 shrink-0" }) }) })] }) })] })) : null, state === 'loading' ? (_jsx("div", { className: "space-y-0.5", children: [0, 1, 2].map((index) => (_jsx(Skeleton, { className: "h-14 w-full rounded-lg" }, index))) })) : state === 'error' ? (_jsx(ErrorState, { size: "sm", title: t('inbox.loadError'), action: _jsx(Button, { variant: "outline", size: "sm", onClick: onRetry, children: t('inbox.retry') }) })) : visible.length === 0 ? (_jsx(EmptyState, { size: "sm", media: _jsx(EmptyArt, { icon: BellIcon }), title: tab === 'needs' && rows.length > 0 ? t('inbox.emptyNeedsYou') : t('inbox.empty'), description: tab === 'needs' && rows.length > 0 ? t('inbox.emptyNeedsYouDescription') : t('inbox.emptyDescription') })) : (_jsx("ul", { className: "space-y-0.5", children: visible.map((row) => (_jsx("li", { children: _jsx(InboxRow, { row: row, onOpen: () => onOpenRow(row) }) }, row.id))) })), _jsxs("div", { className: "flex flex-col gap-2 pt-2 sm:flex-row sm:items-center sm:justify-between", children: [_jsx("p", { className: "text-muted-foreground text-sm text-pretty", children: t('inbox.emailOptIn') }), 'href' in settings ? (_jsx(Button, { asChild: true, variant: "outline", size: "sm", className: "gap-1.5 self-start sm:self-auto", children: _jsx(UiLink, { href: settings.href, children: settingsLabel }) })) : (_jsx(Button, { variant: "outline", size: "sm", className: "gap-1.5 self-start sm:self-auto", onClick: settings.onOpen, children: settingsLabel }))] })] }) }));
69
+ const list = (_jsx("div", { className: "min-h-0 flex-1 overflow-y-auto", children: _jsxs("div", { className: cn('mx-auto flex w-full max-w-4xl flex-col gap-4 px-4 py-6 pb-20', !bare && 'md:px-8'), children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [header ? _jsx("h1", { className: "text-foreground text-xl font-medium text-balance", children: t('inbox.title') }) : null, _jsx("p", { className: "text-muted-foreground text-sm text-pretty", children: t('inbox.description') })] }), _jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [_jsx(Tabs, { value: tab, onValueChange: (value) => setTab(value), children: _jsxs(TabsList, { variant: "secondary", size: "sm", children: [_jsxs(TabsTrigger, { value: "all", className: "w-fit flex-none gap-1.5 px-2.5", children: [t('inbox.tabAll'), unreadCount > 0 ? _jsx(CountBadge, { count: unreadCount }) : null] }), _jsxs(TabsTrigger, { value: "needs", className: "w-fit flex-none gap-1.5 px-2.5", children: [t('inbox.tabNeedsYou'), needsCount > 0 ? _jsx(CountBadge, { count: needsCount, tone: "waiting" }) : null] }), _jsxs(TabsTrigger, { value: "done", className: "w-fit flex-none gap-1.5 px-2.5", children: [t('inbox.tabDone'), doneCount > 0 ? _jsx(CountBadge, { count: doneCount }) : null] })] }) }), unreadCount > 0 ? (_jsxs(Button, { variant: "outline", size: "sm", className: "gap-1.5", onClick: onMarkAllRead, children: [_jsx(ChecksIcon, { className: "size-3.5 shrink-0" }), t('inbox.markAllRead')] })) : null] }), prompt ? (_jsxs(BannerAlert, { variant: "default", children: [_jsx(BannerAlertMedia, { children: _jsx(BellIcon, {}) }), _jsx(BannerAlertTitle, { children: prompt }), _jsx(BannerAlertActions, { children: _jsxs(ButtonGroup, { children: [_jsx(Button, { variant: "secondary", size: "xs", onClick: onTurnOn, children: t('inbox.turnOn') }), _jsx(Hint, { label: t('inbox.dismiss'), side: "top", children: _jsx(Button, { variant: "secondary", size: "icon-sm", "aria-label": t('inbox.dismiss'), onClick: onDismissPrompt, children: _jsx(XIcon, { className: "size-3.5 shrink-0" }) }) })] }) })] })) : null, state === 'loading' ? (_jsx("div", { className: "space-y-0.5", children: [0, 1, 2].map((index) => (_jsx(Skeleton, { className: "h-14 w-full rounded-lg" }, index))) })) : state === 'error' ? (_jsx(ErrorState, { size: "sm", title: t('inbox.loadError'), action: _jsx(Button, { variant: "outline", size: "sm", onClick: onRetry, children: t('inbox.retry') }) })) : visible.length === 0 ? (_jsx(EmptyState, { size: "sm", media: _jsx(EmptyArt, { icon: BellIcon }), title: tab === 'needs' && rows.length > 0 ? t('inbox.emptyNeedsYou') : t('inbox.empty'), description: tab === 'needs' && rows.length > 0 ? t('inbox.emptyNeedsYouDescription') : t('inbox.emptyDescription') })) : (_jsx("ul", { className: "space-y-0.5", children: visible.map((row) => (_jsx("li", { children: _jsx(InboxRow, { row: row, onOpen: () => onOpenRow(row) }) }, row.id))) })), _jsxs("div", { className: "flex flex-col gap-2 pt-2 sm:flex-row sm:items-center sm:justify-between", children: [_jsx("p", { className: "text-muted-foreground text-sm text-pretty", children: t('inbox.emailOptIn') }), 'href' in settings ? (_jsx(Button, { asChild: true, variant: "outline", size: "sm", className: "gap-1.5 self-start sm:self-auto", children: _jsx(UiLink, { href: settings.href, children: settingsLabel }) })) : (_jsx(Button, { variant: "outline", size: "sm", className: "gap-1.5 self-start sm:self-auto", onClick: settings.onOpen, children: settingsLabel }))] })] }) }));
70
70
  if (bare)
71
71
  return list;
72
72
  return (
@@ -5,7 +5,6 @@ interface UpgradeDialogState {
5
5
  isOpen: boolean;
6
6
  reason: UpgradeReason;
7
7
  message: string;
8
- balance: number;
9
8
  /** The account that actually needs the upgrade (the blocked account from the
10
9
  * 402 — e.g. the project's owning team account). `undefined` falls back to the
11
10
  * user's primary account. The dialog scopes its billing state + subscribe
@@ -23,7 +22,6 @@ interface UpgradeDialogState {
23
22
  openUpgradeDialog: (opts: {
24
23
  reason?: UpgradeReason;
25
24
  message?: string;
26
- balance?: number;
27
25
  accountId?: string;
28
26
  hasSubscription?: boolean;
29
27
  billingState?: BillingState;
@@ -3,7 +3,6 @@ export const useUpgradeDialogStore = create((set) => ({
3
3
  isOpen: false,
4
4
  reason: 'subscription_required',
5
5
  message: '',
6
- balance: 0,
7
6
  accountId: undefined,
8
7
  hasSubscription: undefined,
9
8
  billingState: undefined,
@@ -11,7 +10,6 @@ export const useUpgradeDialogStore = create((set) => ({
11
10
  isOpen: true,
12
11
  reason: opts.reason ?? 'subscription_required',
13
12
  message: opts.message ?? '',
14
- balance: opts.balance ?? 0,
15
13
  accountId: opts.accountId,
16
14
  hasSubscription: opts.hasSubscription,
17
15
  billingState: opts.billingState,
@@ -42,7 +42,7 @@ export declare function expiryChip(msLeft: number): {
42
42
  /**
43
43
  * The approval itself, without the page frame: the standalone page wraps it in
44
44
  * a bordered card inside `AuthFrame`; the Review Center opens the same panel in
45
- * `ApprovalDecisionModal`, so a call reads and decides the same way on both.
45
+ * `ApprovalDecisionPane`, so a call reads and decides the same way on both.
46
46
  *
47
47
  * Top to bottom (Paper V01, sentence-first): the connector and action with the
48
48
  * time left; one plain sentence of what the agent wants; the agent's own
@@ -187,7 +187,7 @@ function FactRow({ icon, muted = false, children, }) {
187
187
  /**
188
188
  * The approval itself, without the page frame: the standalone page wraps it in
189
189
  * a bordered card inside `AuthFrame`; the Review Center opens the same panel in
190
- * `ApprovalDecisionModal`, so a call reads and decides the same way on both.
190
+ * `ApprovalDecisionPane`, so a call reads and decides the same way on both.
191
191
  *
192
192
  * Top to bottom (Paper V01, sentence-first): the connector and action with the
193
193
  * time left; one plain sentence of what the agent wants; the agent's own
@@ -15,9 +15,21 @@
15
15
  * Undo takes it back; leaving the page sends what waits.
16
16
  */
17
17
  import { type SessionAsk } from '@kortix/sdk';
18
+ import { type ReactNode } from 'react';
19
+ /**
20
+ * The kinds a deck card draws. A connector approval stays in the inbox list.
21
+ * A kind this build does not know is left out, never drawn as an empty card.
22
+ */
23
+ export declare const DECK_KINDS: ReadonlySet<SessionAsk['kind']>;
18
24
  /** The deck's order: oldest first, skipped asks after the rest. Pure; exported for tests. */
19
25
  export declare function deckOrder(asks: readonly SessionAsk[], skipped: readonly string[], hidden: ReadonlySet<string>): SessionAsk[];
20
- export declare function AskDeck({ projectId, onOpenSession }: {
26
+ export declare function AskDeck({ projectId, onOpenSession, empty, paused, }: {
21
27
  projectId: string;
28
+ /** The host shows something else over the deck: it draws nothing and its
29
+ * keys answer nothing, but stays mounted so staged answers keep Undo. */
30
+ paused?: boolean;
22
31
  onOpenSession?: (sessionId: string) => void;
23
- }): import("react").JSX.Element;
32
+ /** Drawn once no card is left, in place of the deck's own "Nothing waits on
33
+ * you" (a host that shows other waiting items beside the deck). */
34
+ empty?: ReactNode;
35
+ }): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react").JSX.Element | null;
@@ -40,7 +40,7 @@ const SWIPE_PX = 96;
40
40
  * The kinds a deck card draws. A connector approval stays in the inbox list.
41
41
  * A kind this build does not know is left out, never drawn as an empty card.
42
42
  */
43
- const DECK_KINDS = new Set(['question', 'permission', 'access']);
43
+ export const DECK_KINDS = new Set(['question', 'permission', 'access']);
44
44
  function relativeTime(iso) {
45
45
  const seconds = Math.max(0, Math.round((Date.now() - Date.parse(iso)) / 1000));
46
46
  if (seconds < 60)
@@ -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 }) {
66
+ export function AskDeck({ projectId, onOpenSession, empty, paused = false, }) {
67
67
  const t = useTranslations('hardcodedUi.askDeck');
68
68
  const queryClient = useQueryClient();
69
69
  const { data, isLoading, isError, refetch } = useSessionAsks(projectId);
@@ -152,12 +152,16 @@ export function AskDeck({ projectId, onOpenSession }) {
152
152
  });
153
153
  }, [t]);
154
154
  const skip = useCallback((ask) => setSkipped((prev) => [...prev.filter((id) => id !== ask.id), ask.id]), []);
155
+ if (paused)
156
+ return null;
155
157
  if (isLoading)
156
158
  return _jsx(Skeleton, { className: "h-64 w-full rounded-lg" });
157
159
  if (isError) {
158
160
  return (_jsx(EmptyState, { icon: ShieldWarningIcon, title: t('loadFailed'), action: _jsx(Button, { size: "sm", variant: "outline", onClick: () => void refetch(), children: t('retry') }) }));
159
161
  }
160
162
  if (!current) {
163
+ if (empty !== undefined)
164
+ return empty;
161
165
  return _jsx(EmptyState, { icon: CheckIcon, title: t('emptyTitle'), description: t('emptyDescription') });
162
166
  }
163
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) => decide(current, verdict, answers), onSkip: () => skip(current), onOpenSession: onOpenSession }, current.id)] }));