@micha.bigler/ui-core-micha 4.15.0 → 4.17.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.17.0 - UCM-BILL-9
4
+
5
+ Users tab, every app: the billing access column is a short coloured status (`accountAccessText` now returns
6
+ "Freigeschaltet", "{plan name} · bis {short date}", "Team · bis {date}", "Schreibgeschützt" or "Betreiber"; plan names from
7
+ `getMe().plans`, neutral `Billing.OP_SUBSCRIPTION` when missing, never the key) and the free-access switch moved to its own
8
+ "Ohne Abo" column without a visible label (`FreeAccessSwitch` option `hideLabel`; "–" for subscription, team and operator
9
+ rows); grant and revoke dialogs unchanged. `useBillingUsersColumn` returns two columns and takes `isOperator` (default
10
+ `user.is_superuser`). The built-in delete in `UserListComponent` is an icon button named "Löschen – {name}" and is shown
11
+ disabled on the own row instead of hidden; confirmation, permissions and app row actions unchanged. New `formatShortDate`.
12
+ New keys `Billing.OP_FREE_ACCESS_SHORT`, `OP_TEAM`, `OP_OPERATOR`, `OP_SUBSCRIPTION`, `OP_NO_SUBSCRIPTION`,
13
+ `OP_FREE_ACCESS_FOR`, `Common.DELETE_FOR`.
14
+
15
+ ## 4.16.0 - UCM-CHAT-7
16
+
17
+ Opt-in compact chat composer: `ChatWorkspace` props `composerLayout` (`'standard'` default, `'compact'`) and
18
+ `renderComposerContext({ chat })`; `ChatComposer` props `layout`, `context`, `notice`; `ModelPicker` prop `shortLabel`.
19
+ Compact: a non-wrapping context row (host content, model choice at its end), a full-width input with an icon Send that
20
+ becomes Stop while running, the short model label, and the long-chat hint as one dismissible line per chat
21
+ (`Chat.longChatShort` with "Neuer Chat"). New keys `Chat.longChatShort`, `Chat.stopAnswer`, `Chat.dismissNotice`.
22
+ Without the option the composer, its texts and `renderComposerExtra` are unchanged.
23
+
3
24
  ## 4.15.0 - UCM-PERF-4
4
25
 
