Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
150 commits
Select commit Hold shift + click to select a range
40636a0
feat(ui-components): introduce chat components
FabienMotte Jul 23, 2025
6f1ed20
chore: add passphrase input
FabienMotte Jul 23, 2025
0b70363
wip
Haroenv Jul 30, 2025
78ed732
toggle and header part of satellite
Haroenv Aug 1, 2025
62880e9
revert js example
shaejaz Sep 3, 2025
9f83bde
revert react example
shaejaz Sep 3, 2025
13b1e28
remove todo
shaejaz Sep 3, 2025
556c1d0
remove toggle button duplicate
shaejaz Sep 3, 2025
5d2e92b
add tests
shaejaz Sep 3, 2025
6ceffff
update bundlesize
shaejaz Sep 3, 2025
dd12b04
fix lint
shaejaz Sep 3, 2025
b095c41
Merge branch 'master' into feat/chat-components
shaejaz Sep 4, 2025
040c035
markdown
Haroenv Aug 29, 2025
8adc9ef
add chat component
shaejaz Sep 4, 2025
4b2531e
update chat message
shaejaz Sep 4, 2025
deb8c8a
fix polyfill errors
shaejaz Sep 4, 2025
5ca5ec2
update lock file
shaejaz Sep 4, 2025
000f255
add chat test
shaejaz Sep 4, 2025
adf7f8f
address comments
shaejaz Sep 4, 2025
95a463e
address comments
shaejaz Sep 5, 2025
032cd1d
add base lib in is.js
shaejaz Sep 5, 2025
c978854
add hook in react core
shaejaz Sep 5, 2025
51f350f
add react widget
shaejaz Sep 5, 2025
c2df1ac
move transport handling to hook
shaejaz Sep 5, 2025
205ab67
update types
shaejaz Sep 8, 2025
2c7406e
export it anyway
Haroenv Sep 8, 2025
8b26037
add chat component props
shaejaz Sep 8, 2025
88cf87d
add refine button
shaejaz Sep 8, 2025
69ab089
address comment
shaejaz Sep 8, 2025
5cc91f7
add tests
shaejaz Sep 9, 2025
2609211
update tools usage
shaejaz Sep 10, 2025
09e8b51
fix ci
shaejaz Sep 10, 2025
e5e5259
fix type error
shaejaz Sep 10, 2025
e71e483
address comments
shaejaz Sep 10, 2025
9041a1a
Merge branch 'master' into feat/react-chat
shaejaz Sep 10, 2025
2229762
fix is version
shaejaz Sep 10, 2025
bfc6b25
just one zod
Haroenv Sep 10, 2025
1dd7a0a
add more tests
shaejaz Sep 11, 2025
729f629
use user provided search index tool
shaejaz Sep 11, 2025
1ba802f
update user default tools logic
shaejaz Sep 11, 2025
5e0c14d
init
shaejaz Sep 15, 2025
35b5d65
don't rerender in connector
shaejaz Sep 15, 2025
f99adbc
add tools support
shaejaz Sep 16, 2025
a839a11
move open and input to connector
shaejaz Sep 16, 2025
50e9d08
fix vue build
shaejaz Sep 16, 2025
c3901e0
fix build fr
shaejaz Sep 16, 2025
678e292
init
shaejaz Aug 13, 2025
52ea485
remove stick to bottom hook
shaejaz Aug 13, 2025
989b274
move ui to ui components
shaejaz Aug 13, 2025
93d7756
add chat components
shaejaz Aug 14, 2025
f5b06d3
fix widget types
shaejaz Aug 15, 2025
3fea3b3
forward props
shaejaz Aug 18, 2025
e82095a
wip: use ai dependency in connector
Haroenv Aug 18, 2025
e219a32
move usechat to react core
shaejaz Aug 19, 2025
c136118
remove is components and widgets
shaejaz Aug 19, 2025
ad39f22
remove unecessary react widgets
shaejaz Aug 19, 2025
84b919c
fix test
shaejaz Aug 20, 2025
3b1b853
deps
Haroenv Aug 20, 2025
527a280
revert rollup alias
shaejaz Aug 20, 2025
38c0d1c
init
shaejaz Aug 28, 2025
373ce70
use carousel
shaejaz Aug 29, 2025
a39aece
add tools prop
shaejaz Sep 2, 2025
3473921
add carousel default tool
shaejaz Sep 2, 2025
bfc6910
add transport to props
shaejaz Sep 2, 2025
d79465c
feat(react-instantsearch-ui): implement chat components design
FabienMotte Sep 11, 2025
5cd47c9
chore: review considered
FabienMotte Sep 15, 2025
72375c6
chore: review considered
FabienMotte Sep 16, 2025
5da6059
remove
FabienMotte Sep 16, 2025
692b1d0
chore: review considered
FabienMotte Sep 16, 2025
3ddfcde
chore: review considered
FabienMotte Sep 16, 2025
37ecdbd
chore: revert lock
FabienMotte Sep 16, 2025
1b4c24f
chore: clean types
FabienMotte Sep 17, 2025
a493c5d
chore: fix types
FabienMotte Sep 17, 2025
33da4d5
chore: clean comments
FabienMotte Sep 17, 2025
f525f0a
update tool logic
shaejaz Sep 17, 2025
e83ff45
chore: fix conflicts
FabienMotte Sep 18, 2025
002ce28
feat: add clear button
FabienMotte Sep 18, 2025
69eecf6
feat: add default chat prompt disclaimer
FabienMotte Sep 18, 2025
6d392a5
chore: revert
FabienMotte Sep 18, 2025
3580993
chore: use polyfills
FabienMotte Sep 18, 2025
d7fc569
chore: revert
FabienMotte Sep 18, 2025
c59e143
chore: revert
FabienMotte Sep 18, 2025
20d493f
feat: add header/prompt gradients
FabienMotte Sep 18, 2025
502b042
fix type and tool name check
shaejaz Sep 18, 2025
04290cd
fix lint
shaejaz Sep 18, 2025
8ef5bff
fix: chat prompt gradient z-index
FabienMotte Sep 18, 2025
39dfe62
refactor: move `use-stick-to-bottom` to Chat widget
FabienMotte Sep 18, 2025
f28a8c5
Merge branch 'feat/js-chat' into feat/chat-tools
shaejaz Sep 18, 2025
f17db28
chore: add `useStickToBottom` hook instead of lib
FabienMotte Sep 18, 2025
87851d2
fix: mobile fixes
FabienMotte Sep 18, 2025
37656d9
chore: update bundlesizes
FabienMotte Sep 18, 2025
daf1409
Merge master into feat/chat-design
FabienMotte Sep 18, 2025
fbafb54
test: fix
FabienMotte Sep 19, 2025
85332c0
test: fix lint
FabienMotte Sep 19, 2025
1808886
init
shaejaz Sep 15, 2025
b7da559
don't rerender in connector
shaejaz Sep 15, 2025
f6b3d06
add tools support
shaejaz Sep 16, 2025
cd70c1d
move open and input to connector
shaejaz Sep 16, 2025
00a3b18
fix vue build
shaejaz Sep 16, 2025
d5ec6c4
fix build fr
shaejaz Sep 16, 2025
49e4d4f
fine-tune connector implementation
dhayab Sep 17, 2025
17c060e
add connector unit tests
dhayab Sep 17, 2025
0bd250f
add connector cts tests
dhayab Sep 17, 2025
19a0f02
fine-tune widget implementation
dhayab Sep 18, 2025
3f7fe7f
add widget unit and cts tests
dhayab Sep 18, 2025
1b0e11a
support maximized and clear in widget
dhayab Sep 19, 2025
9c0143e
add js tool support
shaejaz Sep 19, 2025
43716b2
test: fix
FabienMotte Sep 19, 2025
4ef6e26
Merge branch 'feat/js-chat' into feat/chat-tools
shaejaz Sep 19, 2025
2f1cb7f
fix chat message
shaejaz Sep 19, 2025
14bcc15
Merge remote-tracking branch 'origin/feat/chat-design' into feat/js-chat
dhayab Sep 19, 2025
59f864d
update widget test
dhayab Sep 19, 2025
49d4e22
fix react chat
shaejaz Sep 19, 2025
9b41ae2
Merge branch 'feat/js-chat' into feat/chat-tools
shaejaz Sep 19, 2025
30b75dc
bump bundlesize
dhayab Sep 19, 2025
66e3338
fix tools in js
shaejaz Sep 22, 2025
a86b236
Merge branch 'feat/js-chat' into feat/chat-tools
shaejaz Sep 22, 2025
bfd906b
dont export chat in umd js bundle
dhayab Sep 22, 2025
9842b33
silence issue with invalid ref in preact
dhayab Sep 22, 2025
bbda654
fix lint issues
dhayab Sep 22, 2025
b9443a4
more fixes?
dhayab Sep 22, 2025
3ca11da
take 3
dhayab Sep 23, 2025
209fd1c
Merge remote-tracking branch 'origin/master' into feat/js-chat
dhayab Sep 23, 2025
8b37701
post-merge fixes
dhayab Sep 23, 2025
3f656f1
delete remnant files
dhayab Sep 23, 2025
1ba3d74
additional post-merge fixes
dhayab Sep 23, 2025
894af6c
bump bundlesize
dhayab Sep 23, 2025
1633771
fix lint
shaejaz Sep 23, 2025
481d915
Merge branch 'feat/js-chat' into feat/chat-tools
shaejaz Sep 23, 2025
e384874
readjust bundlesize
dhayab Sep 23, 2025
85fae59
Merge remote-tracking branch 'origin/master' into feat/js-chat
dhayab Sep 23, 2025
d7329c3
Merge branch 'feat/js-chat' into feat/chat-tools
shaejaz Sep 23, 2025
4c2a634
Merge branch 'master' into feat/chat-tools
shaejaz Sep 24, 2025
e2108a9
update rollup
shaejaz Sep 24, 2025
96778ab
add new jsdom jest env
shaejaz Sep 24, 2025
49bb25d
add tool common tests
shaejaz Sep 24, 2025
b15e13b
add new jsdom jest env
shaejaz Sep 24, 2025
9986e9c
update all jsdom usage
shaejaz Sep 24, 2025
4a2b81e
fix lint
shaejaz Sep 24, 2025
76b4b2a
update all envs
shaejaz Sep 24, 2025
5815ce3
update snapshots
shaejaz Sep 24, 2025
29cdefe
update jsdom global
shaejaz Sep 24, 2025
100add3
use ts in env config
shaejaz Sep 24, 2025
c849b4a
Merge branch 'master' into feat/fixed-jsdom
shaejaz Sep 24, 2025
2d872ff
set to default env
shaejaz Sep 24, 2025
bc49da6
Merge branch 'feat/fixed-jsdom' into feat/chat-tools
shaejaz Sep 24, 2025
9287335
Merge branch 'master' into feat/chat-tools
shaejaz Sep 25, 2025
783cb63
rename tool type
shaejaz Sep 25, 2025
c951d4f
remove external from rollup
shaejaz Sep 25, 2025
e4c706a
address comment
shaejaz Sep 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { MenuIconComponent } from './icons';

