|
1 | | -import { MynahIconsType, MynahUI, DetailedListItem, DetailedListItemGroup, MynahIcons } from '@aws/mynah-ui' |
| 1 | +import { |
| 2 | + MynahIconsType, |
| 3 | + MynahUI, |
| 4 | + DetailedListItem, |
| 5 | + DetailedListItemGroup, |
| 6 | + MynahIcons, |
| 7 | + NotificationType, |
| 8 | +} from '@aws/mynah-ui' |
2 | 9 | import { Messager } from '../messager' |
3 | 10 | import { ListRulesResult } from '@aws/language-server-runtimes-types' |
4 | 11 | import { RulesFolder } from '@aws/language-server-runtimes-types' |
@@ -82,14 +89,38 @@ export class RulesList { |
82 | 89 | // Close the rules list first |
83 | 90 | this.rulesList?.close() |
84 | 91 |
|
85 | | - // Use the current tab, the tabId should be the same as the one used for the rules list |
86 | | - this.messager.onChatPrompt({ |
87 | | - prompt: { |
88 | | - prompt: 'Generate a Memory Bank for this project', |
89 | | - escapedPrompt: 'Generate a Memory Bank for this project', |
90 | | - }, |
91 | | - tabId: this.tabId, |
92 | | - }) |
| 92 | + // Check if we're at the tab limit (10 tabs max) |
| 93 | + const currentTabCount = Object.keys(this.mynahUi.getAllTabs()).length |
| 94 | + if (currentTabCount >= 10) { |
| 95 | + // Show notification that max tabs reached |
| 96 | + this.mynahUi.notify({ |
| 97 | + content: 'You can only open ten conversation tabs at a time.', |
| 98 | + type: NotificationType.WARNING, |
| 99 | + }) |
| 100 | + return |
| 101 | + } |
| 102 | + |
| 103 | + // Create a new tab for the memory bank generation |
| 104 | + const newTabId = this.mynahUi.updateStore('', { tabTitle: 'Memory Bank' }) |
| 105 | + if (newTabId) { |
| 106 | + // Add the new tab and switch to it |
| 107 | + this.messager.onTabAdd(newTabId) |
| 108 | + |
| 109 | + // Send the chat prompt to the new tab |
| 110 | + this.messager.onChatPrompt({ |
| 111 | + prompt: { |
| 112 | + prompt: 'Generate a Memory Bank for this project', |
| 113 | + escapedPrompt: 'Generate a Memory Bank for this project', |
| 114 | + }, |
| 115 | + tabId: newTabId, |
| 116 | + }) |
| 117 | + } else { |
| 118 | + // Show error notification if tab creation failed |
| 119 | + this.mynahUi.notify({ |
| 120 | + content: 'Failed to create new tab for Memory Bank generation.', |
| 121 | + type: NotificationType.ERROR, |
| 122 | + }) |
| 123 | + } |
93 | 124 | } |
94 | 125 |
|
95 | 126 | showLoading(tabId: string) { |
|
0 commit comments