5
26
  Opt-in `AuthProvider` prop `bootstrap` (`true` for `/api/bootstrap/`, or a same-origin path; requires
package/README.md CHANGED
@@ -23,6 +23,15 @@ the kit's navigation groups: `my-account` (Profile, Security), `management` (Use
23
23
  then appears in that group after the kit's own tabs, in the order of `extraTabs`, in the desktop sidebar and in the
24
24
  phone navigation. Without `group`, or with `more` or an unknown value, it stays in "More" as before.
25
25
 
26
+ ## Users tab: access column and delete
27
+
28
+ With billing in the account page, the user list shows two columns: "Zugang", a short coloured status ("Freigeschaltet",
29
+ "{Plan} · bis {Datum}", "Team · bis {Datum}", "Schreibgeschützt", "Betreiber"), and "Ohne Abo", the free-access switch
30
+ without a visible label (only for free and read-only rows; "–" otherwise). Plan names come from the app's own catalogue
31
+ (`getMe().plans`); a plan without a name shows "Abo", never its key. Operator rows default to `user.is_superuser`;
32
+ `useBillingUsersColumn({ isOperator: ({ user, account }) => ... })` overrides that. The built-in delete is an icon button
33
+ named "Löschen – {Name}", shown disabled on the own row; confirmation, permissions and app row actions are unchanged.
34
+
26
35
  ## Account section: plan choice on the app's own page
27
36
 
28
37
  `SubscriptionSection` shows an inline plan picker for an account without access. An app with its own plan page passes
@@ -141,6 +150,19 @@ extra peers are optional: `@micha.bigler/ui-core-micha/charts` (`@mui/x-charts`)
141
150
  (`react-markdown`, `remark-gfm`). Install those peers only in apps that import the sub-path. The 4.0.0 entry in
142
151
  `CHANGELOG.md` has the migration table.
143
152
 
153
+ ## Shared chat: compact composer (opt-in)
154
+
155
+ `<ChatWorkspace composerLayout="compact" renderComposerContext={({ chat }) => ...}>` lays the composer out in two
156
+ rows: a context row with the host's content (for example chips of what was added to the chat) and the model choice at
157
+ its end — one line that never wraps, the host content is clipped first (plain text gets an ellipsis; give element
158
+ items `minWidth: 0` and their own ellipsis, as MUI `Chip` labels have, and a "+n" item, so they shorten instead of
159
+ being cut) — and a full-width input with an icon Send that
160
+ becomes Stop ("Antwort stoppen") while an answer runs. The model button then shows a short label ("Sonnet · Gründlich")
161
+ without vendor and version. The long-chat hint becomes one line with "Neuer Chat" and a close button; closed, it stays
162
+ closed for that chat until the page reloads, and another chat shows it again. `renderComposerExtra` keeps rendering
163
+ above the composer. Without `composerLayout` the composer is unchanged. `ChatComposer` takes the same `layout`,
164
+ `context` and `notice` props directly; `ModelPicker` takes `shortLabel`.
165
+
144
166
  ## Shared chat: host controls
145
167
 
146
168
  `ChatWorkspace` (from `@micha.bigler/ui-core-micha/chat`) takes optional props for apps that put UI around the surface;
@@ -1,29 +1,42 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React from 'react';
3
- import { Button, Stack, Typography } from '@mui/material';
3
+ import { Button, Chip, Stack, Typography } from '@mui/material';
4
4
  import { useTranslation } from 'react-i18next';
5
- import { formatDate } from './format';
6
- import { FreeAccessSwitch } from './FreeAccessSwitch';
7
- export function accountAccessText(account, t, language) {
5
+ import { formatShortDate } from './format';
6
+ import SoftChip from '../components/SoftChip';
7
+ export const BILLING_ACCESS_BADGE_SX = { maxWidth: '100%' };
8
+ export function accountAccessText(account, t, language, { planNames = {}, isOperator = false } = {}) {
8
9
  if (!account)
9
10
  return '–'; // no row for this person (not loaded): say nothing rather than claim read-only
10
11
  const access = account.access || {};
12
+ if (isOperator)
13
+ return t('Billing.OP_OPERATOR');
14
+ if (access.status === 'read_only')
15
+ return t('Billing.OP_READ_ONLY');
11
16
  if (access.source === 'subscription') {
12
- const date = formatDate(account.term_ends_at || access.ends_at, language);
13
- const plan = account.plan_key || '';
14
- return [t('Billing.OP_PLAN', { plan }), date && t('Billing.OP_UNTIL', { date }), access.status === 'read_only' && t('Billing.OP_READ_ONLY')].filter(Boolean).join(' · ');
17
+ const date = formatShortDate(account.term_ends_at || access.ends_at, language);
18
+ const plan = planNames[account.plan_key] || t('Billing.OP_SUBSCRIPTION');
19
+ return [plan, date && t('Billing.OP_UNTIL', { date })].filter(Boolean).join(' · ');
15
20
  }
16
21
  if (access.source === 'team') {
17
- const date = formatDate(access.ends_at, language);
18
- return [t('Billing.OP_TEAM_SEAT'), date && t('Billing.OP_UNTIL', { date }), access.status === 'read_only' && t('Billing.OP_READ_ONLY')].filter(Boolean).join(' · ');
22
+ const date = formatShortDate(access.ends_at, language);
23
+ return [t('Billing.OP_TEAM'), date && t('Billing.OP_UNTIL', { date })].filter(Boolean).join(' · ');
19
24
  }
20
- if (access.source === 'free')
21
- return [t('Billing.OP_FREE_ACCESS'), access.status === 'read_only' && t('Billing.OP_READ_ONLY')].filter(Boolean).join(' · ');
25
+ if (access.source === 'free' && access.status !== 'read_only')
26
+ return t('Billing.OP_FREE_ACCESS_SHORT');
22
27
  return t('Billing.OP_READ_ONLY');
23
28
  }
24
- export function BillingAccessCell({ account, api, onChanged }) {
29
+ export function BillingAccessCell({ account, planNames, isOperator = false }) {
25
30
  const { t, i18n } = useTranslation();
26
- return _jsxs(Stack, { spacing: 0.5, children: [_jsx(Typography, { children: accountAccessText(account, t, i18n.language) }), account && _jsx(FreeAccessSwitch, { account: account, api: api, onChanged: onChanged })] });
31
+ if (!account)
32
+ return '–';
33
+ const access = account.access || {};
34
+ const label = accountAccessText(account, t, i18n.language, { planNames, isOperator });
35
+ // Operator is neutral; the others are the kit's soft tinted status chips, as in the prototype.
36
+ if (isOperator)
37
+ return _jsx(Chip, { size: "small", variant: "outlined", label: label, sx: BILLING_ACCESS_BADGE_SX });
38
+ const tone = access.status === 'read_only' ? 'warning' : access.source === 'subscription' ? 'success' : 'primary';
39
+ return _jsx(SoftChip, { tone: tone, label: label });
27
40
  }
28
41
  export function BillingAccessError({ onRetry }) {
29
42
  const { t } = useTranslation();
@@ -1,10 +1,10 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React, { useId, useRef, useState } from 'react';
3
- import { Alert, Button, Dialog, DialogActions, DialogContent, DialogTitle, FormControlLabel, Switch, TextField, Box } from '@mui/material';
3
+ import { Alert, Button, Dialog, DialogActions, DialogContent, DialogTitle, FormControlLabel, Switch, TextField, Box, Tooltip } from '@mui/material';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  export const FREE_ACCESS_SWITCH_ALERT_SX = { width: '100%' };
6
6
  const statusOf = (error) => { var _a; return (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status; };
7
- export function FreeAccessSwitch({ account, api, onChanged, sx }) {
7
+ export function FreeAccessSwitch({ account, api, onChanged, sx, hideLabel = false, name }) {
8
8
  const { t } = useTranslation();
9
9
  const [open, setOpen] = useState(false);
10
10
  const [reason, setReason] = useState('');
@@ -13,6 +13,7 @@ export function FreeAccessSwitch({ account, api, onChanged, sx }) {
13
13
  const inFlight = useRef(false);
14
14
  const titleId = useId();
15
15
  const active = Boolean(account === null || account === void 0 ? void 0 : account.free_access);
16
+ const displayName = name || (account === null || account === void 0 ? void 0 : account.name) || (account === null || account === void 0 ? void 0 : account.email) || (account === null || account === void 0 ? void 0 : account.user_id) || '';
16
17
  const openDialog = () => { setReason(''); setError(null); setOpen(true); };
17
18
  const close = () => { if (!busy)
18
19
  setOpen(false); };
@@ -36,6 +37,7 @@ export function FreeAccessSwitch({ account, api, onChanged, sx }) {
36
37
  }
37
38
  };
38
39
  const validReason = reason.trim().length > 0 && reason.trim().length <= 1000;
39
- return _jsxs(_Fragment, { children: [_jsx(Box, { sx: sx, children: _jsx(FormControlLabel, { control: _jsx(Switch, { checked: active, disabled: busy, onChange: openDialog, slotProps: { input: { 'aria-label': `${t('Billing.OP_FREE_ACCESS')} – ${(account === null || account === void 0 ? void 0 : account.name) || (account === null || account === void 0 ? void 0 : account.email) || (account === null || account === void 0 ? void 0 : account.user_id)}` } } }), label: t('Billing.OP_FREE_ACCESS') }) }), _jsxs(Dialog, { open: open, onClose: close, "aria-labelledby": titleId, children: [_jsx(DialogTitle, { id: titleId, children: active ? t('Billing.OP_REVOKE_TITLE') : t('Billing.OP_FREE_ACCESS') }), _jsxs(DialogContent, { children: [active ? _jsx("p", { children: t('Billing.OP_REVOKE_BODY') }) : _jsx(TextField, { label: t('Billing.OP_REASON'), multiline: true, required: true, fullWidth: true, disabled: busy, value: reason, onChange: (event) => setReason(event.target.value), inputProps: { maxLength: 1001 } }), error && _jsx(Alert, { severity: "error", sx: FREE_ACCESS_SWITCH_ALERT_SX, children: t(error) })] }), _jsxs(DialogActions, { children: [_jsx(Button, { disabled: busy, onClick: close, children: t('Billing.OP_CANCEL') }), _jsx(Button, { disabled: busy || (!active && !validReason), onClick: submit, children: active ? t('Billing.OP_REVOKE') : t('Billing.OP_GRANT') })] })] })] });
40
+ const control = _jsx(Switch, { checked: active, disabled: busy, onChange: openDialog, slotProps: { input: { 'aria-label': hideLabel ? t('Billing.OP_FREE_ACCESS_FOR', { name: displayName }) : `${t('Billing.OP_FREE_ACCESS')} – ${displayName}` } } });
41
+ return _jsxs(_Fragment, { children: [_jsx(Box, { sx: sx, children: hideLabel ? _jsx(Tooltip, { title: t('Billing.OP_FREE_ACCESS_FOR', { name: displayName }), children: _jsx("span", { children: control }) }) : _jsx(FormControlLabel, { control: control, label: t('Billing.OP_FREE_ACCESS') }) }), _jsxs(Dialog, { open: open, onClose: close, "aria-labelledby": titleId, children: [_jsx(DialogTitle, { id: titleId, children: active ? t('Billing.OP_REVOKE_TITLE') : t('Billing.OP_FREE_ACCESS') }), _jsxs(DialogContent, { children: [active ? _jsx("p", { children: t('Billing.OP_REVOKE_BODY') }) : _jsx(TextField, { label: t('Billing.OP_REASON'), multiline: true, required: true, fullWidth: true, disabled: busy, value: reason, onChange: (event) => setReason(event.target.value), inputProps: { maxLength: 1001 } }), error && _jsx(Alert, { severity: "error", sx: FREE_ACCESS_SWITCH_ALERT_SX, children: t(error) })] }), _jsxs(DialogActions, { children: [_jsx(Button, { disabled: busy, onClick: close, children: t('Billing.OP_CANCEL') }), _jsx(Button, { disabled: busy || (!active && !validReason), onClick: submit, children: active ? t('Billing.OP_REVOKE') : t('Billing.OP_GRANT') })] })] })] });
40
42
  }
41
43
  export default FreeAccessSwitch;
@@ -38,6 +38,14 @@ export function formatDate(iso, language) {
38
38
  return '';
39
39
  return new Intl.DateTimeFormat(intlLocale(language), { year: 'numeric', month: 'long', day: 'numeric', timeZone: 'UTC' }).format(date);
40
40
  }
41
+ export function formatShortDate(iso, language) {
42
+ if (typeof iso !== 'string' || !iso)
43
+ return '';
44
+ const date = new Date(iso);
45
+ if (!Number.isFinite(date.getTime()))
46
+ return '';
47
+ return new Intl.DateTimeFormat(intlLocale(language), { year: 'numeric', month: 'numeric', day: 'numeric', timeZone: 'UTC' }).format(date);
48
+ }
41
49
  export function formatDateTime(iso, language) {
42
50
  if (typeof iso !== 'string' || !iso)
43
51
  return '';
@@ -1,21 +1,60 @@
1
- import React, { useMemo } from 'react';
1
+ import React, { useEffect, useMemo, useRef, useState } from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
3
  import { defaultBillingApi } from './api';
4
4
  import { BillingAccessCell, BillingAccessError, accountAccessText } from './BillingAccessCell';
5
+ import { FreeAccessSwitch } from './FreeAccessSwitch';
5
6
  import { useOperatorAccounts } from './useOperatorAccounts';
6
- export function useBillingUsersColumn({ api = defaultBillingApi, enabled = true } = {}) {
7
+ const defaultIsOperator = ({ user }) => (user === null || user === void 0 ? void 0 : user.is_superuser) === true;
8
+ const userName = (user) => [user === null || user === void 0 ? void 0 : user.first_name, user === null || user === void 0 ? void 0 : user.last_name].filter(Boolean).join(' ') || (user === null || user === void 0 ? void 0 : user.name) || (user === null || user === void 0 ? void 0 : user.email) || (user === null || user === void 0 ? void 0 : user.username) || '';
9
+ export function useBillingUsersColumn({ api = defaultBillingApi, enabled = true, isOperator = defaultIsOperator } = {}) {
7
10
  const { t, i18n } = useTranslation();
8
11
  const billing = useOperatorAccounts(api, { enabled });
12
+ const [planNames, setPlanNames] = useState({});
13
+ // Plan names are loaded once per activation; reading `api` through a ref keeps an inline `api` object from
14
+ // refetching on every render.
15
+ const apiRef = useRef(api);
16
+ apiRef.current = api;
17
+ useEffect(() => {
18
+ var _a;
19
+ let active = true;
20
+ const getMe = (_a = apiRef.current) === null || _a === void 0 ? void 0 : _a.getMe;
21
+ if (!enabled || typeof getMe !== 'function') {
22
+ setPlanNames({});
23
+ return () => { active = false; };
24
+ }
25
+ Promise.resolve().then(() => getMe.call(apiRef.current)).then((me) => {
26
+ if (!active)
27
+ return;
28
+ setPlanNames(Object.fromEntries((Array.isArray(me === null || me === void 0 ? void 0 : me.plans) ? me.plans : []).filter((plan) => (plan === null || plan === void 0 ? void 0 : plan.key) && (plan === null || plan === void 0 ? void 0 : plan.name)).map((plan) => [plan.key, plan.name])));
29
+ }).catch(() => { if (active)
30
+ setPlanNames({}); });
31
+ return () => { active = false; };
32
+ }, [enabled]);
9
33
  const extraColumns = useMemo(() => billing.status === 'error' ? [{
10
34
  key: 'billing-access', label: t('Billing.OP_ACCESS'), minWidth: 260,
11
35
  renderCell: () => React.createElement(BillingAccessError, { onRetry: billing.reload }),
12
36
  getSortValue: () => '', getSearchValue: () => '',
13
- }] : billing.status !== 'ready' ? [] : [{
14
- key: 'billing-access', label: t('Billing.OP_ACCESS'), minWidth: 260,
15
- renderCell: ({ user }) => React.createElement(BillingAccessCell, { account: billing.accounts.get(user === null || user === void 0 ? void 0 : user.id), api, onChanged: (answer) => billing.setFreeAccess(user.id, answer) }),
16
- getSortValue: ({ user }) => accountAccessText(billing.accounts.get(user === null || user === void 0 ? void 0 : user.id), t, i18n.language),
17
- getSearchValue: ({ user }) => accountAccessText(billing.accounts.get(user === null || user === void 0 ? void 0 : user.id), t, i18n.language),
18
- }], [billing.status, billing.accounts, billing.setFreeAccess, billing.reload, api, t, i18n.language]);
37
+ }] : billing.status !== 'ready' ? [] : (() => {
38
+ const statusFor = ({ user, account }) => accountAccessText(account, t, i18n.language, { planNames, isOperator: isOperator({ user, account }) });
39
+ return [{
40
+ key: 'billing-access', label: t('Billing.OP_ACCESS'), minWidth: 180,
41
+ renderCell: ({ user }) => React.createElement(BillingAccessCell, { account: billing.accounts.get(user === null || user === void 0 ? void 0 : user.id), planNames, isOperator: isOperator({ user, account: billing.accounts.get(user === null || user === void 0 ? void 0 : user.id) }) }),
42
+ getSortValue: (context) => { var _a; return statusFor(Object.assign(Object.assign({}, context), { account: billing.accounts.get((_a = context.user) === null || _a === void 0 ? void 0 : _a.id) })); },
43
+ getSearchValue: (context) => { var _a; return statusFor(Object.assign(Object.assign({}, context), { account: billing.accounts.get((_a = context.user) === null || _a === void 0 ? void 0 : _a.id) })); },
44
+ }, {
45
+ key: 'billing-free-access', label: t('Billing.OP_NO_SUBSCRIPTION'), minWidth: 112, align: 'center',
46
+ renderCell: ({ user }) => {
47
+ var _a, _b;
48
+ const account = billing.accounts.get(user === null || user === void 0 ? void 0 : user.id);
49
+ const operator = isOperator({ user, account });
50
+ const source = (_a = account === null || account === void 0 ? void 0 : account.access) === null || _a === void 0 ? void 0 : _a.source;
51
+ if (!account || operator || source === 'subscription' || source === 'team' || (source !== 'free' && ((_b = account.access) === null || _b === void 0 ? void 0 : _b.status) !== 'read_only'))
52
+ return '–';
53
+ return React.createElement(FreeAccessSwitch, { account, api, name: userName(user), hideLabel: true, onChanged: (answer) => billing.setFreeAccess(user.id, answer) });
54
+ },
55
+ getSortValue: () => '', getSearchValue: () => '',
56
+ }];
57
+ })(), [billing.status, billing.accounts, billing.setFreeAccess, billing.reload, api, t, i18n.language, planNames, isOperator]);
19
58
  return { status: billing.status, extraColumns, reload: billing.reload };
20
59
  }
21
60
  export default useBillingUsersColumn;
@@ -1,24 +1,57 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React from 'react';
3
- import { Button, Stack, TextField } from '@mui/material';
3
+ import { Box, Button, IconButton, Stack, TextField } from '@mui/material';
4
+ import SendIcon from '@mui/icons-material/Send';
5
+ import StopIcon from '@mui/icons-material/Stop';
6
+ import CloseIcon from '@mui/icons-material/Close';
4
7
  import { useTranslation } from 'react-i18next';
5
8
  /**
6
9
  * Message input. Send is disabled while a turn runs, for an archived chat and while the connection is down;
7
10
  * Stop replaces it during a turn. Enter sends, Shift+Enter inserts a line break.
11
+ *
12
+ * `layout="compact"` (UCM-CHAT-7) stacks an optional one-line `notice` (`{ text, action, onAction, onDismiss }`),
13
+ * a context row (`context`, then `actions` at its end; never wraps, the context is clipped first) and a full-width
14
+ * input row with an icon Send that becomes Stop while running. The default `standard` layout is unchanged.
8
15
  */
9
16
  export const CHAT_COMPOSER_INPUT_SX = { flex: '1 1 12rem', minWidth: 0 };
10
- export function ChatComposer({ value = '', onChange, onSend, onStop, running = false, archived = false, connected = true, inputRef, sx, actions }) {
17
+ export const CHAT_COMPOSER_COMPACT_ROOT_SX = { display: 'flex', flexDirection: 'column', gap: 0.75, p: { xs: 1, md: 1.5 }, borderTop: 1, borderColor: 'divider', minWidth: 0 };
18
+ export const CHAT_COMPOSER_CONTEXT_ROW_SX = { display: 'flex', alignItems: 'center', gap: 0.75, minHeight: 30, minWidth: 0, flexWrap: 'nowrap' };
19
+ export const CHAT_COMPOSER_CONTEXT_SX = { minWidth: 0, flex: '1 1 auto', overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' };
20
+ export const CHAT_COMPOSER_CONTEXT_ACTIONS_SX = { flex: '0 0 auto', minWidth: 0, whiteSpace: 'nowrap' };
21
+ export const CHAT_COMPOSER_INPUT_ROW_SX = { display: 'flex', alignItems: 'flex-end', gap: 0.5, minWidth: 0, p: '3px 3px 3px 10px', border: 1, borderColor: 'divider', borderRadius: 1, '&:focus-within': { borderColor: 'primary.main', boxShadow: (theme) => `0 0 0 2px ${theme.palette.primary.main}33` } };
22
+ export const CHAT_COMPOSER_COMPACT_FIELD_SX = { flex: '1 1 auto', minWidth: 0, '& .MuiOutlinedInput-root': { p: 0, alignItems: 'flex-end' }, '& .MuiOutlinedInput-notchedOutline': { border: 0 }, '& .MuiInputBase-inputMultiline': { px: 0, py: 1.5, maxHeight: '7.5em', overflowY: 'auto' } };
23
+ export const CHAT_COMPOSER_ACTION_SX = { width: 36, height: 36, flex: '0 0 36px' };
24
+ // Send is the filled primary action of the input row, as in the prototype; Stop keeps the plain icon button.
25
+ export const CHAT_COMPOSER_SEND_SX = Object.assign(Object.assign({}, CHAT_COMPOSER_ACTION_SX), { bgcolor: 'primary.main', color: 'primary.contrastText', '&:hover': { bgcolor: 'primary.dark' }, '&.Mui-disabled': { bgcolor: 'action.disabledBackground', color: 'action.disabled' } });
26
+ export const CHAT_COMPOSER_NOTICE_SX = { display: 'flex', alignItems: 'center', gap: 0.75, minWidth: 0, minHeight: 32, px: 1, color: 'text.secondary', bgcolor: 'action.hover', borderRadius: 1 };
27
+ export const CHAT_COMPOSER_NOTICE_TEXT_SX = { minWidth: 0, flex: '1 1 auto', overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' };
28
+ export const CHAT_COMPOSER_NOTICE_ACTION_SX = { flex: '0 0 auto', minWidth: 0, p: 0.25, whiteSpace: 'nowrap' };
29
+ export const CHAT_COMPOSER_NOTICE_CLOSE_SX = { width: 28, height: 28, flex: '0 0 28px' };
30
+ function CompactNotice({ notice, t }) {
31
+ if (!notice)
32
+ return null;
33
+ const details = React.isValidElement(notice) ? { content: notice } : notice;
34
+ if (!details || typeof details !== 'object')
35
+ return notice;
36
+ return (_jsxs(Box, { role: "status", sx: CHAT_COMPOSER_NOTICE_SX, children: [_jsx(Box, { component: "span", sx: CHAT_COMPOSER_NOTICE_TEXT_SX, children: details.text || details.content }), details.action ? _jsx(Button, { size: "small", color: "inherit", sx: CHAT_COMPOSER_NOTICE_ACTION_SX, onClick: details.onAction, children: details.action }) : null, _jsx(IconButton, { "aria-label": t('Chat.dismissNotice'), size: "small", sx: CHAT_COMPOSER_NOTICE_CLOSE_SX, onClick: details.onDismiss, children: _jsx(CloseIcon, { fontSize: "small" }) })] }));
37
+ }
38
+ export function ChatComposer({ value = '', onChange, onSend, onStop, running = false, archived = false, connected = true, inputRef, sx, actions, layout = 'standard', context, notice }) {
11
39
  const { t } = useTranslation();
12
40
  const blocked = archived || !connected;
13
41
  const canSend = !running && !blocked && value.trim().length > 0;
14
42
  const submit = () => { if (canSend)
15
43
  onSend === null || onSend === void 0 ? void 0 : onSend(); };
16
- return (_jsxs(Stack, { direction: "row", alignItems: "flex-end", flexWrap: "wrap", gap: 1, sx: Object.assign({ p: { xs: 1, md: 2 }, borderTop: 1, borderColor: 'divider' }, sx), children: [_jsx(TextField, { multiline: true, maxRows: 6, sx: CHAT_COMPOSER_INPUT_SX, size: "small", value: value, inputRef: inputRef, disabled: blocked, placeholder: t('Chat.message'), slotProps: { htmlInput: { 'aria-label': t('Chat.message') } }, onChange: (event) => onChange === null || onChange === void 0 ? void 0 : onChange(event.target.value), onKeyDown: (event) => {
17
- var _a;
18
- if (event.key === 'Enter' && !event.shiftKey && !((_a = event.nativeEvent) === null || _a === void 0 ? void 0 : _a.isComposing)) {
19
- event.preventDefault();
20
- submit();
21
- }
22
- } }), actions ? _jsx(Stack, { direction: "row", alignItems: "flex-end", children: actions }) : null, running ? _jsx(Button, { variant: "outlined", onClick: onStop, children: t('Chat.stop') }) : null, _jsx(Button, { variant: "contained", onClick: submit, disabled: !canSend, children: t('Chat.send') })] }));
44
+ const handleKeyDown = (event) => {
45
+ var _a;
46
+ if (event.key === 'Enter' && !event.shiftKey && !((_a = event.nativeEvent) === null || _a === void 0 ? void 0 : _a.isComposing)) {
47
+ event.preventDefault();
48
+ submit();
49
+ }
50
+ };
51
+ if (layout === 'compact')
52
+ return (_jsxs(Stack, { sx: sx ? [CHAT_COMPOSER_COMPACT_ROOT_SX, sx] : CHAT_COMPOSER_COMPACT_ROOT_SX, children: [_jsx(CompactNotice, { notice: notice, t: t }), _jsxs(Stack, { direction: "row", alignItems: "center", sx: CHAT_COMPOSER_CONTEXT_ROW_SX, children: [_jsx(Box, { sx: CHAT_COMPOSER_CONTEXT_SX, children: context }), actions ? _jsx(Box, { sx: CHAT_COMPOSER_CONTEXT_ACTIONS_SX, children: actions }) : null] }), _jsxs(Stack, { direction: "row", alignItems: "flex-end", sx: CHAT_COMPOSER_INPUT_ROW_SX, children: [_jsx(TextField, { multiline: true, maxRows: 5, variant: "outlined", sx: CHAT_COMPOSER_COMPACT_FIELD_SX, size: "small", value: value, inputRef: inputRef, disabled: blocked, placeholder: t('Chat.message'), slotProps: { htmlInput: { 'aria-label': t('Chat.message') } }, onChange: (event) => onChange === null || onChange === void 0 ? void 0 : onChange(event.target.value), onKeyDown: handleKeyDown }), running
53
+ ? _jsx(IconButton, { "aria-label": t('Chat.stopAnswer'), title: t('Chat.stopAnswer'), sx: CHAT_COMPOSER_ACTION_SX, onClick: onStop, children: _jsx(StopIcon, {}) })
54
+ : _jsx(IconButton, { "aria-label": t('Chat.send'), sx: CHAT_COMPOSER_SEND_SX, onClick: submit, disabled: !canSend, children: _jsx(SendIcon, { fontSize: "small" }) })] })] }));
55
+ return (_jsxs(Stack, { direction: "row", alignItems: "flex-end", flexWrap: "wrap", gap: 1, sx: Object.assign({ p: { xs: 1, md: 2 }, borderTop: 1, borderColor: 'divider' }, sx), children: [_jsx(TextField, { multiline: true, maxRows: 6, sx: CHAT_COMPOSER_INPUT_SX, size: "small", value: value, inputRef: inputRef, disabled: blocked, placeholder: t('Chat.message'), slotProps: { htmlInput: { 'aria-label': t('Chat.message') } }, onChange: (event) => onChange === null || onChange === void 0 ? void 0 : onChange(event.target.value), onKeyDown: handleKeyDown }), actions ? _jsx(Stack, { direction: "row", alignItems: "flex-end", children: actions }) : null, running ? _jsx(Button, { variant: "outlined", onClick: onStop, children: t('Chat.stop') }) : null, _jsx(Button, { variant: "contained", onClick: submit, disabled: !canSend, children: t('Chat.send') })] }));
23
56
  }
24
57
  export default ChatComposer;
@@ -62,7 +62,7 @@ const appendDelta = (turns, text) => {
62
62
  * Props: `apiBase` and `wsUrl` (where the app mounted the chat routes), `api` (partial overrides of the REST
63
63
  * calls; every function not given keeps its default), `scope` (passed when creating a chat), `sx`.
64
64
  */
65
- export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, sx, unavailableReasonText, sidePanel, sidePanelLabel, renderAnswerExtra, renderComposerExtra, onAppFrame, activeChatId, onActiveChatChange, composerPrefill, getSendContext, sendRequest, onSendRequestHandled, layout = 'viewport', compactBelow = 720, tokenBalance = null, usageToTokens, longChatTokens = 40000 }) {
65
+ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, sx, unavailableReasonText, sidePanel, sidePanelLabel, renderAnswerExtra, renderComposerExtra, composerLayout = 'standard', renderComposerContext, onAppFrame, activeChatId, onActiveChatChange, composerPrefill, getSendContext, sendRequest, onSendRequestHandled, layout = 'viewport', compactBelow = 720, tokenBalance = null, usageToTokens, longChatTokens = 40000 }) {
66
66
  var _a;
67
67
  const { t } = useTranslation();
68
68
  const theme = useTheme();
@@ -127,6 +127,7 @@ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, sx, un
127
127
  const [listOpen, setListOpen] = useState(false);
128
128
  const [pickerOpen, setPickerOpen] = useState(false);
129
129
  const [openedOnce, setOpenedOnce] = useState(false); // distinguishes a reconnect from the first connect
130
+ const [dismissedComposerNotices, setDismissedComposerNotices] = useState(() => new Set());
130
131
  const running = turns.some(isGenerating);
131
132
  const isArchived = Boolean(chat === null || chat === void 0 ? void 0 : chat.archived_at);
132
133
  const selection = (chat === null || chat === void 0 ? void 0 : chat.selection) || catalogue.default;
@@ -526,6 +527,9 @@ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, sx, un
526
527
  if (unavailable) {
527
528
  return (_jsx(Stack, { alignItems: "center", justifyContent: "center", spacing: 1, sx: Object.assign({ minHeight: 320, p: 3, textAlign: 'center' }, sx), children: _jsx(Typography, { color: "text.secondary", children: unavailableText || t('Chat.notAvailableHere') }) }));
528
529
  }
529
- return (_jsxs(Box, { ref: rootRef, sx: Object.assign({ display: 'grid', gridTemplateColumns: narrow ? 'minmax(0, 1fr)' : `minmax(240px, 320px) minmax(0, 1fr)${chat && sidePanel ? ' minmax(240px, 320px)' : ''}`, height: '100%', minHeight: 480, border: 1, borderColor: 'divider', borderRadius: 1, overflow: 'hidden', bgcolor: 'background.paper' }, sx), children: [narrow ? null : _jsx(Box, { sx: { borderRight: 1, borderColor: 'divider', minHeight: 0 }, children: list }), _jsxs(Stack, { sx: { minWidth: 0, minHeight: 0 }, children: [_jsxs(Stack, { direction: "row", alignItems: "center", gap: 1, sx: { px: 1.5, py: 0.5, borderBottom: 1, borderColor: 'divider', minHeight: 56 }, children: [narrow ? _jsx(Button, { color: "inherit", onClick: () => setListOpen(true), children: t('Chat.chats') }) : null, _jsx(Typography, { noWrap: true, sx: { flex: 1, fontWeight: 600 }, children: chat ? (chat.title || t('Chat.untitled')) : '' }), socket.status === 'connecting' && openedOnce ? _jsx(Chip, { size: "small", color: "warning", variant: "outlined", label: t('Chat.reconnecting') }) : null, isArchived ? _jsx(Chip, { size: "small", label: t('Chat.archived') }) : null, isArchived ? _jsx(Button, { size: "small", onClick: () => updateChat(chat, { archived: false }), children: t('Chat.restore') }) : null, chat && sidePanel && narrow ? _jsx(Button, { color: "inherit", onClick: () => setSidePanelOpen(true), children: sidePanelLabel || t('Chat.sidePanel') }) : null] }), chat ? (_jsxs(_Fragment, { children: [_jsx(ChatThread, { turns: turns, chat: chat, renderAnswerExtra: answerExtra, trimmedCount: trimmedCount, tool: tool, notice: noticeFor(), hasOlder: Boolean(olderCursor), olderBusy: olderBusy, onLoadOlder: loadOlder, onRetry: retry, readOnly: isArchived, summary: summary, usageToTokens: usageToTokens }), isArchived ? _jsx(Typography, { variant: "caption", color: "text.secondary", sx: { px: 2, pb: 1 }, children: t('Chat.archivedReadOnly') }) : null, renderComposerExtra ? _jsx(Box, { children: renderComposerExtra({ chat }) }, chat.id) : null, longChat ? _jsx(Alert, { severity: "info", action: _jsx(Button, { color: "inherit", size: "small", onClick: createChat, children: t('Chat.newConversation') }), children: t('Chat.longChat') }) : null, _jsx(ChatComposer, { value: draft, onChange: setDraft, onSend: send, onStop: () => socket.send({ type: 'stop' }), running: running, archived: isArchived, connected: socket.connected, inputRef: composerInputRef, actions: _jsx(ModelPicker, { entries: catalogue.entries, selection: selection, disabled: isArchived || running || (catalogueLoading && catalogueChatId !== chat.id), open: pickerOpen, onOpenChange: setPickerOpen, onChange: (next) => updateChat(chat, { selection: next }), sheet: narrow, balance: tokenBalance, longChat: longChat, onNewChat: createChat }) })] })) : (_jsxs(Stack, { alignItems: "center", justifyContent: "center", spacing: 2, sx: { flex: 1, p: 3 }, children: [_jsx(Typography, { color: "text.secondary", align: "center", children: t('Chat.selectChat') }), _jsx(Button, { variant: "contained", onClick: createChat, children: t('Chat.newChat') })] }))] }), chat && sidePanel && !narrow ? _jsx(Box, { sx: { borderLeft: 1, borderColor: 'divider', minHeight: 0, overflow: 'auto' }, children: sidePanel(chat) }, chat.id) : null, narrow && chat && sidePanel ? _jsx(Drawer, { anchor: "right", open: sidePanelOpen, onClose: () => setSidePanelOpen(false), slotProps: { paper: { 'aria-label': sidePanelLabel || t('Chat.sidePanel') } }, children: _jsx(Box, { children: sidePanel(chat) }, chat.id) }) : null, narrow ? _jsx(Drawer, { open: listOpen, onClose: () => setListOpen(false), slotProps: { paper: { sx: { width: 'min(320px, 86vw)' } } }, children: list }) : null] }));
530
+ return (_jsxs(Box, { ref: rootRef, sx: Object.assign({ display: 'grid', gridTemplateColumns: narrow ? 'minmax(0, 1fr)' : `minmax(240px, 320px) minmax(0, 1fr)${chat && sidePanel ? ' minmax(240px, 320px)' : ''}`, height: '100%', minHeight: 480, border: 1, borderColor: 'divider', borderRadius: 1, overflow: 'hidden', bgcolor: 'background.paper' }, sx), children: [narrow ? null : _jsx(Box, { sx: { borderRight: 1, borderColor: 'divider', minHeight: 0 }, children: list }), _jsxs(Stack, { sx: { minWidth: 0, minHeight: 0 }, children: [_jsxs(Stack, { direction: "row", alignItems: "center", gap: 1, sx: { px: 1.5, py: 0.5, borderBottom: 1, borderColor: 'divider', minHeight: 56 }, children: [narrow ? _jsx(Button, { color: "inherit", onClick: () => setListOpen(true), children: t('Chat.chats') }) : null, _jsx(Typography, { noWrap: true, sx: { flex: 1, fontWeight: 600 }, children: chat ? (chat.title || t('Chat.untitled')) : '' }), socket.status === 'connecting' && openedOnce ? _jsx(Chip, { size: "small", color: "warning", variant: "outlined", label: t('Chat.reconnecting') }) : null, isArchived ? _jsx(Chip, { size: "small", label: t('Chat.archived') }) : null, isArchived ? _jsx(Button, { size: "small", onClick: () => updateChat(chat, { archived: false }), children: t('Chat.restore') }) : null, chat && sidePanel && narrow ? _jsx(Button, { color: "inherit", onClick: () => setSidePanelOpen(true), children: sidePanelLabel || t('Chat.sidePanel') }) : null] }), chat ? (_jsxs(_Fragment, { children: [_jsx(ChatThread, { turns: turns, chat: chat, renderAnswerExtra: answerExtra, trimmedCount: trimmedCount, tool: tool, notice: noticeFor(), hasOlder: Boolean(olderCursor), olderBusy: olderBusy, onLoadOlder: loadOlder, onRetry: retry, readOnly: isArchived, summary: summary, usageToTokens: usageToTokens }), isArchived ? _jsx(Typography, { variant: "caption", color: "text.secondary", sx: { px: 2, pb: 1 }, children: t('Chat.archivedReadOnly') }) : null, renderComposerExtra ? _jsx(Box, { children: renderComposerExtra({ chat }) }, chat.id) : null, composerLayout !== 'compact' && longChat ? _jsx(Alert, { severity: "info", action: _jsx(Button, { color: "inherit", size: "small", onClick: createChat, children: t('Chat.newConversation') }), children: t('Chat.longChat') }) : null, _jsx(ChatComposer, { layout: composerLayout, context: composerLayout === 'compact' ? renderComposerContext === null || renderComposerContext === void 0 ? void 0 : renderComposerContext({ chat }) : undefined, notice: composerLayout === 'compact' && longChat && !dismissedComposerNotices.has(`${chat.id}:long-chat`) ? {
531
+ id: 'long-chat', text: t('Chat.longChatShort'), action: t('Chat.newChat'), onAction: createChat,
532
+ onDismiss: () => setDismissedComposerNotices((current) => new Set(current).add(`${chat.id}:long-chat`)),
533
+ } : null, value: draft, onChange: setDraft, onSend: send, onStop: () => socket.send({ type: 'stop' }), running: running, archived: isArchived, connected: socket.connected, inputRef: composerInputRef, actions: _jsx(ModelPicker, { entries: catalogue.entries, selection: selection, disabled: isArchived || running || (catalogueLoading && catalogueChatId !== chat.id), open: pickerOpen, onOpenChange: setPickerOpen, onChange: (next) => updateChat(chat, { selection: next }), sheet: narrow, balance: tokenBalance, longChat: longChat, onNewChat: createChat, shortLabel: composerLayout === 'compact' }) })] })) : (_jsxs(Stack, { alignItems: "center", justifyContent: "center", spacing: 2, sx: { flex: 1, p: 3 }, children: [_jsx(Typography, { color: "text.secondary", align: "center", children: t('Chat.selectChat') }), _jsx(Button, { variant: "contained", onClick: createChat, children: t('Chat.newChat') })] }))] }), chat && sidePanel && !narrow ? _jsx(Box, { sx: { borderLeft: 1, borderColor: 'divider', minHeight: 0, overflow: 'auto' }, children: sidePanel(chat) }, chat.id) : null, narrow && chat && sidePanel ? _jsx(Drawer, { anchor: "right", open: sidePanelOpen, onClose: () => setSidePanelOpen(false), slotProps: { paper: { 'aria-label': sidePanelLabel || t('Chat.sidePanel') } }, children: _jsx(Box, { children: sidePanel(chat) }, chat.id) }) : null, narrow ? _jsx(Drawer, { open: listOpen, onClose: () => setListOpen(false), slotProps: { paper: { sx: { width: 'min(320px, 86vw)' } } }, children: list }) : null] }));
530
534
  }
531
535
  export default ChatWorkspace;
@@ -6,6 +6,8 @@ import { useTranslation } from 'react-i18next';
6
6
  const LEVELS = ['top', 'best', 'balanced', 'fast'];
7
7
  const EFFORTS = ['low', 'medium', 'high', 'max'];
8
8
  export const CHAT_MODEL_TRIGGER_SX = { minWidth: 0, px: 1.25, color: 'text.secondary', whiteSpace: 'nowrap', flexShrink: 0, maxWidth: { xs: 140, sm: 'none' } };
9
+ // The short label sits at the end of the compact composer's context row, which clips the host content first.
10
+ export const CHAT_MODEL_TRIGGER_SHORT_SX = Object.assign(Object.assign({}, CHAT_MODEL_TRIGGER_SX), { maxWidth: 'none' });
9
11
  export const CHAT_MODEL_ENTRY_SX = { borderRadius: 1, alignItems: 'flex-start' };
10
12
  export const CHAT_MODEL_EFFORT_SX = { flex: 1, minWidth: 0 };
11
13
  export const CHAT_MODEL_CLOSE_SX = { ml: 'auto' };
@@ -19,7 +21,10 @@ const fallback = (entries) => {
19
21
  const entry = entries.find((item) => item.default) || entries[0];
20
22
  return entry ? { entry: entry.id, effort: (_a = entry.efforts) === null || _a === void 0 ? void 0 : _a[0] } : null;
21
23
  };
22
- const cleanLabel = (entry) => ((entry === null || entry === void 0 ? void 0 : entry.label) || (entry === null || entry === void 0 ? void 0 : entry.model) || '').replace(/\s+\d+(?:\.\d+)*$/, '');
24
+ const cleanLabel = (entry, shortLabel = false) => {
25
+ const withoutVersion = ((entry === null || entry === void 0 ? void 0 : entry.label) || (entry === null || entry === void 0 ? void 0 : entry.model) || '').replace(/\s+\d+(?:\.\d+)*$/, '');
26
+ return shortLabel ? withoutVersion.replace(/^(?:(?:Claude|Anthropic|OpenAI)\s+)+/i, '') : withoutVersion;
27
+ };
23
28
  function estimateText(entry, effort, t, language) {
24
29
  var _a;
25
30
  if (entry.billing === 'subscription')
@@ -37,7 +42,7 @@ function estimateText(entry, effort, t, language) {
37
42
  }
38
43
  return null;
39
44
  }
40
- export function ModelPicker({ entries = [], selection, onChange, disabled = false, open, onOpenChange, sheet, balance = null, longChat = false, onNewChat }) {
45
+ export function ModelPicker({ entries = [], selection, onChange, disabled = false, open, onOpenChange, sheet, balance = null, longChat = false, onNewChat, shortLabel = false }) {
41
46
  const { t, i18n } = useTranslation();
42
47
  const language = typeof (i18n === null || i18n === void 0 ? void 0 : i18n.language) === 'string' ? i18n.language.split('_')[0] || undefined : undefined;
43
48
  const theme = useTheme();
@@ -80,7 +85,7 @@ export function ModelPicker({ entries = [], selection, onChange, disabled = fals
80
85
  };
81
86
  const content = (_jsx(Box, { role: "dialog", "aria-labelledby": "chat-model-picker-title", sx: { p: 2, width: narrow ? 'auto' : 360, maxWidth: '100%', maxHeight: narrow ? '82vh' : 'min(640px, 80vh)', overflowY: 'auto' }, children: _jsxs(Stack, { spacing: 1.25, children: [_jsxs(Stack, { direction: "row", alignItems: "center", gap: 1, children: [_jsx(Typography, { id: "chat-model-picker-title", variant: "subtitle1", sx: { fontWeight: 600 }, children: t('Chat.pickerTitle') }), _jsx(IconButton, { "aria-label": t('Chat.close'), size: "small", sx: CHAT_MODEL_CLOSE_SX, onClick: () => setOpen(false), children: _jsx(CloseIcon, { fontSize: "small" }) })] }), _jsxs(Box, { role: "radiogroup", "aria-labelledby": "chat-model-picker-title", onKeyDown: moveSelection, children: [grouped.map(([level, items]) => _jsxs(Box, { children: [_jsx(Typography, { variant: "subtitle2", children: t(`Chat.level.${level}`) }), _jsx(Typography, { variant: "caption", color: "text.secondary", children: t(`Chat.levelHint.${level}`) }), _jsx(List, { dense: true, disablePadding: true, children: items.map(entryRow) })] }, level)), unknown.length ? _jsx(List, { dense: true, disablePadding: true, children: unknown.map(entryRow) }) : null] }), active ? _jsxs(Box, { children: [_jsx(Typography, { variant: "subtitle2", sx: { mb: 0.75 }, children: t('Chat.effortQuestion') }), _jsx(ToggleButtonGroup, { exclusive: true, fullWidth: true, size: "small", value: effort || null, "aria-label": t('Chat.effortQuestion'), onChange: (_event, next) => { if (next)
82
87
  onChange === null || onChange === void 0 ? void 0 : onChange({ entry: active.id, effort: next }); }, children: EFFORTS.filter((item) => { var _a; return (_a = active.efforts) === null || _a === void 0 ? void 0 : _a.includes(item); }).map((item) => _jsx(ToggleButton, { value: item, sx: CHAT_MODEL_EFFORT_SX, children: t(`Chat.effort.${item}`) }, item)) }), _jsx(Typography, { variant: "caption", color: "text.secondary", children: t(hasTokenEstimates ? 'Chat.effortHintTokens' : 'Chat.effortHint') })] }) : null, longChat ? _jsx(Alert, { severity: "warning", action: onNewChat ? _jsx(Button, { color: "inherit", size: "small", onClick: onNewChat, children: t('Chat.newConversation') }) : null, children: t('Chat.longChat') }) : null, Number.isInteger(balance) && balance >= 0 ? _jsx(Typography, { variant: "caption", color: "text.secondary", children: t('Chat.balanceLabel', { n: new Intl.NumberFormat(language).format(balance) }) }) : null] }) }));
83
- const trigger = _jsx(Button, { ref: anchor, size: "small", color: "inherit", sx: CHAT_MODEL_TRIGGER_SX, disabled: disabled || !entries.length, onClick: () => setOpen(true), "aria-haspopup": "dialog", children: _jsx(Box, { component: "span", sx: { overflow: 'hidden', textOverflow: 'ellipsis' }, children: active ? `${cleanLabel(active)} · ${t(`Chat.effort.${effort}`)} ▾` : t('Chat.chooseModel') }) });
88
+ const trigger = _jsx(Button, { ref: anchor, size: "small", color: "inherit", sx: shortLabel ? CHAT_MODEL_TRIGGER_SHORT_SX : CHAT_MODEL_TRIGGER_SX, disabled: disabled || !entries.length, onClick: () => setOpen(true), "aria-haspopup": "dialog", children: _jsx(Box, { component: "span", sx: { overflow: 'hidden', textOverflow: 'ellipsis' }, children: active ? `${cleanLabel(active, shortLabel)} · ${t(`Chat.effort.${effort}`)} ▾` : t('Chat.chooseModel') }) });
84
89
  return _jsxs(_Fragment, { children: [trigger, narrow ? _jsx(Drawer, { anchor: "bottom", open: isOpen, onClose: () => setOpen(false), children: content }) : _jsx(Popover, { open: isOpen, anchorEl: anchor.current, onClose: () => setOpen(false), anchorOrigin: { vertical: 'top', horizontal: 'left' }, transformOrigin: { vertical: 'bottom', horizontal: 'left' }, children: content })] });
85
90
  }
86
91
  export default ModelPicker;
@@ -1,11 +1,24 @@
1
1
  import { createKitSxEntry } from '../theme/kitSxEntry';
2
- import { CHAT_COMPOSER_INPUT_SX } from './ChatComposer';
2
+ import { CHAT_COMPOSER_INPUT_SX, CHAT_COMPOSER_COMPACT_ROOT_SX, CHAT_COMPOSER_CONTEXT_ROW_SX, CHAT_COMPOSER_CONTEXT_SX, CHAT_COMPOSER_CONTEXT_ACTIONS_SX, CHAT_COMPOSER_INPUT_ROW_SX, CHAT_COMPOSER_COMPACT_FIELD_SX, CHAT_COMPOSER_ACTION_SX, CHAT_COMPOSER_SEND_SX, CHAT_COMPOSER_NOTICE_SX, CHAT_COMPOSER_NOTICE_TEXT_SX, CHAT_COMPOSER_NOTICE_ACTION_SX, CHAT_COMPOSER_NOTICE_CLOSE_SX, } from './ChatComposer';
3
3
  import { CHAT_LIST_ARCHIVED_ACTION_SX, CHAT_LIST_ROW_ACTION_SX } from './ChatList';
4
4
  import { CHAT_THREAD_NOTICE_SX, CHAT_THREAD_TOOL_CHIP_SX, CHAT_THREAD_TRIMMED_SX } from './ChatThread';
5
- import { CHAT_MODEL_TRIGGER_SX, CHAT_MODEL_ENTRY_SX, CHAT_MODEL_EFFORT_SX, CHAT_MODEL_CLOSE_SX } from './ModelPicker';
5
+ import { CHAT_MODEL_TRIGGER_SX, CHAT_MODEL_TRIGGER_SHORT_SX, CHAT_MODEL_ENTRY_SX, CHAT_MODEL_EFFORT_SX, CHAT_MODEL_CLOSE_SX } from './ModelPicker';
6
6
  export const CHAT_KIT_SX_REGISTRY = [
7
7
  createKitSxEntry('ChatComposer.input', 'MuiTextField', CHAT_COMPOSER_INPUT_SX, 'CHAT_COMPOSER_INPUT_SX'),
8
+ createKitSxEntry('ChatComposer.compactRoot', 'MuiStack', CHAT_COMPOSER_COMPACT_ROOT_SX, 'CHAT_COMPOSER_COMPACT_ROOT_SX'),
9
+ createKitSxEntry('ChatComposer.contextRow', 'MuiStack', CHAT_COMPOSER_CONTEXT_ROW_SX, 'CHAT_COMPOSER_CONTEXT_ROW_SX'),
10
+ createKitSxEntry('ChatComposer.context', 'MuiBox', CHAT_COMPOSER_CONTEXT_SX, 'CHAT_COMPOSER_CONTEXT_SX'),
11
+ createKitSxEntry('ChatComposer.contextActions', 'MuiBox', CHAT_COMPOSER_CONTEXT_ACTIONS_SX, 'CHAT_COMPOSER_CONTEXT_ACTIONS_SX'),
12
+ createKitSxEntry('ChatComposer.inputRow', 'MuiStack', CHAT_COMPOSER_INPUT_ROW_SX, 'CHAT_COMPOSER_INPUT_ROW_SX'),
13
+ createKitSxEntry('ChatComposer.compactField', 'MuiTextField', CHAT_COMPOSER_COMPACT_FIELD_SX, 'CHAT_COMPOSER_COMPACT_FIELD_SX'),
14
+ createKitSxEntry('ChatComposer.action', 'MuiIconButton', CHAT_COMPOSER_ACTION_SX, 'CHAT_COMPOSER_ACTION_SX'),
15
+ createKitSxEntry('ChatComposer.send', 'MuiIconButton', CHAT_COMPOSER_SEND_SX, 'CHAT_COMPOSER_SEND_SX'),
16
+ createKitSxEntry('ChatComposer.notice', 'MuiBox', CHAT_COMPOSER_NOTICE_SX, 'CHAT_COMPOSER_NOTICE_SX'),
17
+ createKitSxEntry('ChatComposer.noticeText', 'MuiBox', CHAT_COMPOSER_NOTICE_TEXT_SX, 'CHAT_COMPOSER_NOTICE_TEXT_SX'),
18
+ createKitSxEntry('ChatComposer.noticeAction', 'MuiButton', CHAT_COMPOSER_NOTICE_ACTION_SX, 'CHAT_COMPOSER_NOTICE_ACTION_SX'),
19
+ createKitSxEntry('ChatComposer.noticeClose', 'MuiIconButton', CHAT_COMPOSER_NOTICE_CLOSE_SX, 'CHAT_COMPOSER_NOTICE_CLOSE_SX'),
8
20
  createKitSxEntry('ModelPicker.trigger', 'MuiButton', CHAT_MODEL_TRIGGER_SX, 'CHAT_MODEL_TRIGGER_SX'),
21
+ createKitSxEntry('ModelPicker.triggerShort', 'MuiButton', CHAT_MODEL_TRIGGER_SHORT_SX, 'CHAT_MODEL_TRIGGER_SHORT_SX'),
9
22
  createKitSxEntry('ModelPicker.entry', 'MuiListItemButton', CHAT_MODEL_ENTRY_SX, 'CHAT_MODEL_ENTRY_SX'),
10
23
  createKitSxEntry('ModelPicker.effort', 'MuiToggleButton', CHAT_MODEL_EFFORT_SX, 'CHAT_MODEL_EFFORT_SX'),
11
24
  createKitSxEntry('ModelPicker.close', 'MuiIconButton', CHAT_MODEL_CLOSE_SX, 'CHAT_MODEL_CLOSE_SX'),
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React, { useMemo, useState, useEffect, useCallback } from 'react';
3
- import { Box, Typography, FormControl, Select, MenuItem, Button, Tooltip, CircularProgress, Alert, TextField, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, TableSortLabel, TablePagination, } from '@mui/material';
3
+ import { Box, Typography, FormControl, Select, MenuItem, Button, IconButton, Tooltip, CircularProgress, Alert, TextField, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, TableSortLabel, TablePagination, } from '@mui/material';
4
4
  import CheckCircleIcon from '@mui/icons-material/CheckCircle';
5
5
  import CancelIcon from '@mui/icons-material/Cancel';
6
6
  import DeleteIcon from '@mui/icons-material/Delete';
@@ -148,6 +148,7 @@ export function UserListComponent({ roles = DEFAULT_ROLES, currentUser, extraCol
148
148
  }
149
149
  return (user === null || user === void 0 ? void 0 : user.username) || '';
150
150
  };
151
+ const getUserDeleteName = (user) => getUserDisplayName(user) || (user === null || user === void 0 ? void 0 : user.email) || (user === null || user === void 0 ? void 0 : user.username) || '';
151
152
  const renderBooleanStatusIcon = (value, positiveLabel, negativeLabel) => (_jsx(Tooltip, { title: value ? positiveLabel : negativeLabel, children: _jsx("span", { children: value ? (_jsx(CheckCircleIcon, { color: "success", fontSize: "small" })) : (_jsx(CancelIcon, { color: "error", fontSize: "small" })) }) }));
152
153
  const getExtraColumnSortValue = (column, user) => {
153
154
  var _a;
@@ -340,7 +341,7 @@ export function UserListComponent({ roles = DEFAULT_ROLES, currentUser, extraCol
340
341
  return (_jsx(Button, { size: "small", variant: "outlined", onClick: () => runRowAction(action, row), disabled: isBusy || isDisabled, sx: USER_LIST_ACTION_SX, children: typeof action.label === 'function'
341
342
  ? action.label({ user: row, t, currentUser, canEdit: canEdit(row) })
342
343
  : action.label }, `${action.key}-${row.id}`));
343
- }), showDeleteAction && !isOwnRow(row) && (_jsx(Tooltip, { title: t('Common.DELETE', 'Delete'), children: _jsx("span", { children: _jsx(Button, { size: "small", variant: "outlined", color: "error", startIcon: _jsx(DeleteIcon, {}), onClick: () => handleDelete(row.id), disabled: !canDelete(row), sx: USER_LIST_ACTION_SX, children: t('Common.DELETE', 'Delete') }) }) }))] })),
344
+ }), showDeleteAction && (_jsx(Tooltip, { title: t('Common.DELETE_FOR', { name: getUserDeleteName(row) }), children: _jsx("span", { children: _jsx(IconButton, { color: "error", "aria-label": t('Common.DELETE_FOR', { name: getUserDeleteName(row) }), onClick: () => handleDelete(row.id), disabled: isOwnRow(row) || !canDelete(row), size: "small", children: _jsx(DeleteIcon, { fontSize: "small" }) }) }) }))] })),
344
345
  };
