From 0f8d59bc50016387640939f0e555a133859fd3ec Mon Sep 17 00:00:00 2001 From: Dogus Atasoy Date: Tue, 30 Apr 2024 08:52:34 +0200 Subject: [PATCH] updated file list rootFolder title for single files. --- example/src/main.ts | 42 ++----------------- example/src/samples/sample-data.ts | 15 ++++--- example/src/samples/sample-list-0.md | 6 +++ example/src/samples/sample-list-1.md | 13 ++++++ example/src/samples/sample-list-2.md | 19 +++++++++ .../{sample-list.md => sample-list-3.md} | 0 .../chat-item/chat-item-tree-view-wrapper.ts | 2 +- 7 files changed, 53 insertions(+), 44 deletions(-) create mode 100644 example/src/samples/sample-list-0.md create mode 100644 example/src/samples/sample-list-1.md create mode 100644 example/src/samples/sample-list-2.md rename example/src/samples/{sample-list.md => sample-list-3.md} (100%) diff --git a/example/src/main.ts b/example/src/main.ts index aff5156..ccdd4a0 100644 --- a/example/src/main.ts +++ b/example/src/main.ts @@ -277,11 +277,10 @@ export const createMynahUI = (initialData?: MynahUIDataModel): MynahUI => { mynahUI.addChatItem(tabId, defaultFollowUps); break; case Commands.CARD_WITH_MARKDOWN_LIST: - mynahUI.addChatItem(tabId, sampleMarkdownList); - mynahUI.addChatItem(tabId, defaultFollowUps); + getGenerativeAIAnswer(tabId, sampleMarkdownList); break; case Commands.PROGRESSIVE_CARD: - getProgressingCard(tabId); + getGenerativeAIAnswer(tabId, exampleProgressCards); break; case Commands.STATUS_CARDS: mynahUI.addChatItem(tabId, { @@ -447,7 +446,7 @@ export const createMynahUI = (initialData?: MynahUIDataModel): MynahUI => { ); }; - const getGenerativeAIAnswer = (tabId: string): void => { + const getGenerativeAIAnswer = (tabId: string, optionalParts?: Partial[]): void => { const messageId = new Date().getTime().toString(); mynahUI.updateStore(tabId, { loadingChat: true, @@ -455,7 +454,7 @@ export const createMynahUI = (initialData?: MynahUIDataModel): MynahUI => { }); connector .requestGenerativeAIAnswer( - exampleStreamParts, + optionalParts ?? exampleStreamParts, (chatItem: Partial) => { if (streamingMessageId != null) { mynahUI.updateChatAnswerWithMessageId(tabId, streamingMessageId, chatItem); @@ -487,39 +486,6 @@ export const createMynahUI = (initialData?: MynahUIDataModel): MynahUI => { }); }; - const getProgressingCard = (tabId: string): void => { - const messageId = new Date().getTime().toString(); - mynahUI.updateStore(tabId, { - loadingChat: true, - promptInputDisabledState: true, - }); - connector - .requestGenerativeAIAnswer( - exampleProgressCards, - (chatItem: Partial) => { - mynahUI.updateChatAnswerWithMessageId(tabId, messageId, chatItem); - return false; - }, - () => { - mynahUI.updateStore(tabId, { - loadingChat: false, - promptInputDisabledState: false, - }); - mynahUI.notify({ - content: 'Your refactor request is finished', - }); - mynahUI.addChatItem(tabId, defaultFollowUps); - } - ) - .then(() => { - mynahUI.addChatItem(tabId, { - type: ChatItemType.ANSWER_STREAM, - body: '', - messageId, - }); - }); - }; - new ThemeBuilder('#theme-editor'); return mynahUI; diff --git a/example/src/samples/sample-data.ts b/example/src/samples/sample-data.ts index 86ef579..422933a 100644 --- a/example/src/samples/sample-data.ts +++ b/example/src/samples/sample-data.ts @@ -10,7 +10,10 @@ import md7 from './sample-7.md'; import md8 from './sample-8.md'; import md9 from './sample-9.md'; import md10 from './sample-10.md'; -import sampleList from './sample-list.md'; +import sampleList0 from './sample-list-0.md'; +import sampleList1 from './sample-list-1.md'; +import sampleList2 from './sample-list-2.md'; +import sampleList3 from './sample-list-3.md'; import SampleCode from './sample-code.md'; import { Commands } from '../commands'; @@ -55,10 +58,12 @@ export const exampleSources = [ }, ] as SourceLink[]; -export const sampleMarkdownList: ChatItem = { - type: ChatItemType.ANSWER, - body: `${sampleList as string}` -}; +export const sampleMarkdownList: Partial[] = [ + { body: `${sampleList0 as string}`}, + { body: `${sampleList1 as string}`}, + { body: `${sampleList2 as string}`}, + { body: `${sampleList3 as string}`}, +]; export const exampleStreamParts: Partial[] = [ { body: `${md0 as string}` }, diff --git a/example/src/samples/sample-list-0.md b/example/src/samples/sample-list-0.md new file mode 100644 index 0000000..ecb20e7 --- /dev/null +++ b/example/src/samples/sample-list-0.md @@ -0,0 +1,6 @@ +This is a list below with some code and bolds inside + +- **Bold** Text with some `inline code`. +- Also with some code blocks ```const a = 5;``` + +End of the list. \ No newline at end of file diff --git a/example/src/samples/sample-list-1.md b/example/src/samples/sample-list-1.md new file mode 100644 index 0000000..8a04609 --- /dev/null +++ b/example/src/samples/sample-list-1.md @@ -0,0 +1,13 @@ +This is a list below with some code and bolds inside + +- **Bold** Text with some `inline code`. +- Also with some code blocks ```const a = 5;``` + +End of the list. + +Certainly, here's an example of a Markdown list where each item has a bold text word: + +* **Item1** This is the first list item. +* **Item2** This is the second list item. +* **Item3** This is the third list item. +* **Item4** This is the fourth list item. And it also has a [LINK](#) inside. \ No newline at end of file diff --git a/example/src/samples/sample-list-2.md b/example/src/samples/sample-list-2.md new file mode 100644 index 0000000..d176c76 --- /dev/null +++ b/example/src/samples/sample-list-2.md @@ -0,0 +1,19 @@ +This is a list below with some code and bolds inside + +- **Bold** Text with some `inline code`. +- Also with some code blocks ```const a = 5;``` + +End of the list. + +Certainly, here's an example of a Markdown list where each item has a bold text word: + +* **Item1** This is the first list item. +* **Item2** This is the second list item. +* **Item3** This is the third list item. +* **Item4** This is the fourth list item. And it also has a [LINK](#) inside. + +List with numbers. +1. **Item1** This is the first list item. +2. **Item2** This is the second list item. +3. **Item3** This is the third list item. +4. **Item4** This is the fourth list item. And it also has a [LINK](#) inside. \ No newline at end of file diff --git a/example/src/samples/sample-list.md b/example/src/samples/sample-list-3.md similarity index 100% rename from example/src/samples/sample-list.md rename to example/src/samples/sample-list-3.md diff --git a/src/components/chat-item/chat-item-tree-view-wrapper.ts b/src/components/chat-item/chat-item-tree-view-wrapper.ts index cd7c3ec..8f79885 100644 --- a/src/components/chat-item/chat-item-tree-view-wrapper.ts +++ b/src/components/chat-item/chat-item-tree-view-wrapper.ts @@ -34,7 +34,7 @@ export class ChatItemTreeViewWrapper { references: props.references }).render; - const tree = props.files.length === 1 + const tree = props.files.length === 1 && props.rootTitle == null ? new ChatItemTreeFile({ filePath: props.files[0], fileName: props.files[0],