Skip to content

Commit

Permalink
updated file list rootFolder title for single files.
Browse files Browse the repository at this point in the history
  • Loading branch information
dogusata committed Apr 30, 2024
1 parent 7584bb6 commit 0f8d59b
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 44 deletions.
42 changes: 4 additions & 38 deletions example/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down Expand Up @@ -447,15 +446,15 @@ export const createMynahUI = (initialData?: MynahUIDataModel): MynahUI => {
);
};

const getGenerativeAIAnswer = (tabId: string): void => {
const getGenerativeAIAnswer = (tabId: string, optionalParts?: Partial<ChatItem>[]): void => {
const messageId = new Date().getTime().toString();
mynahUI.updateStore(tabId, {
loadingChat: true,
promptInputDisabledState: true,
});
connector
.requestGenerativeAIAnswer(
exampleStreamParts,
optionalParts ?? exampleStreamParts,
(chatItem: Partial<ChatItem>) => {
if (streamingMessageId != null) {
mynahUI.updateChatAnswerWithMessageId(tabId, streamingMessageId, chatItem);
Expand Down Expand Up @@ -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<ChatItem>) => {
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;
Expand Down
15 changes: 10 additions & 5 deletions example/src/samples/sample-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -55,10 +58,12 @@ export const exampleSources = [
},
] as SourceLink[];

export const sampleMarkdownList: ChatItem = {
type: ChatItemType.ANSWER,
body: `${sampleList as string}`
};
export const sampleMarkdownList: Partial<ChatItem>[] = [
{ body: `${sampleList0 as string}`},
{ body: `${sampleList1 as string}`},
{ body: `${sampleList2 as string}`},
{ body: `${sampleList3 as string}`},
];

export const exampleStreamParts: Partial<ChatItem>[] = [
{ body: `${md0 as string}` },
Expand Down
6 changes: 6 additions & 0 deletions example/src/samples/sample-list-0.md
Original file line number Diff line number Diff line change
@@ -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.
13 changes: 13 additions & 0 deletions example/src/samples/sample-list-1.md
Original file line number Diff line number Diff line change
@@ -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.
19 changes: 19 additions & 0 deletions example/src/samples/sample-list-2.md
Original file line number Diff line number Diff line change
@@ -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.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/components/chat-item/chat-item-tree-view-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down

0 comments on commit 0f8d59b

Please sign in to comment.