import type { ComponentProps, Renderer } from '../../types';
import type {
AddToolResult,
ChatInit,
AddToolResultWithOutput,
ChatMessageBase,
ChatToolMessage,
ClientSideTool,
} from './types';

export type ChatMessageSide = 'left' | 'right';
Expand Down Expand Up @@ -77,21 +77,6 @@ export type ChatMessageActionProps = {
onClick?: (message: ChatMessageBase) => void;
};

export type Tools = Array<{
type: string;
component: (props: {
message: ChatToolMessage;
indexUiState: object;
setIndexUiState: (state: object) => void;
}) => JSX.Element;
onToolCall: (params: {
toolCall: Parameters<
NonNullable<ChatInit<ChatMessageBase>['onToolCall']>
>[0]['toolCall'];
addToolResult: AddToolResult;
}) => void;
}>;

export type ChatMessageProps = ComponentProps<'article'> & {
/**
* The message object associated with this chat message
Expand Down Expand Up @@ -138,7 +123,7 @@ export type ChatMessageProps = ComponentProps<'article'> & {
/**
* Array of tools available for the assistant (for tool messages)
*/
tools?: Tools;
tools?: ClientSideTool[];
/**
* Optional handler to refine the search query (for tool actions)
*/
Expand Down Expand Up @@ -216,15 +201,25 @@ export function createChatMessageComponent({ createElement }: Renderer) {
const tool = find(tools, (t) => t.type === part.type);
if (tool) {
const ToolComponent = tool.component;
const toolMessage = part as ChatToolMessage;

const boundAddToolResult: AddToolResultWithOutput = (params) =>
tool.addToolResult?.({
output: params.output,
tool: part.type,
toolCallId: toolMessage.toolCallId,
});

return (
<div
key={`${message.id}-${index}`}
className="ais-ChatMessage-tool"
>
<ToolComponent
message={part as ChatToolMessage}
message={toolMessage}
indexUiState={indexUiState}
setIndexUiState={setIndexUiState}
addToolResult={boundAddToolResult}
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@ import {
} from './icons';

import type { ComponentProps, MutableRef, Renderer } from '../../types';
import type {
ChatMessageProps,
Tools,
ChatMessageActionProps,
} from './ChatMessage';
import type { ChatMessageProps, ChatMessageActionProps } from './ChatMessage';
import type { ChatMessageErrorProps } from './ChatMessageError';
import type { ChatMessageLoaderProps } from './ChatMessageLoader';
import type { ChatMessageBase, ChatStatus } from './types';
import type { ChatMessageBase, ChatStatus, ClientSideTool } from './types';

export type ChatMessagesTranslations = {
/**
Expand Down Expand Up @@ -85,7 +81,7 @@ export type ChatMessagesProps<
/**
* Tools available for the assistant
*/
tools?: Tools;
tools?: ClientSideTool[];
/**
* Current chat status
*/
Expand Down Expand Up @@ -173,7 +169,7 @@ function createDefaultMessageComponent<
assistantMessageProps?: Partial<ChatMessageProps>;
indexUiState: object;
setIndexUiState: (state: object) => void;
tools?: Tools;
tools?: ClientSideTool[];
onReload?: (messageId?: string) => void;
}) {
const defaultAssistantActions: ChatMessageActionProps[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ describe('ChatMessage', () => {
component: ({ message }) => (
<div className="wrapper">{JSON.stringify(message.output)}</div>
),
addToolResult: jest.fn(),
onToolCall: jest.fn(),
},
]}
Expand Down
25 changes: 25 additions & 0 deletions packages/instantsearch-ui-components/src/components/chat/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,31 @@ export type ChatToolMessage = Extract<
ChatMessageBase['parts'][number],
{ type: `tool-${string}` }
>;
export type ChatToolType = ChatToolMessage['type'];

export type { ChatInit } from 'ai';
export type AddToolResult = AbstractChat<UIMessage>['addToolResult'];

export type AddToolResultWithOutput = (
params: Pick<Parameters<AddToolResult>[0], 'output'>
) => ReturnType<AddToolResult>;

export type ClientSideToolComponentProps = {
message: ChatToolMessage;
indexUiState: object;
setIndexUiState: (state: object) => void;
addToolResult: AddToolResultWithOutput;
};

export type ClientSideToolComponent = (
props: ClientSideToolComponentProps
) => JSX.Element;

export type ClientSideTool = {
type: ChatToolType;
component: ClientSideToolComponent;
addToolResult: AddToolResult;
onToolCall?: (params: { addToolResult: AddToolResultWithOutput }) => void;
};

export type UserClientSideTool = Omit<ClientSideTool, 'addToolResult'>;
4 changes: 4 additions & 0 deletions packages/instantsearch.js/src/connectors/chat/connectChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ export default (function connectChat<TWidgetParams extends UnknownWidgetParams>(
};
},

get chatInstance() {
return _chatInstance;
},

dispose() {
unmountFn();
},
Expand Down
1 change: 1 addition & 0 deletions packages/instantsearch.js/src/lib/chat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export type { ChatInit } from './chat';
export { AbstractChat } from './chat';
export { ChatState } from './chat';
export { Chat } from './chat';
export * from './tools';
5 changes: 5 additions & 0 deletions packages/instantsearch.js/src/lib/chat/tools.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { ChatToolType } from 'instantsearch-ui-components';

export const SearchIndexToolType: ChatToolType = 'tool-algolia_search_index';

export const defaultTools: ChatToolType[] = [SearchIndexToolType];
Loading