Skip to content

Commit

Permalink
fix: reset chat do not stop ongoing stream
Browse files Browse the repository at this point in the history
  • Loading branch information
rjborba committed Aug 24, 2024
1 parent 0c9256b commit 3f59653
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion apps/storybook/stories/public/orama-search-box.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default meta

const Template = ({ preset, colorScheme }) => {
return html`<orama-search-box
open=${preset?.open}
.open=${preset?.open}
.facetProperty=${preset?.facetProperty}
.resultMap=${preset?.resultMap}
.colorScheme=${colorScheme}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
| `placeholder` | `placeholder` | | `string` | `'Ask me anything'` |
| `showClearChat` | `show-clear-chat` | | `boolean` | `true` |
| `sourceBaseUrl` | `source-base-url` | | `string` | `''` |
| `sourcesMap` | -- | | `{ title?: string; path?: string; description?: string; }` | `undefined` |
| `sourcesMap` | -- | | `{ title?: string; description?: string; path?: string; }` | `undefined` |
| `suggestions` | -- | | `string[]` | `undefined` |


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
| `index` | -- | | `{ api_key: string; endpoint: string; }` | `undefined` |
| `placeholder` | `placeholder` | | `string` | `undefined` |
| `sourceBaseUrl` | `source-base-url` | | `string` | `undefined` |
| `sourcesMap` | -- | | `{ title?: string; path?: string; description?: string; }` | `undefined` |
| `sourcesMap` | -- | | `{ title?: string; description?: string; path?: string; }` | `undefined` |
| `suggestions` | -- | | `string[]` | `undefined` |


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,12 @@ export class SearchBox {

connectedCallback() {
this.windowWidth = windowWidthListener.width
globalContext.open = this.open

globalStore.onChange('open', () => {
this.open = globalContext.open
})

windowWidthListener.addEventListener('widthChange', this.updateWindowWidth)
}

Expand Down
6 changes: 3 additions & 3 deletions packages/ui-stencil/src/components/orama-search-box/readme.md

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions packages/ui-stencil/src/services/ChatService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,15 @@ export class ChatService {
throw new OramaClientNotInitializedError();
}

if (chatContext.interactions.length < 1) {
return;
}

// TODO: SDK should abort any streaming before cleaning the sessions. It is not doing that today
if (['loading', 'rendering', 'streaming'].includes(chatContext.interactions[chatContext.interactions.length - 1].status)) {
this.answerSession.abortAnswer();
}

this.answerSession.clearSession();
};
}

0 comments on commit 3f59653

Please sign in to comment.