345
346
  return [...baseColumns, ...mappedExtraColumns, actionColumn];
346
347
  }, [
@@ -1723,6 +1723,12 @@ export const authTranslations = {
1723
1723
  "en": "Delete",
1724
1724
  "sw": "Futa"
1725
1725
  },
1726
+ "Common.DELETE_FOR": {
1727
+ "de": "Löschen – {{name}}",
1728
+ "fr": "Supprimer – {{name}}",
1729
+ "en": "Delete – {{name}}",
1730
+ "sw": "Futa – {{name}}"
1731
+ },
1726
1732
  "Common.CANCEL": {
1727
1733
  "de": "Abbrechen",
1728
1734
  "fr": "Annuler",
@@ -78,6 +78,12 @@ export const billingTranslations = {
78
78
  'Billing.OP_OVERVIEW_TITLE': { de: 'Übersicht Abos', de_informal: 'Übersicht Abos', en: 'Subscription overview', fr: 'Aperçu des abonnements', sw: 'Muhtasari wa usajili' },
79
79
  'Billing.OP_ACTIVE_ACCOUNTS': { de: 'Aktive Konten', de_informal: 'Aktive Konten', en: 'Active accounts', fr: 'Comptes actifs', sw: 'Akaunti zinazotumika' },
80
80
  'Billing.OP_PLAN': { de: 'Abo {{plan}}', de_informal: 'Abo {{plan}}', en: 'Subscription {{plan}}', fr: 'Abonnement {{plan}}', sw: 'Usajili {{plan}}' },
81
+ 'Billing.OP_SUBSCRIPTION': { de: 'Abo', de_informal: 'Abo', en: 'Subscription', fr: 'Abonnement', sw: 'Usajili' },
82
+ 'Billing.OP_FREE_ACCESS_SHORT': { de: 'Freigeschaltet', de_informal: 'Freigeschaltet', en: 'Free access', fr: 'Accès gratuit', sw: 'Ufikiaji wa bure' },
83
+ 'Billing.OP_FREE_ACCESS_FOR': { de: 'Ohne Abo freigeschaltet – {{name}}', de_informal: 'Ohne Abo freigeschaltet – {{name}}', en: 'Free access without a subscription – {{name}}', fr: 'Accès sans abonnement – {{name}}', sw: 'Ufikiaji bila usajili – {{name}}' },
84
+ 'Billing.OP_TEAM': { de: 'Team', de_informal: 'Team', en: 'Team', fr: 'Équipe', sw: 'Timu' },
85
+ 'Billing.OP_OPERATOR': { de: 'Betreiber', de_informal: 'Betreiber', en: 'Operator', fr: 'Opérateur', sw: 'Mwendeshaji' },
86
+ 'Billing.OP_NO_SUBSCRIPTION': { de: 'Ohne Abo', de_informal: 'Ohne Abo', en: 'No subscription', fr: 'Sans abonnement', sw: 'Bila usajili' },
81
87
  'Billing.OP_TEAM_SEAT': { de: 'Team-Platz', de_informal: 'Team-Platz', en: 'Team seat', fr: 'Place d’équipe', sw: 'Nafasi ya timu' },
82
88
  'Billing.OP_FREE_ACCESS': { de: 'Ohne Abo freigeschaltet', de_informal: 'Ohne Abo freigeschaltet', en: 'Access enabled without a subscription', fr: 'Accès activé sans abonnement', sw: 'Ufikiaji umewezeshwa bila usajili' },
83
89
  'Billing.OP_READ_ONLY': { de: 'Schreibgeschützt', de_informal: 'Schreibgeschützt', en: 'Read-only', fr: 'Lecture seule', sw: 'Kusoma pekee' },
@@ -14,6 +14,8 @@ export const chatTranslations = {
14
14
  'Chat.loadOlder': { de: 'Ältere laden', en: 'Load older', fr: 'Charger les plus anciens', sw: 'Pakia za zamani' },
15
15
  'Chat.send': { de: 'Senden', en: 'Send', fr: 'Envoyer', sw: 'Tuma' },
16
16
  'Chat.stop': { de: 'Stoppen', en: 'Stop', fr: 'Arrêter', sw: 'Simamisha' },
17
+ 'Chat.stopAnswer': { de: 'Antwort stoppen', en: 'Stop answer', fr: 'Arrêter la réponse', sw: 'Simamisha jibu' },
18
+ 'Chat.dismissNotice': { de: 'Hinweis schliessen', en: 'Dismiss notice', fr: 'Fermer la notification', sw: 'Funga taarifa' },
17
19
  'Chat.message': { de: 'Nachricht', en: 'Message', fr: 'Message', sw: 'Ujumbe' },
18
20
  'Chat.typing': { de: 'Antwort wird erstellt …', en: 'Thinking…', fr: 'Réflexion…', sw: 'Inafikiria…' },
19
21
  'Chat.retry': { de: 'Erneut versuchen', en: 'Retry', fr: 'Réessayer', sw: 'Jaribu tena' },
@@ -44,6 +46,7 @@ export const chatTranslations = {
44
46
  'Chat.effortHintTokens': { de: 'Gründlicher heisst bessere Antworten, aber längere Wartezeit und mehr Token.', en: 'More thorough means better answers, but longer waits and more tokens.', fr: 'Une réponse plus approfondie est meilleure, mais prend plus de temps et consomme plus de jetons.', sw: 'Jibu lenye kina zaidi huwa bora, lakini husubiriwa muda mrefu na hutumia tokeni zaidi.' },
45
47
  'Chat.effortHint': { de: 'Gründlicher heisst bessere Antworten, aber längere Wartezeit.', en: 'More thorough means better answers, but longer waits.', fr: 'Une réponse plus approfondie est meilleure, mais prend plus de temps.', sw: 'Jibu lenye kina zaidi huwa bora, lakini husubiriwa muda mrefu.' },
46
48
  'Chat.longChat': { de: 'Diese Unterhaltung ist lang. Ältere Teile werden zusammengefasst; eine neue Unterhaltung ist günstiger.', en: 'This conversation is long. Older parts will be summarized; a new conversation costs less.', fr: 'Cette conversation est longue. Les anciens passages seront résumés ; une nouvelle conversation coûte moins cher.', sw: 'Mazungumzo haya ni marefu. Sehemu za awali zitafupishwa; mazungumzo mapya yatagharimu kidogo.' },
49
+ 'Chat.longChatShort': { de: 'Lange Unterhaltung: ältere Teile werden zusammengefasst.', en: 'Long conversation: older parts will be summarized.', fr: 'Discussion longue : les anciens passages seront résumés.', sw: 'Mazungumzo marefu: sehemu za awali zitafupishwa.' },
47
50
  'Chat.newConversation': { de: 'Neue Unterhaltung', en: 'New conversation', fr: 'Nouvelle conversation', sw: 'Mazungumzo mapya' },
48
51
  'Chat.balanceLabel': { de: 'Guthaben {{n}} Token', en: 'Balance: {{n}} tokens', fr: 'Solde : {{n}} jetons', sw: 'Salio: tokeni {{n}}' },
49
52
  'Chat.summaryUntilHere': { de: 'Zusammenfassung bis hier', en: 'Summary so far', fr: 'Résumé jusqu’ici', sw: 'Muhtasari hadi hapa' },
@@ -37,6 +37,7 @@ import { SETUP_WIZARD_CARD_SX } from '../onboarding/SetupWizardShell';
37
37
  import { REAUTH_MODAL_ALERT_SX, REAUTH_MODAL_TEXT_FIELD_SX } from '../auth/ReauthModal';
38
38
  import { createKitSxEntry } from './kitSxEntry';
39
39
  import { ACCESS_ENDED_BANNER_ALERT_SX } from '../billing/AccessEndedBanner';
40
+ import { BILLING_ACCESS_BADGE_SX } from '../billing/BillingAccessCell';
40
41
  import { TOKEN_BALANCE_BADGE_SX } from '../billing/TokenBalanceBadge';
41
42
  import { PLAN_PICKER_ALERT_SX, PLAN_PICKER_CARD_SX, PLAN_PICKER_LABEL_SX, PLAN_PICKER_SELECTED_CARD_SX } from '../billing/PlanPicker';
42
43
  import { SUBSCRIPTION_SECTION_ALERT_SX, SUBSCRIPTION_SECTION_SEAT_ADD_SX, SUBSCRIPTION_SECTION_SEAT_SELECT_SX } from '../billing/SubscriptionSection';
@@ -51,6 +52,7 @@ import { RECEIPT_REVIEW_ACTIONS_SX, RECEIPT_REVIEW_ACTION_BUTTON_SX, RECEIPT_REV
51
52
  const SX_EXPORTS = {
52
53
  ACCESS_CODE_ACTION_SX,
53
54
  ACCESS_ENDED_BANNER_ALERT_SX,
55
+ BILLING_ACCESS_BADGE_SX,
54
56
  FREE_ACCESS_SWITCH_ALERT_SX,
55
57
  OPERATOR_OVERVIEW_ALERT_SX,
56
58
  ACCESS_CODE_ALERT_SX,
@@ -251,6 +253,7 @@ export const KIT_COMPONENT_SX_REGISTRY = [
251
253
  entry('ReauthModal.alert', 'MuiAlert', REAUTH_MODAL_ALERT_SX),
252
254
  entry('ReauthModal.field', 'MuiTextField', REAUTH_MODAL_TEXT_FIELD_SX),
253
255
  entry('AccessEndedBanner.alert', 'MuiAlert', ACCESS_ENDED_BANNER_ALERT_SX),
256
+ entry('BillingAccessCell.badge', 'MuiChip', BILLING_ACCESS_BADGE_SX),
254
257
  entry('TokenBalanceBadge.root', 'MuiChip', TOKEN_BALANCE_BADGE_SX),
255
258
  entry('PlanPicker.card', 'MuiCard', PLAN_PICKER_CARD_SX),
256
259
  entry('PlanPicker.selectedCard', 'MuiCard', PLAN_PICKER_SELECTED_CARD_SX),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micha.bigler/ui-core-micha",
3
- "version": "4.15.0",
3
+ "version": "4.17.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "exports": {