@adecore/agents-react 0.46.3 → 0.48.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/dist/agents/accounts.d.ts +9 -1
- package/dist/agents/accounts.js +31 -7
- package/dist/chat/account-choice.d.ts +5 -4
- package/dist/chat/account-choice.js +47 -39
- package/dist/chat/index.d.ts +1 -0
- package/dist/chat/index.js +1 -0
- package/dist/chat/logic/scrubber.js +12 -0
- package/dist/chat/logic/timeline-copy.js +2 -0
- package/dist/chat/logic/timeline.d.ts +6 -1
- package/dist/chat/logic/timeline.js +36 -10
- package/dist/chat/preferences.d.ts +2 -2
- package/dist/chat/preferences.js +11 -5
- package/dist/chat/ui/AccountPill.js +9 -6
- package/dist/chat/ui/ChatActivity.d.ts +2 -1
- package/dist/chat/ui/ChatActivity.js +295 -61
- package/dist/chat/ui/Composer.d.ts +2 -1
- package/dist/chat/ui/Composer.js +492 -486
- package/dist/chat/ui/LimitState.js +180 -172
- package/dist/chat/ui/PromptEditor.js +4 -1
- package/dist/chat/ui/ReferenceChip.d.ts +2 -1
- package/dist/chat/ui/ReferenceChip.js +135 -100
- package/dist/chat/ui/UnifiedDiff.js +22 -19
- package/dist/chat/ui/composer/ComposerControls.js +1 -1
- package/dist/chat/ui/composer/ComposerMenu.js +17 -11
- package/dist/chat/ui/composer/chips.d.ts +3 -0
- package/dist/chat/ui/composer/chips.js +14 -10
- package/dist/chat/ui/composer/use-chat-controls.js +70 -67
- package/dist/chat/ui/diff/EditorEditDiff.d.ts +3 -1
- package/dist/chat/ui/diff/EditorEditDiff.js +24 -18
- package/dist/chat/ui/diff/EditorPatchDiff.d.ts +3 -1
- package/dist/chat/ui/diff/EditorPatchDiff.js +4 -2
- package/dist/chat/ui/diff/diff-props.d.ts +2 -0
- package/dist/chat/ui/reference-icons.d.ts +3 -0
- package/dist/chat/ui/reference-icons.js +15 -2
- package/dist/chat/ui/rows/MessageRows.d.ts +6 -1
- package/dist/chat/ui/rows/MessageRows.js +166 -10
- package/dist/chat/ui/rows/RowContainer.js +21 -22
- package/dist/chat/ui/rows/Rows.js +37 -19
- package/dist/chat/ui/rows/WorkflowRow.d.ts +2 -1
- package/dist/chat/ui/rows/WorkflowRow.js +197 -191
- package/dist/chat/ui/rows/row-rhythm.d.ts +1 -0
- package/dist/chat/ui/rows/row-rhythm.js +12 -3
- package/dist/chat/workflow-list.d.ts +12 -0
- package/dist/chat/workflow-list.js +54 -0
- package/dist/host-hooks.d.ts +3 -0
- package/dist/host-hooks.js +8 -0
- package/dist/host.d.ts +11 -1
- package/dist/index.d.ts +1 -1
- package/dist/locales/en/agent-chat.d.ts +9 -0
- package/dist/locales/en/agent-chat.js +9 -0
- package/dist/locales/en/agent-providers.d.ts +5 -0
- package/dist/locales/en/agent-providers.js +8 -3
- package/dist/locales/nl/agent-chat.d.ts +9 -0
- package/dist/locales/nl/agent-chat.js +9 -0
- package/dist/locales/nl/agent-providers.d.ts +5 -0
- package/dist/locales/nl/agent-providers.js +8 -3
- package/dist/providers/AccountOrderList.d.ts +10 -0
- package/dist/providers/AccountOrderList.js +158 -0
- package/dist/providers/CliDetail.js +55 -61
- package/dist/providers/account-actions.d.ts +1 -0
- package/dist/providers/account-actions.js +39 -0
- package/dist/providers/index.d.ts +1 -1
- package/dist/providers/index.js +1 -1
- package/dist/usage/limit-groups.js +6 -1
- package/package.json +8 -8
- package/src/agents/accounts.ts +42 -6
- package/src/chat/account-choice.ts +31 -10
- package/src/chat/index.ts +1 -0
- package/src/chat/logic/scrubber.ts +5 -0
- package/src/chat/logic/timeline-copy.ts +2 -0
- package/src/chat/logic/timeline.ts +33 -2
- package/src/chat/preferences.ts +33 -8
- package/src/chat/ui/AccountPill.tsx +3 -3
- package/src/chat/ui/ChatActivity.tsx +52 -6
- package/src/chat/ui/Composer.tsx +19 -3
- package/src/chat/ui/LimitState.tsx +4 -2
- package/src/chat/ui/PromptEditor.tsx +3 -1
- package/src/chat/ui/ReferenceChip.tsx +15 -5
- package/src/chat/ui/UnifiedDiff.tsx +12 -1
- package/src/chat/ui/composer/ComposerControls.tsx +1 -1
- package/src/chat/ui/composer/ComposerMenu.tsx +4 -2
- package/src/chat/ui/composer/chips.ts +15 -9
- package/src/chat/ui/composer/use-chat-controls.ts +4 -1
- package/src/chat/ui/diff/EditorEditDiff.tsx +9 -4
- package/src/chat/ui/diff/EditorPatchDiff.tsx +5 -1
- package/src/chat/ui/diff/diff-props.ts +3 -0
- package/src/chat/ui/reference-icons.ts +13 -1
- package/src/chat/ui/rows/MessageRows.tsx +35 -0
- package/src/chat/ui/rows/RowContainer.tsx +2 -2
- package/src/chat/ui/rows/Rows.tsx +3 -0
- package/src/chat/ui/rows/WorkflowRow.tsx +9 -4
- package/src/chat/ui/rows/row-rhythm.ts +12 -3
- package/src/chat/workflow-list.ts +65 -0
- package/src/host-hooks.ts +13 -0
- package/src/host.ts +23 -1
- package/src/index.ts +1 -0
- package/src/locales/en/agent-chat.ts +9 -0
- package/src/locales/en/agent-providers.ts +8 -3
- package/src/locales/nl/agent-chat.ts +9 -0
- package/src/locales/nl/agent-providers.ts +8 -3
- package/src/providers/AccountOrderList.tsx +124 -0
- package/src/providers/CliDetail.tsx +33 -28
- package/src/providers/account-actions.ts +30 -0
- package/src/providers/index.ts +11 -1
- package/src/usage/limit-groups.ts +8 -1
|
@@ -52,6 +52,45 @@ export async function removeAccount(scope, host, id, kind) {
|
|
|
52
52
|
rememberChatAccount(scope.id, kind, null);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
+
/* Puts the accounts of one CLI in this order, showing it at once; a refusal puts the host's order back and says why. */
|
|
56
|
+
export async function reorderAccounts(scope, host, kind, ids) {
|
|
57
|
+
const store = useProviderAccountsStore.getState();
|
|
58
|
+
const before = providerAccountsOf(scope.id).accounts;
|
|
59
|
+
if (before !== null) {
|
|
60
|
+
const accounts = {
|
|
61
|
+
...before.accounts
|
|
62
|
+
};
|
|
63
|
+
for (const [order, id] of ids.entries()) {
|
|
64
|
+
const account = accounts[id];
|
|
65
|
+
if (account !== undefined) {
|
|
66
|
+
accounts[id] = {
|
|
67
|
+
...account,
|
|
68
|
+
order
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
store.set(scope.id, {
|
|
73
|
+
...before,
|
|
74
|
+
accounts
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
store.set(scope.id, await linkTo(scope).request('accounts.reorder', {
|
|
79
|
+
kind,
|
|
80
|
+
ids: [...ids]
|
|
81
|
+
}));
|
|
82
|
+
} catch (e) {
|
|
83
|
+
if (before !== null) {
|
|
84
|
+
store.set(scope.id, before);
|
|
85
|
+
}
|
|
86
|
+
host.notify({
|
|
87
|
+
id: `providers-reorder-${scope.id}`,
|
|
88
|
+
kind: 'error',
|
|
89
|
+
title: words('account.reorderFailed'),
|
|
90
|
+
description: errorMessage(e)
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
55
94
|
/* An account in a folder the host makes for it; answers its id. Throws what the host said, for the form to show. */
|
|
56
95
|
export async function createAccount(scope, kind, label, color) {
|
|
57
96
|
const {
|
|
@@ -3,7 +3,7 @@ export { AgentIcon } from '../agents/AgentIcon.js';
|
|
|
3
3
|
export { AgentModelLabel } from '../agents/AgentModelLabel.js';
|
|
4
4
|
export { ModelOptionControl } from '../agents/ModelOptionControl.js';
|
|
5
5
|
export { ProviderLogo } from '../agents/ProviderLogo.js';
|
|
6
|
-
export { type AccountEntry, accountsOfKind, ACCOUNT_TONE_CLASSES, accountStatusLine, canContinueOn, type AccountTone } from '../agents/accounts.js';
|
|
6
|
+
export { type AccountEntry, type AccountRule, accountsOfKind, ACCOUNT_TONE_CLASSES, accountStatusLine, canContinueOn, projectDefault, topAccountEntry, type AccountTone } from '../agents/accounts.js';
|
|
7
7
|
export { modelName, useModelName, shortModelName } from '../agents/model-name.js';
|
|
8
8
|
export { carryOptions } from '../agents/model-options.js';
|
|
9
9
|
export { type ModelRequirement } from '../agents/model-requirement.js';
|
package/dist/providers/index.js
CHANGED
|
@@ -4,7 +4,7 @@ export { AgentIcon } from '../agents/AgentIcon.js';
|
|
|
4
4
|
export { AgentModelLabel } from '../agents/AgentModelLabel.js';
|
|
5
5
|
export { ModelOptionControl } from '../agents/ModelOptionControl.js';
|
|
6
6
|
export { ProviderLogo } from '../agents/ProviderLogo.js';
|
|
7
|
-
export { accountsOfKind, ACCOUNT_TONE_CLASSES, accountStatusLine, canContinueOn } from '../agents/accounts.js';
|
|
7
|
+
export { accountsOfKind, ACCOUNT_TONE_CLASSES, accountStatusLine, canContinueOn, projectDefault, topAccountEntry } from '../agents/accounts.js';
|
|
8
8
|
export { modelName, useModelName, shortModelName } from '../agents/model-name.js';
|
|
9
9
|
export { carryOptions } from '../agents/model-options.js';
|
|
10
10
|
export {} from '../agents/model-requirement.js';
|
|
@@ -42,7 +42,12 @@ export function limitGroups(snapshot, accounts) {
|
|
|
42
42
|
entry: null,
|
|
43
43
|
status: account.status
|
|
44
44
|
}));
|
|
45
|
-
|
|
45
|
+
// In the person's order, as every other list of accounts; a read account the list does not know yet goes last.
|
|
46
|
+
const place = id => {
|
|
47
|
+
const index = known.findIndex(account => account.id === id);
|
|
48
|
+
return index === -1 ? known.length : index;
|
|
49
|
+
};
|
|
50
|
+
const rows = [...read, ...unread].sort((a, b) => place(a.id) - place(b.id));
|
|
46
51
|
return rows.length === 0 ? [] : [{
|
|
47
52
|
kind,
|
|
48
53
|
accounts: rows
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adecore/agents-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.48.0",
|
|
4
4
|
"description": "React agent chat threads, composers, approvals, provider accounts and usage views.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -72,11 +72,11 @@
|
|
|
72
72
|
"test:visuals": "bun --config=integration.bunfig.toml --conditions=source test ./src/chat/visual-viewport.integration.test.ts"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@adecore/agent-contracts": "0.
|
|
76
|
-
"@adecore/editor": "0.
|
|
77
|
-
"@adecore/editor-react": "0.
|
|
78
|
-
"@adecore/intelligent-ui": "0.
|
|
79
|
-
"@adecore/merge": "0.
|
|
75
|
+
"@adecore/agent-contracts": "0.48.0",
|
|
76
|
+
"@adecore/editor": "0.48.0",
|
|
77
|
+
"@adecore/editor-react": "0.48.0",
|
|
78
|
+
"@adecore/intelligent-ui": "0.48.0",
|
|
79
|
+
"@adecore/merge": "0.48.0",
|
|
80
80
|
"@codemirror/commands": "^6.11.1",
|
|
81
81
|
"@codemirror/language": "^6.13.1",
|
|
82
82
|
"@codemirror/state": "^6.7.6",
|
|
@@ -100,14 +100,14 @@
|
|
|
100
100
|
"zustand": "^5.0.16"
|
|
101
101
|
},
|
|
102
102
|
"peerDependencies": {
|
|
103
|
-
"@adecore/ui": "^0.
|
|
103
|
+
"@adecore/ui": "^0.48.0",
|
|
104
104
|
"i18next": "^26.4.2",
|
|
105
105
|
"react": "^19.3.0",
|
|
106
106
|
"react-dom": "^19.3.0",
|
|
107
107
|
"react-i18next": "^17.0.15"
|
|
108
108
|
},
|
|
109
109
|
"devDependencies": {
|
|
110
|
-
"@adecore/ui": "0.
|
|
110
|
+
"@adecore/ui": "0.48.0",
|
|
111
111
|
"@types/bun": "^1.4.4",
|
|
112
112
|
"@types/react": "^19.3.0",
|
|
113
113
|
"@types/react-dom": "^19.3.0",
|
package/src/agents/accounts.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import i18next from 'i18next';
|
|
2
|
-
import type
|
|
2
|
+
import { orderedAccountIds, type AgentKind, type ProviderAccount, type ProviderAccounts, type ProviderAccountStatus } from '@adecore/agent-contracts';
|
|
3
3
|
import type { AccentChoice, ChatHost } from '../host';
|
|
4
4
|
|
|
5
5
|
/*
|
|
@@ -24,7 +24,7 @@ export interface AccountEntry {
|
|
|
24
24
|
isDefault: boolean;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
/* The accounts of one CLI
|
|
27
|
+
/* The accounts of one CLI in the person's order, the one every list and menu shows. */
|
|
28
28
|
export function accountsOfKind(accounts: ProviderAccounts | null, kind: AgentKind): AccountEntry[] {
|
|
29
29
|
if (accounts === null) {
|
|
30
30
|
return [];
|
|
@@ -32,10 +32,46 @@ export function accountsOfKind(accounts: ProviderAccounts | null, kind: AgentKin
|
|
|
32
32
|
|
|
33
33
|
const statuses = new Map(accounts.statuses.map((status) => [status.id, status]));
|
|
34
34
|
|
|
35
|
-
return
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
return orderedAccountIds(accounts.accounts, kind).flatMap((id) => {
|
|
36
|
+
const account = accounts.accounts[id];
|
|
37
|
+
|
|
38
|
+
return account === undefined ? [] : [{ id, account, status: statuses.get(id) ?? null, isDefault: id === kind }];
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* The account a new chat of this CLI starts on when nothing names one, as the machine decides it. */
|
|
43
|
+
export function topAccountEntry(entries: readonly AccountEntry[]): AccountEntry | null {
|
|
44
|
+
return entries.find((entry) => entry.account.enabled !== false) ?? null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/* The ids of an order with one moved to another place, clamped to the ends. */
|
|
48
|
+
export function movedIds(ids: readonly string[], id: string, to: number): string[] {
|
|
49
|
+
const rest = ids.filter((candidate) => candidate !== id);
|
|
50
|
+
const place = Math.max(0, Math.min(to, rest.length));
|
|
51
|
+
|
|
52
|
+
return [...rest.slice(0, place), id, ...rest.slice(place)];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* What a project says about the accounts of each CLI: the one its new chats start on, and those it never offers. */
|
|
56
|
+
export type AccountRule = Partial<Record<string, { default?: string; off?: readonly string[] }>>;
|
|
57
|
+
|
|
58
|
+
/* The accounts a project offers, as `offeredAccounts` gives them; the one in use stays even when the project turned it off. */
|
|
59
|
+
export function projectOffered(
|
|
60
|
+
entries: readonly AccountEntry[],
|
|
61
|
+
rule: AccountRule | null | undefined,
|
|
62
|
+
kind: AgentKind,
|
|
63
|
+
current: string | undefined
|
|
64
|
+
): AccountEntry[] {
|
|
65
|
+
const off = rule?.[kind]?.off ?? [];
|
|
66
|
+
|
|
67
|
+
return entries.filter((entry) => !off.includes(entry.id) || entry.id === current);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* The project's own default account of a CLI, while the machine still has it and it is on. */
|
|
71
|
+
export function projectDefault(entries: readonly AccountEntry[], rule: AccountRule | null | undefined, kind: AgentKind): string | null {
|
|
72
|
+
const id = rule?.[kind]?.default;
|
|
73
|
+
|
|
74
|
+
return entries.some((entry) => entry.id === id && entry.account.enabled !== false) ? (id ?? null) : null;
|
|
39
75
|
}
|
|
40
76
|
|
|
41
77
|
/* A default account nobody named goes by its CLI's name. */
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import type { AgentKind, ProviderAccounts } from '@adecore/agent-contracts';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
accountName,
|
|
4
|
+
accountsOfKind,
|
|
5
|
+
hasAccountChoice,
|
|
6
|
+
offeredAccounts,
|
|
7
|
+
projectDefault,
|
|
8
|
+
projectOffered,
|
|
9
|
+
type AccountEntry,
|
|
10
|
+
type AccountRule
|
|
11
|
+
} from '../agents/accounts';
|
|
12
|
+
import { useHostAccountRule } from '../host-hooks';
|
|
13
|
+
import { useChatScope } from '../scope';
|
|
3
14
|
import { useProviderAccounts, type ProviderAccountsRow } from '../state/provider-accounts';
|
|
4
15
|
import { useProviders } from '../state/providers';
|
|
5
16
|
|
|
6
17
|
export interface AccountChoice {
|
|
7
18
|
accounts: ProviderAccounts;
|
|
8
|
-
/* The accounts a person may pick for this CLI: those that are on, and the one in use. */
|
|
19
|
+
/* The accounts a person may pick for this CLI: those that are on and the chat's project offers, and the one in use. */
|
|
9
20
|
offered: AccountEntry[];
|
|
10
21
|
/* The account the chat runs under, by id; the CLI's kind for its default account. */
|
|
11
22
|
currentId: string;
|
|
@@ -19,7 +30,9 @@ export interface AccountChoice {
|
|
|
19
30
|
* The accounts of a chat's CLI on the machine in scope and the one the chat runs under, or null while
|
|
20
31
|
* the CLI has fewer than two accounts that are on: with one there is nothing to choose or tell apart.
|
|
21
32
|
*/
|
|
22
|
-
export function useAccountChoice(kind: AgentKind | null, account: string | undefined): AccountChoice | null {
|
|
33
|
+
export function useAccountChoice(kind: AgentKind | null, account: string | undefined, chatId: string): AccountChoice | null {
|
|
34
|
+
const scope = useChatScope();
|
|
35
|
+
const rule = useHostAccountRule(scope.id, chatId);
|
|
23
36
|
const accounts = useProviderAccounts((row) => row.accounts);
|
|
24
37
|
const providerName = useProviders((row) => row.providers.find((entry) => entry.kind === kind)?.name) ?? kind ?? '';
|
|
25
38
|
|
|
@@ -37,7 +50,7 @@ export function useAccountChoice(kind: AgentKind | null, account: string | undef
|
|
|
37
50
|
|
|
38
51
|
return {
|
|
39
52
|
accounts,
|
|
40
|
-
offered: offeredAccounts(entries, currentId),
|
|
53
|
+
offered: projectOffered(offeredAccounts(entries, currentId), rule, kind, currentId),
|
|
41
54
|
currentId,
|
|
42
55
|
current: entries.find((entry) => entry.id === currentId) ?? null,
|
|
43
56
|
providerName,
|
|
@@ -54,14 +67,21 @@ export function useAccountChoice(kind: AgentKind | null, account: string | undef
|
|
|
54
67
|
export type NewAccountChoice =
|
|
55
68
|
| { status: 'loading' }
|
|
56
69
|
| { status: 'unsupported' }
|
|
57
|
-
| {
|
|
70
|
+
| {
|
|
71
|
+
status: 'ready';
|
|
72
|
+
offered: AccountEntry[];
|
|
73
|
+
/* The account the project starts new chats of this CLI on, by id; null leaves it to the order. */
|
|
74
|
+
projectDefault: string | null;
|
|
75
|
+
providerName: string;
|
|
76
|
+
nameOf(entry: AccountEntry): string;
|
|
77
|
+
};
|
|
58
78
|
|
|
59
79
|
// One object each, so a render that changes nothing hands back the same answer.
|
|
60
80
|
const LOADING: NewAccountChoice = { status: 'loading' };
|
|
61
81
|
const UNSUPPORTED: NewAccountChoice = { status: 'unsupported' };
|
|
62
82
|
|
|
63
83
|
/* `useNewAccountChoice` without React, for its tests. */
|
|
64
|
-
export function newAccountChoiceOf(row: ProviderAccountsRow, kind: AgentKind | null, providerName: string): NewAccountChoice {
|
|
84
|
+
export function newAccountChoiceOf(row: ProviderAccountsRow, kind: AgentKind | null, providerName: string, rule: AccountRule | null = null): NewAccountChoice {
|
|
65
85
|
if (kind === null || !row.loaded) {
|
|
66
86
|
return LOADING;
|
|
67
87
|
}
|
|
@@ -75,16 +95,17 @@ export function newAccountChoiceOf(row: ProviderAccountsRow, kind: AgentKind | n
|
|
|
75
95
|
|
|
76
96
|
return {
|
|
77
97
|
status: 'ready',
|
|
78
|
-
offered: offeredAccounts(entries, undefined),
|
|
98
|
+
offered: projectOffered(offeredAccounts(entries, undefined), rule, kind, undefined),
|
|
99
|
+
projectDefault: projectDefault(entries, rule, kind),
|
|
79
100
|
providerName,
|
|
80
101
|
nameOf: (entry: AccountEntry) => accountName(entry, providerName)
|
|
81
102
|
};
|
|
82
103
|
}
|
|
83
104
|
|
|
84
|
-
/* The accounts a new chat or agent of this CLI may start under on the machine in scope. */
|
|
85
|
-
export function useNewAccountChoice(kind: AgentKind | null): NewAccountChoice {
|
|
105
|
+
/* The accounts a new chat or agent of this CLI may start under on the machine in scope, within what the project of that start says. */
|
|
106
|
+
export function useNewAccountChoice(kind: AgentKind | null, rule: AccountRule | null = null): NewAccountChoice {
|
|
86
107
|
const row = useProviderAccounts((entry) => entry);
|
|
87
108
|
const providerName = useProviders((entry) => entry.providers.find((provider) => provider.kind === kind)?.name) ?? kind ?? '';
|
|
88
109
|
|
|
89
|
-
return newAccountChoiceOf(row, kind, providerName);
|
|
110
|
+
return newAccountChoiceOf(row, kind, providerName, rule);
|
|
90
111
|
}
|
package/src/chat/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { type AccountChoice, useAccountChoice, type NewAccountChoice, useNewAcco
|
|
|
3
3
|
export { transportActions, actionsOf, useChatActions } from './actions';
|
|
4
4
|
export { type ChatSendExtras, ChatClient } from './chat-client';
|
|
5
5
|
export type { ProjectChat, Referable, ReferableKind, Referables } from './chat-references';
|
|
6
|
+
export { REFERENCE_ICONS } from './ui/reference-icons';
|
|
6
7
|
export { sendFromComposer, type ComposerSend } from './composer-send';
|
|
7
8
|
export { stepEffortFromComposer } from './composer-effort';
|
|
8
9
|
export type { EffortStep } from './logic/effort';
|
|
@@ -89,6 +89,11 @@ export function ticksOf(
|
|
|
89
89
|
return [{ id: row.id, rowIndex, kind: 'person', text, createdAt: row.item.createdAt, turnId: row.item.turnId, bookmark }];
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
// A message another node sent stands in for the turn it opened, whose own line it hides.
|
|
93
|
+
if (row.kind === 'message') {
|
|
94
|
+
return [{ id: row.id, rowIndex, kind: 'wake', text: row.message.text, createdAt: row.createdAt, turnId: null, bookmark }];
|
|
95
|
+
}
|
|
96
|
+
|
|
92
97
|
// The other turns nobody asked for (a sub-agent that finished, the CLI going on) are no place to return to.
|
|
93
98
|
if (row.kind === 'turn-start' && ((row.turn.taskIds?.length ?? 0) > 0 || (row.turn.messageFrom?.length ?? 0) > 0)) {
|
|
94
99
|
return [{ id: row.id, rowIndex, kind: 'wake', text: row.label, createdAt: row.turn.createdAt, turnId: row.turn.id, bookmark: null }];
|
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
ChatAssistantItem,
|
|
5
5
|
ChatCheckpointDiff,
|
|
6
6
|
ChatItem,
|
|
7
|
+
ChatNoteMessage,
|
|
7
8
|
ChatQuestionItem,
|
|
8
9
|
ChatSubagentItem,
|
|
9
10
|
ChatThinkingItem,
|
|
@@ -55,6 +56,8 @@ export type TimelineRow =
|
|
|
55
56
|
| { kind: 'approval'; id: string; item: ChatApprovalItem }
|
|
56
57
|
| { kind: 'question'; id: string; item: ChatQuestionItem }
|
|
57
58
|
| { kind: 'note'; id: string; level: 'info' | 'warning' | 'error'; text: string; from?: string }
|
|
59
|
+
// A message another node sent the chat, drawn as said to it under the name of its sender.
|
|
60
|
+
| { kind: 'message'; id: string; message: ChatNoteMessage; createdAt: number }
|
|
58
61
|
| { kind: 'compaction'; id: string; preTokens: number | null }
|
|
59
62
|
| {
|
|
60
63
|
kind: 'changed-files';
|
|
@@ -455,7 +458,11 @@ function rowsForItems(items: ChatItem[], options: TimelineOptions, children: Map
|
|
|
455
458
|
|
|
456
459
|
break;
|
|
457
460
|
case 'note':
|
|
458
|
-
|
|
461
|
+
if (item.message !== undefined) {
|
|
462
|
+
rows.push({ kind: 'message', id: item.id, message: item.message, createdAt: item.createdAt });
|
|
463
|
+
} else {
|
|
464
|
+
rows.push({ kind: 'note', id: item.id, level: item.level, text: item.text, ...(item.from === undefined ? {} : { from: item.from }) });
|
|
465
|
+
}
|
|
459
466
|
|
|
460
467
|
break;
|
|
461
468
|
case 'compaction':
|
|
@@ -601,6 +608,29 @@ function chunksByTurn(items: ChatItem[]): TurnChunk[] {
|
|
|
601
608
|
return chunks;
|
|
602
609
|
}
|
|
603
610
|
|
|
611
|
+
/* Whether every node whose message opened the turn has that message among the rows right above it. */
|
|
612
|
+
function opensUnderItsMessages(turn: ChatTurnItem, rows: readonly TimelineRow[]): boolean {
|
|
613
|
+
const from = turn.messageFrom ?? [];
|
|
614
|
+
|
|
615
|
+
if (from.length === 0) {
|
|
616
|
+
return false;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
const senders = new Set<string>();
|
|
620
|
+
|
|
621
|
+
for (let i = rows.length - 1; i >= 0; i--) {
|
|
622
|
+
const row = rows[i]!;
|
|
623
|
+
|
|
624
|
+
if (row.kind !== 'message') {
|
|
625
|
+
break;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
senders.add(row.message.from);
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
return from.every((id) => senders.has(id));
|
|
632
|
+
}
|
|
633
|
+
|
|
604
634
|
/* The whole thread as rows; items without a turn (older records) are shown as they are. */
|
|
605
635
|
export function deriveTimelineRows(items: ChatItem[], options: TimelineOptions): TimelineRow[] {
|
|
606
636
|
const rows: TimelineRow[] = [];
|
|
@@ -617,7 +647,8 @@ export function deriveTimelineRows(items: ChatItem[], options: TimelineOptions):
|
|
|
617
647
|
const turn = chunk.items.find((item): item is ChatTurnItem => item.kind === 'turn');
|
|
618
648
|
const conversation = chunk.items.filter((item) => item.kind !== 'turn');
|
|
619
649
|
|
|
620
|
-
|
|
650
|
+
// A turn a message opened needs no line of its own when that message stands right above it.
|
|
651
|
+
if (turn?.origin === 'agent' && !opensUnderItsMessages(turn, rows)) {
|
|
621
652
|
// The agent started this one itself, so there is no message of the person to show above it.
|
|
622
653
|
rows.push({ kind: 'turn-start', id: `start-${turnId}`, turn, label: agentTurnLabel(turn) });
|
|
623
654
|
}
|
package/src/chat/preferences.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { chatStorageKey, chatStorageLegacyKeys, createChatStore, onChatStorageConfiguration } from '../storage';
|
|
2
|
-
import
|
|
2
|
+
import {
|
|
3
|
+
topAccountOf,
|
|
4
|
+
type AgentKind,
|
|
5
|
+
type ChatPreferencesPayload,
|
|
6
|
+
type ModelSelection,
|
|
7
|
+
type ProviderInfo,
|
|
8
|
+
type ProviderAccounts,
|
|
9
|
+
type RuntimeMode
|
|
10
|
+
} from '@adecore/agent-contracts';
|
|
3
11
|
import { persistedJson } from './persisted-json';
|
|
4
12
|
import { DEFAULT_READING_WIDTH, isChatReadingWidth, type ChatReadingWidth } from './reading-width';
|
|
5
13
|
import { DEFAULT_SEND_KEY, isChatSendKey, type ChatSendKey } from './send-key';
|
|
@@ -14,7 +22,7 @@ export interface ChatPreferences {
|
|
|
14
22
|
runtimeMode: RuntimeMode;
|
|
15
23
|
// What an agent started as a terminal node runs in; a chat picks its own mode in the composer.
|
|
16
24
|
terminalRuntimeMode: RuntimeMode;
|
|
17
|
-
/* Per machine, the account a new agent of each CLI starts under; an account id only means something on its own machine. */
|
|
25
|
+
/* Per machine that keeps no order of its accounts, the account a new agent of each CLI starts under; an account id only means something on its own machine. */
|
|
18
26
|
accountByMachine: Record<string, Partial<Record<AgentKind, string>>>;
|
|
19
27
|
/* How wide a chat of its own reads. It never reaches a machine. */
|
|
20
28
|
readingWidth: ChatReadingWidth;
|
|
@@ -137,12 +145,29 @@ export function withAccount(preferences: ChatPreferences, scopeId: string, provi
|
|
|
137
145
|
return { ...preferences, accountByMachine: Object.keys(picks).length === 0 ? machines : { ...machines, [scopeId]: picks } };
|
|
138
146
|
}
|
|
139
147
|
|
|
140
|
-
/*
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
148
|
+
/*
|
|
149
|
+
* What a machine starts a chat with when it starts one with no client mounting it; `accounts` as
|
|
150
|
+
* `accountFor` takes them. A machine that keeps an order of the accounts (`ordered`) starts on its top
|
|
151
|
+
* account, which this sends too; an older one still starts on the account picked here.
|
|
152
|
+
*/
|
|
153
|
+
export function chatPreferencesPayload(
|
|
154
|
+
preferences: ChatPreferences,
|
|
155
|
+
scopeId: string,
|
|
156
|
+
accounts?: ProviderAccounts | null,
|
|
157
|
+
ordered = false
|
|
158
|
+
): ChatPreferencesPayload {
|
|
159
|
+
const kinds = ordered
|
|
160
|
+
? [...new Set(Object.values(accounts?.accounts ?? {}).map((account) => account.kind))]
|
|
161
|
+
: Object.keys(preferences.accountByMachine[scopeId] ?? {});
|
|
162
|
+
|
|
163
|
+
const picks = kinds.flatMap((provider) => {
|
|
164
|
+
const account = ordered
|
|
165
|
+
? accounts
|
|
166
|
+
? topAccountOf(accounts.accounts, provider)
|
|
167
|
+
: null
|
|
168
|
+
: accountFor(preferences, scopeId, provider as AgentKind, accounts);
|
|
169
|
+
|
|
170
|
+
return account === null || (ordered && account === provider) ? [] : [[provider, account] as const];
|
|
146
171
|
});
|
|
147
172
|
|
|
148
173
|
return {
|
|
@@ -6,9 +6,9 @@ import { useChats } from '../../state/chats';
|
|
|
6
6
|
import { useChatScope } from '../../scope';
|
|
7
7
|
import { Pill, Tooltip } from '@adecore/ui';
|
|
8
8
|
|
|
9
|
-
function AccountPillOf({ provider, account }: { provider: AgentKind; account: string | undefined }) {
|
|
9
|
+
function AccountPillOf({ chatId, provider, account }: { chatId: string; provider: AgentKind; account: string | undefined }) {
|
|
10
10
|
const { t } = useTranslation('agent-chat');
|
|
11
|
-
const choice = useAccountChoice(provider, account);
|
|
11
|
+
const choice = useAccountChoice(provider, account, chatId);
|
|
12
12
|
|
|
13
13
|
if (choice === null) {
|
|
14
14
|
return null;
|
|
@@ -31,5 +31,5 @@ export function AccountPill({ chatId }: { chatId: string }) {
|
|
|
31
31
|
const provider = useChats((s) => s.statusByKey[keyOf(chatId)]?.info.provider);
|
|
32
32
|
const account = useChats((s) => s.statusByKey[keyOf(chatId)]?.info.account);
|
|
33
33
|
|
|
34
|
-
return provider === undefined ? null : <AccountPillOf provider={provider} account={account} />;
|
|
34
|
+
return provider === undefined ? null : <AccountPillOf chatId={chatId} provider={provider} account={account} />;
|
|
35
35
|
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
1
|
+
import { useState, type ReactNode } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import { useShallow } from 'zustand/shallow';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import { Activity, MessageCircleQuestionMark, Square, SquareTerminal } from 'lucide-react';
|
|
5
|
+
import { Activity, MessageCircleQuestionMark, Square, SquareTerminal, TriangleAlert } from 'lucide-react';
|
|
6
6
|
import type { ChatBackgroundTask, ChatSubagentItem } from '@adecore/agent-contracts';
|
|
7
7
|
import { backgroundCounts } from '../activity';
|
|
8
8
|
import { badgeCountOf, entryTimeOf, flyoutSubagents, progressOf, statusWordOf, subagentTitle, summaryWordOf, taskIdOf, taskRowStateOf } from '../subagent-list';
|
|
9
9
|
import { useSubagentSupport } from '../subagent-support';
|
|
10
|
-
import { canOpenSubagent, crumbOf, openFromMain, useSubagentTrail } from '../subagent-view';
|
|
10
|
+
import { canOpenSubagent, crumbOf, openFromMain, useSubagentTrail, type SubagentStep } from '../subagent-view';
|
|
11
|
+
import { flyoutWorkflows, workflowPillOf, type WorkflowCall, type WorkflowWord } from '../workflow-list';
|
|
11
12
|
import { SubagentStopButton } from './SubagentStopButton';
|
|
13
|
+
import { WorkflowRow } from './rows/WorkflowRow';
|
|
12
14
|
import { formatElapsedShort } from '@adecore/ui/format';
|
|
13
15
|
import { Icon, IconButton, Popover, Surface, useNow } from '@adecore/ui';
|
|
14
16
|
import { useChatRow, useChats } from '../../state/chats';
|
|
@@ -24,14 +26,19 @@ const NO_ITEMS: readonly string[] = [];
|
|
|
24
26
|
|
|
25
27
|
const ROW_BODY = 'flex min-h-9 min-w-0 grow items-center gap-2.5 rounded-md px-2.5 py-1.5 text-left';
|
|
26
28
|
|
|
27
|
-
/*
|
|
28
|
-
|
|
29
|
+
/*
|
|
30
|
+
* What the chat keeps working on beside the thread, in one small line over the composer: its sub-agents,
|
|
31
|
+
* its workflows and what runs in the background. Without `workflows` an app shows them somewhere else.
|
|
32
|
+
*/
|
|
33
|
+
export function ChatActivity({ chatId, workflows: showsWorkflows = true }: { chatId: string; workflows?: boolean }) {
|
|
29
34
|
const host = useChatHost();
|
|
30
35
|
const { t } = useTranslation('agent-chat');
|
|
31
36
|
const order = useChatRow(chatId, (row) => row?.order) ?? NO_ITEMS;
|
|
32
37
|
const before = useChatRow(chatId, (row) => row?.subagentsBefore) ?? NO_ITEMS;
|
|
38
|
+
const workflowsBefore = useChatRow(chatId, (row) => row?.workflowsBefore) ?? NO_ITEMS;
|
|
33
39
|
const structure = useChatRow(chatId, (row) => row?.structure);
|
|
34
40
|
const subagents = structure === undefined ? [] : flyoutSubagents([...before, ...order], structure);
|
|
41
|
+
const workflows = structure === undefined || !showsWorkflows ? [] : flyoutWorkflows([...workflowsBefore, ...order], structure);
|
|
35
42
|
const { id, keyOf } = useChatScope();
|
|
36
43
|
const tasks = useHostTasks(id);
|
|
37
44
|
// The infos of these sub-agents' own chats, so the info of any other chat changing does not draw this again.
|
|
@@ -53,7 +60,7 @@ export function ChatActivity({ chatId }: { chatId: string }) {
|
|
|
53
60
|
|
|
54
61
|
const background = useChatRow(chatId, (row) => row?.info.background) ?? NO_TASKS;
|
|
55
62
|
|
|
56
|
-
if (subagents.length === 0 && background.length === 0) {
|
|
63
|
+
if (subagents.length === 0 && workflows.length === 0 && background.length === 0) {
|
|
57
64
|
return null;
|
|
58
65
|
}
|
|
59
66
|
|
|
@@ -87,6 +94,7 @@ export function ChatActivity({ chatId }: { chatId: string }) {
|
|
|
87
94
|
) : (
|
|
88
95
|
<Slot chatId={chatId} items={subagents} />
|
|
89
96
|
))}
|
|
97
|
+
{workflows.length > 0 && <WorkflowFlyout chatId={chatId} calls={workflows} />}
|
|
90
98
|
{background.length > 0 && (
|
|
91
99
|
<Flyout
|
|
92
100
|
icon={<Icon icon={shells > 0 ? SquareTerminal : Activity} size={14} />}
|
|
@@ -126,6 +134,44 @@ function Flyout({ icon, label, heading = label, children }: { icon: ReactNode; l
|
|
|
126
134
|
);
|
|
127
135
|
}
|
|
128
136
|
|
|
137
|
+
function WorkflowIcon({ word }: { word: WorkflowWord }) {
|
|
138
|
+
return word === 'stalled' ? <Icon icon={TriangleAlert} size={14} className="shrink-0 text-status-needs-you" /> : <StatusIcon word={word} />;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/* The workflows as the thread draws them, each with its phases; opening an agent shows its conversation in the thread's place. */
|
|
142
|
+
function WorkflowFlyout({ chatId, calls }: { chatId: string; calls: readonly WorkflowCall[] }) {
|
|
143
|
+
const { t } = useTranslation('agent-chat');
|
|
144
|
+
const { show } = useSubagentTrail(chatId);
|
|
145
|
+
const [open, setOpen] = useState(false);
|
|
146
|
+
const pill = workflowPillOf(calls);
|
|
147
|
+
|
|
148
|
+
const openAgent = (step: SubagentStep): void => {
|
|
149
|
+
setOpen(false);
|
|
150
|
+
show(openFromMain(step));
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<Popover.Root open={open} onOpenChange={setOpen}>
|
|
155
|
+
<Surface
|
|
156
|
+
render={<Popover.Trigger />}
|
|
157
|
+
className="pointer-events-auto inline-flex h-7.5 max-w-full min-w-0 items-center gap-1.5 rounded-full px-3 text-xs text-text-muted tabular-nums hover:text-text"
|
|
158
|
+
>
|
|
159
|
+
<WorkflowIcon word={pill.word} />
|
|
160
|
+
<span className="truncate">{pill.label}</span>
|
|
161
|
+
{calls.length === 1 && <span className="sr-only">, {t(`rows.workflow.${pill.word}`)}</span>}
|
|
162
|
+
</Surface>
|
|
163
|
+
<Popover.Popup side="top" className="w-96">
|
|
164
|
+
<div className="px-2.5 pt-1.5 pb-1 text-xs text-text-faint">{t('activity.workflows', { count: calls.length })}</div>
|
|
165
|
+
<div className="max-h-96 overflow-auto px-2.5 pb-1.5">
|
|
166
|
+
{calls.map((call) => (
|
|
167
|
+
<WorkflowRow key={call.id} chatId={chatId} tool={call} workflow={call.workflow} onOpenAgent={openAgent} place="flyout" />
|
|
168
|
+
))}
|
|
169
|
+
</div>
|
|
170
|
+
</Popover.Popup>
|
|
171
|
+
</Popover.Root>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
129
175
|
/* One line of a flyout; with `onOpen` the line leads somewhere and closes the flyout on the way. */
|
|
130
176
|
function ActivityRow({
|
|
131
177
|
icon,
|
package/src/chat/ui/Composer.tsx
CHANGED
|
@@ -58,6 +58,8 @@ interface ComposerProps {
|
|
|
58
58
|
disabled: boolean;
|
|
59
59
|
/* Nothing can be written, while the chat's own prompts are still answered here. */
|
|
60
60
|
readOnly?: boolean;
|
|
61
|
+
/* Off where the app shows the chat's workflows somewhere else, such as beside its node. */
|
|
62
|
+
workflowPill?: boolean;
|
|
61
63
|
/* Opened for one CLI from a menu. The model is the remembered one and there is nothing to pick. */
|
|
62
64
|
providerFixed: boolean;
|
|
63
65
|
/* A promise says whether the host took the message, which a send that also opens a new chat waits for. */
|
|
@@ -78,7 +80,18 @@ function sendLabelKey(busy: boolean, steerable: boolean, delivery: 'queue' | 'st
|
|
|
78
80
|
return delivery === 'steer' ? 'composer.steerButton' : 'composer.queueWithSteerButton';
|
|
79
81
|
}
|
|
80
82
|
|
|
81
|
-
export function Composer({
|
|
83
|
+
export function Composer({
|
|
84
|
+
chatId,
|
|
85
|
+
info,
|
|
86
|
+
focused,
|
|
87
|
+
answerPromptsElsewhere,
|
|
88
|
+
disabled,
|
|
89
|
+
readOnly = false,
|
|
90
|
+
workflowPill = true,
|
|
91
|
+
providerFixed,
|
|
92
|
+
onSend,
|
|
93
|
+
onRetarget
|
|
94
|
+
}: ComposerProps) {
|
|
82
95
|
const { t } = useTranslation('agent-chat');
|
|
83
96
|
const host = useChatHost();
|
|
84
97
|
const scope = useChatScope();
|
|
@@ -177,7 +190,10 @@ export function Composer({ chatId, info, focused, answerPromptsElsewhere, disabl
|
|
|
177
190
|
const pending = usePendingRequests(chatId);
|
|
178
191
|
const compactionOffer = useCompactionOffer(chatId, info, capabilities?.compaction);
|
|
179
192
|
const placeholder = useHintedPlaceholder({ chatId, disabled, readOnly, mentionable: capabilities?.mentions !== false, hasSkills: menus.hasSkills });
|
|
180
|
-
const editorExtensions = [
|
|
193
|
+
const editorExtensions = [
|
|
194
|
+
chipDecorations({ mentions: draft.mentions, skills: draft.skills, references: menus.referenceChips, referenceIcon: host.ReferenceIcon }),
|
|
195
|
+
LEAVE_DROPS_TO_THE_CARD
|
|
196
|
+
];
|
|
181
197
|
|
|
182
198
|
/* The timeline owns the scroller; this is the one bit of it the composer needs to know. */
|
|
183
199
|
const atEnd = useSyncExternalStore(
|
|
@@ -237,7 +253,7 @@ export function Composer({ chatId, info, focused, answerPromptsElsewhere, disabl
|
|
|
237
253
|
</Tooltip>
|
|
238
254
|
</div>
|
|
239
255
|
)}
|
|
240
|
-
<ChatActivity chatId={chatId} />
|
|
256
|
+
<ChatActivity chatId={chatId} workflows={workflowPill} />
|
|
241
257
|
<div
|
|
242
258
|
className={clsx(
|
|
243
259
|
'@container/composer pointer-events-auto flex flex-col overflow-hidden rounded-2xl border shadow-float backdrop-blur-[14px] focus-ring-within',
|
|
@@ -81,7 +81,9 @@ function ContinueOn({ chatId, info, choice }: { chatId: string; info: ChatInfo;
|
|
|
81
81
|
const actions = useChatActions();
|
|
82
82
|
const limits = useUsageLimits();
|
|
83
83
|
const [busy, setBusy] = useState(false);
|
|
84
|
-
const targets = continueTargets(choice.accounts, limits, info.provider, info.account)
|
|
84
|
+
const targets = continueTargets(choice.accounts, limits, info.provider, info.account).filter((target) =>
|
|
85
|
+
choice.offered.some((entry) => entry.id === target.id)
|
|
86
|
+
);
|
|
85
87
|
const unread = limits !== null && hasUnreadAccount(choice.accounts, limits, info.provider, info.account);
|
|
86
88
|
|
|
87
89
|
useEffect(() => {
|
|
@@ -201,7 +203,7 @@ export function LimitDock({ chatId, info }: { chatId: string; info: ChatInfo })
|
|
|
201
203
|
const { t } = useTranslation('agent-chat');
|
|
202
204
|
useFormatLocale();
|
|
203
205
|
const now = useNow(MINUTE_MS, info.limit !== undefined);
|
|
204
|
-
const choice = useAccountChoice(info.provider, info.account);
|
|
206
|
+
const choice = useAccountChoice(info.provider, info.account, chatId);
|
|
205
207
|
const view = limitView(info, now);
|
|
206
208
|
|
|
207
209
|
if (view === null) {
|