@adecore/agents-react 0.24.1 → 0.24.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat/ui/EditDiff.js +4 -3
- package/dist/chat/ui/UnifiedDiff.js +4 -3
- package/dist/chat/ui/diff/ReviewDiff.js +2 -2
- package/dist/chat/ui/rows/WorkRows.js +3 -3
- package/dist/lazy.js +5 -7
- package/package.json +8 -8
- package/src/chat/ui/EditDiff.tsx +6 -5
- package/src/chat/ui/UnifiedDiff.tsx +6 -5
- package/src/chat/ui/diff/ReviewDiff.tsx +3 -3
- package/src/chat/ui/rows/WorkRows.tsx +3 -3
- package/src/lazy.tsx +5 -7
package/dist/chat/ui/EditDiff.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { LazyBoundary } from '@adecore/ui';
|
|
3
4
|
import { useTranslation } from 'react-i18next';
|
|
4
5
|
import { lazyNamed } from '../../lazy.js';
|
|
5
6
|
import { diffSourceBudget, legacyDiffBudget } from './diff/diff-source-budget.js';
|
|
@@ -17,7 +18,7 @@ export default function EditDiff({ change, allowEditor = true, maxHeight }) {
|
|
|
17
18
|
const legacyMode = !allowEditor || loadEngine === undefined;
|
|
18
19
|
const legacyAllowed = useMemo(() => legacyMode && legacyDiffBudget(change.before, change.after), [legacyMode, change.before, change.after]);
|
|
19
20
|
const omitted = _jsx(DiffOmitted, { path: change.path });
|
|
20
|
-
const fallback = legacyAllowed ? (_jsx(DiffFallbackBoundary, { fallback: omitted, resetKeys: [change.path, change.before, change.after], children: _jsx(
|
|
21
|
+
const fallback = legacyAllowed ? (_jsx(DiffFallbackBoundary, { fallback: omitted, resetKeys: [change.path, change.before, change.after], children: _jsx(LazyBoundary, { fallback: _jsx("div", { className: "px-3 py-2 text-xs text-text-faint", children: t('work.loadingDiff') }), children: _jsx(LegacyEditDiff, { change: change, maxHeight: maxHeight }) }) })) : (omitted);
|
|
21
22
|
if (!sourceAllowed) {
|
|
22
23
|
return omitted;
|
|
23
24
|
}
|
|
@@ -25,5 +26,5 @@ export default function EditDiff({ change, allowEditor = true, maxHeight }) {
|
|
|
25
26
|
return fallback;
|
|
26
27
|
}
|
|
27
28
|
const unavailable = _jsx(DiffUnavailable, { path: change.path });
|
|
28
|
-
return (_jsx(DiffFallbackBoundary, { fallback: unavailable, resetKeys: [change.path, change.before, change.after, loadEngine], children: _jsx(
|
|
29
|
+
return (_jsx(DiffFallbackBoundary, { fallback: unavailable, resetKeys: [change.path, change.before, change.after, loadEngine], children: _jsx(LazyBoundary, { fallback: _jsx("div", { className: "px-3 py-2 text-xs text-text-faint", children: t('work.loadingDiff') }), children: _jsx(EditorEditDiff, { change: change, loadEngine: loadEngine, fallback: unavailable, maxHeight: maxHeight, sourceChecked: true }) }) }));
|
|
29
30
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { LazyBoundary } from '@adecore/ui';
|
|
3
4
|
import { useTranslation } from 'react-i18next';
|
|
4
5
|
import { lazyNamed } from '../../lazy.js';
|
|
5
6
|
import { diffSourceBudget, legacyDiffBudget, patchSourceBudget } from './diff/diff-source-budget.js';
|
|
@@ -23,7 +24,7 @@ export default function UnifiedDiff(props) {
|
|
|
23
24
|
const legacyAllowed = useMemo(() => legacyMode && legacyDiffBudget(oldText, newText, change.diff), [legacyMode, oldText, newText, change.diff]);
|
|
24
25
|
const rawAllowed = useMemo(() => hasHunks || legacyDiffBudget('', '', change.diff), [hasHunks, change.diff]);
|
|
25
26
|
const omitted = _jsx(DiffOmitted, { path: change.path });
|
|
26
|
-
const fallback = legacyAllowed ? (_jsx(DiffFallbackBoundary, { fallback: omitted, resetKeys: [change.path, change.diff, oldText, newText, diffStyle], children: _jsx(
|
|
27
|
+
const fallback = legacyAllowed ? (_jsx(DiffFallbackBoundary, { fallback: omitted, resetKeys: [change.path, change.diff, oldText, newText, diffStyle], children: _jsx(LazyBoundary, { fallback: _jsx("div", { className: "px-3 py-2 text-xs text-text-faint", children: t('work.loadingDiff') }), children: _jsx(LegacyUnifiedDiff, { ...props }) }) })) : (omitted);
|
|
27
28
|
if (!sourceAllowed) {
|
|
28
29
|
return omitted;
|
|
29
30
|
}
|
|
@@ -34,5 +35,5 @@ export default function UnifiedDiff(props) {
|
|
|
34
35
|
return fallback;
|
|
35
36
|
}
|
|
36
37
|
const unavailable = _jsx(DiffUnavailable, { path: change.path });
|
|
37
|
-
return (_jsx(DiffFallbackBoundary, { fallback: unavailable, resetKeys: [change.path, change.diff, oldText, newText, ignoreWhitespace, diffStyle, loadEngine], children: _jsx(
|
|
38
|
+
return (_jsx(DiffFallbackBoundary, { fallback: unavailable, resetKeys: [change.path, change.diff, oldText, newText, ignoreWhitespace, diffStyle, loadEngine], children: _jsx(LazyBoundary, { fallback: _jsx("div", { className: "px-3 py-2 text-xs text-text-faint", children: t('work.loadingDiff') }), children: _jsx(EditorPatchDiff, { change: change, sourceChecked: true, contents: contents, ignoreWhitespace: ignoreWhitespace, wrap: overflow === 'wrap', fill: fill, maxHeight: maxHeight, layout: diffStyle, loadEngine: loadEngine, fallback: unavailable }) }) }));
|
|
38
39
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { LazyBoundary } from '@adecore/ui';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { lazyNamed } from '../../../lazy.js';
|
|
5
5
|
const EditDiff = lazyNamed(() => import('../EditDiff.js'), 'default');
|
|
6
6
|
const UnifiedDiff = lazyNamed(() => import('../UnifiedDiff.js'), 'default');
|
|
7
7
|
export function ReviewDiff({ entry, maxHeight = 480 }) {
|
|
8
8
|
const { t } = useTranslation('agent-chat');
|
|
9
|
-
return (_jsx("div", { "data-review-entry": entry.key, children: _jsx(
|
|
9
|
+
return (_jsx("div", { "data-review-entry": entry.key, children: _jsx(LazyBoundary, { fallback: _jsx("p", { className: "px-3 py-2 text-xs text-text-faint", children: t('work.loadingDiff') }), children: entry.change.kind === 'edit' ? (_jsx(EditDiff, { change: entry.change.edit, maxHeight: maxHeight })) : (_jsx(UnifiedDiff, { change: entry.change.patch, contents: entry.change.contents, maxHeight: maxHeight })) }) }));
|
|
10
10
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Fragment,
|
|
2
|
+
import { Fragment, useEffect, useState } from 'react';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import i18next from 'i18next';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
@@ -13,7 +13,7 @@ import { useChatScope } from '../../../scope.js';
|
|
|
13
13
|
import { useCurrentItem } from '../../../state/chats.js';
|
|
14
14
|
import { useTimelineFlash } from '../../timeline-flash.js';
|
|
15
15
|
import { formatClockDuration, formatElapsedShort } from '@adecore/ui/format';
|
|
16
|
-
import { Icon, MiddleTruncate, Spinner, useTickingText } from '@adecore/ui';
|
|
16
|
+
import { Icon, LazyBoundary, MiddleTruncate, Spinner, useTickingText } from '@adecore/ui';
|
|
17
17
|
import { ROW_GUTTER, toolIcon } from '../icons.js';
|
|
18
18
|
import { AnsiOutput } from '../AnsiOutput.js';
|
|
19
19
|
import { RowTime } from '../RowTime.js';
|
|
@@ -48,7 +48,7 @@ export function ToggleLine({ icon, label, detail, command, path, open = false, o
|
|
|
48
48
|
/* The diff renderers load lazily, so a diff waits on them under a line that says so. */
|
|
49
49
|
function DiffSuspense({ children }) {
|
|
50
50
|
const { t } = useTranslation('agent-chat');
|
|
51
|
-
return _jsx(
|
|
51
|
+
return _jsx(LazyBoundary, { fallback: _jsx("div", { className: "px-3 py-2 text-xs text-text-faint", children: t('work.loadingDiff') }), children: children });
|
|
52
52
|
}
|
|
53
53
|
/* A file in a changed files card, which opens its diff under it. */
|
|
54
54
|
function ChangedFileLine({ path, open, onToggle, trailing, children }) {
|
package/dist/lazy.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { lazy } from 'react';
|
|
3
|
+
import { LoadedComponent } from '@adecore/ui';
|
|
3
4
|
const loaders = [];
|
|
4
5
|
let register = null;
|
|
5
6
|
const openErrorListeners = new Set();
|
|
@@ -29,12 +30,9 @@ export function onLazyOpenError(listener) {
|
|
|
29
30
|
* module the prefetcher already fetched.
|
|
30
31
|
*/
|
|
31
32
|
export function lazyNamed(load, name, options) {
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
loaded ??= component;
|
|
36
|
-
return component;
|
|
37
|
-
};
|
|
33
|
+
// Through `LoadedComponent`, so a `LazyBoundary` around it draws the moment the module lands.
|
|
34
|
+
const loaded = new LoadedComponent(async () => (await load())[name]);
|
|
35
|
+
const open = () => loaded.load();
|
|
38
36
|
if (options?.prefetch !== false) {
|
|
39
37
|
loaders.push(open);
|
|
40
38
|
register?.(open);
|
|
@@ -52,7 +50,7 @@ export function lazyNamed(load, name, options) {
|
|
|
52
50
|
}
|
|
53
51
|
});
|
|
54
52
|
const LazyNamed = (props) => {
|
|
55
|
-
const Component = loaded ?? Lazy;
|
|
53
|
+
const Component = loaded.current ?? Lazy;
|
|
56
54
|
return _jsx(Component, { ...props });
|
|
57
55
|
};
|
|
58
56
|
return LazyNamed;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adecore/agents-react",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.2",
|
|
4
4
|
"description": "React agent chat threads, composers, approvals, provider accounts and usage views.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -67,11 +67,11 @@
|
|
|
67
67
|
"test:visuals": "bun --config=integration.bunfig.toml --conditions=source test ./src/chat/visual-viewport.integration.test.ts"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@adecore/agent-contracts": "0.24.
|
|
71
|
-
"@adecore/editor": "0.24.
|
|
72
|
-
"@adecore/editor-react": "0.24.
|
|
73
|
-
"@adecore/intelligent-ui": "0.24.
|
|
74
|
-
"@adecore/merge": "0.24.
|
|
70
|
+
"@adecore/agent-contracts": "0.24.2",
|
|
71
|
+
"@adecore/editor": "0.24.2",
|
|
72
|
+
"@adecore/editor-react": "0.24.2",
|
|
73
|
+
"@adecore/intelligent-ui": "0.24.2",
|
|
74
|
+
"@adecore/merge": "0.24.2",
|
|
75
75
|
"@codemirror/commands": "^6.11.1",
|
|
76
76
|
"@codemirror/language": "^6.12.4",
|
|
77
77
|
"@codemirror/state": "^6.7.6",
|
|
@@ -93,14 +93,14 @@
|
|
|
93
93
|
"zustand": "^5.0.15"
|
|
94
94
|
},
|
|
95
95
|
"peerDependencies": {
|
|
96
|
-
"@adecore/ui": "^0.24.
|
|
96
|
+
"@adecore/ui": "^0.24.2",
|
|
97
97
|
"i18next": "^26.4.2",
|
|
98
98
|
"react": "^19.3.0",
|
|
99
99
|
"react-dom": "^19.3.0",
|
|
100
100
|
"react-i18next": "^17.0.15"
|
|
101
101
|
},
|
|
102
102
|
"devDependencies": {
|
|
103
|
-
"@adecore/ui": "0.24.
|
|
103
|
+
"@adecore/ui": "0.24.2",
|
|
104
104
|
"@types/bun": "^1.4.2",
|
|
105
105
|
"@types/react": "^19.3.0",
|
|
106
106
|
"@types/react-dom": "^19.3.0",
|
package/src/chat/ui/EditDiff.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { LazyBoundary } from '@adecore/ui';
|
|
2
3
|
import { useTranslation } from 'react-i18next';
|
|
3
4
|
import { lazyNamed } from '../../lazy';
|
|
4
5
|
import { diffSourceBudget, legacyDiffBudget } from './diff/diff-source-budget';
|
|
@@ -22,9 +23,9 @@ export default function EditDiff({ change, allowEditor = true, maxHeight }: { ch
|
|
|
22
23
|
const omitted = <DiffOmitted path={change.path} />;
|
|
23
24
|
const fallback = legacyAllowed ? (
|
|
24
25
|
<DiffFallbackBoundary fallback={omitted} resetKeys={[change.path, change.before, change.after]}>
|
|
25
|
-
<
|
|
26
|
+
<LazyBoundary fallback={<div className="px-3 py-2 text-xs text-text-faint">{t('work.loadingDiff')}</div>}>
|
|
26
27
|
<LegacyEditDiff change={change} maxHeight={maxHeight} />
|
|
27
|
-
</
|
|
28
|
+
</LazyBoundary>
|
|
28
29
|
</DiffFallbackBoundary>
|
|
29
30
|
) : (
|
|
30
31
|
omitted
|
|
@@ -38,9 +39,9 @@ export default function EditDiff({ change, allowEditor = true, maxHeight }: { ch
|
|
|
38
39
|
const unavailable = <DiffUnavailable path={change.path} />;
|
|
39
40
|
return (
|
|
40
41
|
<DiffFallbackBoundary fallback={unavailable} resetKeys={[change.path, change.before, change.after, loadEngine]}>
|
|
41
|
-
<
|
|
42
|
+
<LazyBoundary fallback={<div className="px-3 py-2 text-xs text-text-faint">{t('work.loadingDiff')}</div>}>
|
|
42
43
|
<EditorEditDiff change={change} loadEngine={loadEngine!} fallback={unavailable} maxHeight={maxHeight} sourceChecked />
|
|
43
|
-
</
|
|
44
|
+
</LazyBoundary>
|
|
44
45
|
</DiffFallbackBoundary>
|
|
45
46
|
);
|
|
46
47
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { LazyBoundary } from '@adecore/ui';
|
|
2
3
|
import { useTranslation } from 'react-i18next';
|
|
3
4
|
import { lazyNamed } from '../../lazy';
|
|
4
5
|
import { diffSourceBudget, legacyDiffBudget, patchSourceBudget } from './diff/diff-source-budget';
|
|
@@ -27,9 +28,9 @@ export default function UnifiedDiff(props: UnifiedDiffProps) {
|
|
|
27
28
|
const omitted = <DiffOmitted path={change.path} />;
|
|
28
29
|
const fallback = legacyAllowed ? (
|
|
29
30
|
<DiffFallbackBoundary fallback={omitted} resetKeys={[change.path, change.diff, oldText, newText, diffStyle]}>
|
|
30
|
-
<
|
|
31
|
+
<LazyBoundary fallback={<div className="px-3 py-2 text-xs text-text-faint">{t('work.loadingDiff')}</div>}>
|
|
31
32
|
<LegacyUnifiedDiff {...props} />
|
|
32
|
-
</
|
|
33
|
+
</LazyBoundary>
|
|
33
34
|
</DiffFallbackBoundary>
|
|
34
35
|
) : (
|
|
35
36
|
omitted
|
|
@@ -46,7 +47,7 @@ export default function UnifiedDiff(props: UnifiedDiffProps) {
|
|
|
46
47
|
const unavailable = <DiffUnavailable path={change.path} />;
|
|
47
48
|
return (
|
|
48
49
|
<DiffFallbackBoundary fallback={unavailable} resetKeys={[change.path, change.diff, oldText, newText, ignoreWhitespace, diffStyle, loadEngine]}>
|
|
49
|
-
<
|
|
50
|
+
<LazyBoundary fallback={<div className="px-3 py-2 text-xs text-text-faint">{t('work.loadingDiff')}</div>}>
|
|
50
51
|
<EditorPatchDiff
|
|
51
52
|
change={change}
|
|
52
53
|
sourceChecked
|
|
@@ -59,7 +60,7 @@ export default function UnifiedDiff(props: UnifiedDiffProps) {
|
|
|
59
60
|
loadEngine={loadEngine!}
|
|
60
61
|
fallback={unavailable}
|
|
61
62
|
/>
|
|
62
|
-
</
|
|
63
|
+
</LazyBoundary>
|
|
63
64
|
</DiffFallbackBoundary>
|
|
64
65
|
);
|
|
65
66
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LazyBoundary } from '@adecore/ui';
|
|
2
2
|
import { useTranslation } from 'react-i18next';
|
|
3
3
|
import { lazyNamed } from '../../../lazy';
|
|
4
4
|
import type { ReviewEntry } from './review-plan';
|
|
@@ -10,13 +10,13 @@ export function ReviewDiff({ entry, maxHeight = 480 }: { entry: ReviewEntry; max
|
|
|
10
10
|
const { t } = useTranslation('agent-chat');
|
|
11
11
|
return (
|
|
12
12
|
<div data-review-entry={entry.key}>
|
|
13
|
-
<
|
|
13
|
+
<LazyBoundary fallback={<p className="px-3 py-2 text-xs text-text-faint">{t('work.loadingDiff')}</p>}>
|
|
14
14
|
{entry.change.kind === 'edit' ? (
|
|
15
15
|
<EditDiff change={entry.change.edit} maxHeight={maxHeight} />
|
|
16
16
|
) : (
|
|
17
17
|
<UnifiedDiff change={entry.change.patch} contents={entry.change.contents} maxHeight={maxHeight} />
|
|
18
18
|
)}
|
|
19
|
-
</
|
|
19
|
+
</LazyBoundary>
|
|
20
20
|
</div>
|
|
21
21
|
);
|
|
22
22
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fragment,
|
|
1
|
+
import { Fragment, useEffect, useState, type Dispatch, type ReactNode, type SetStateAction } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import i18next from 'i18next';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
@@ -28,7 +28,7 @@ import { useChatScope } from '../../../scope';
|
|
|
28
28
|
import { useCurrentItem } from '../../../state/chats';
|
|
29
29
|
import { useTimelineFlash } from '../../timeline-flash';
|
|
30
30
|
import { formatClockDuration, formatElapsedShort } from '@adecore/ui/format';
|
|
31
|
-
import { Icon, MiddleTruncate, Spinner, useTickingText } from '@adecore/ui';
|
|
31
|
+
import { Icon, LazyBoundary, MiddleTruncate, Spinner, useTickingText } from '@adecore/ui';
|
|
32
32
|
import { ROW_GUTTER, toolIcon } from '../icons';
|
|
33
33
|
import { AnsiOutput } from '../AnsiOutput';
|
|
34
34
|
import { RowTime } from '../RowTime';
|
|
@@ -122,7 +122,7 @@ export function ToggleLine({
|
|
|
122
122
|
/* The diff renderers load lazily, so a diff waits on them under a line that says so. */
|
|
123
123
|
function DiffSuspense({ children }: { children: ReactNode }) {
|
|
124
124
|
const { t } = useTranslation('agent-chat');
|
|
125
|
-
return <
|
|
125
|
+
return <LazyBoundary fallback={<div className="px-3 py-2 text-xs text-text-faint">{t('work.loadingDiff')}</div>}>{children}</LazyBoundary>;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
/* A file in a changed files card, which opens its diff under it. */
|
package/src/lazy.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { lazy, type ComponentProps, type ComponentType } from 'react';
|
|
2
|
+
import { LoadedComponent } from '@adecore/ui';
|
|
2
3
|
|
|
3
4
|
type Loader = () => Promise<unknown>;
|
|
4
5
|
|
|
@@ -38,12 +39,9 @@ export function lazyNamed<Module extends Record<Name, ComponentType<any>>, Name
|
|
|
38
39
|
name: Name,
|
|
39
40
|
options?: { readonly prefetch?: boolean }
|
|
40
41
|
): ComponentType<ComponentProps<Module[Name]>> {
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
loaded ??= component;
|
|
45
|
-
return component;
|
|
46
|
-
};
|
|
42
|
+
// Through `LoadedComponent`, so a `LazyBoundary` around it draws the moment the module lands.
|
|
43
|
+
const loaded = new LoadedComponent<ComponentType<any>>(async () => (await load())[name]);
|
|
44
|
+
const open = (): Promise<ComponentType<any>> => loaded.load();
|
|
47
45
|
if (options?.prefetch !== false) {
|
|
48
46
|
loaders.push(open);
|
|
49
47
|
register?.(open);
|
|
@@ -60,7 +58,7 @@ export function lazyNamed<Module extends Record<Name, ComponentType<any>>, Name
|
|
|
60
58
|
}
|
|
61
59
|
});
|
|
62
60
|
const LazyNamed = (props: ComponentProps<Module[Name]>) => {
|
|
63
|
-
const Component: ComponentType<any> = loaded ?? Lazy;
|
|
61
|
+
const Component: ComponentType<any> = loaded.current ?? Lazy;
|
|
64
62
|
return <Component {...props} />;
|
|
65
63
|
};
|
|
66
64
|
return LazyNamed;
|