Skip to content

Commit 023480d

Browse files
committed
msg: working-partially;
- Added chat=wrapper support to handle title - Should ideally be controller but no title property in chatMessage
1 parent 0c482da commit 023480d

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

src/components/chat-item/chat-wrapper.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,13 @@ export class ChatWrapper {
5454
private lastStreamingChatItemCard: ChatItemCard | null;
5555
private lastStreamingChatItemMessageId: string | null;
5656
private allRenderedChatItems: Record<string, ChatItemCard> = {};
57+
private allRenderedModifiedFileChatItems: Record<string, ChatItem> = {};
5758
render: ExtendedHTMLElement;
5859
private readonly dragOverlayContent: HTMLElement;
5960
private readonly dragBlurOverlay: HTMLElement;
6061
private dragOverlayVisibility: boolean = true;
6162
private imageContextFeatureEnabled: boolean = false;
62-
private readonly modifiedFilesTracker: ModifiedFilesTracker;
63+
private modifiedFilesTracker: ModifiedFilesTracker;
6364

6465
constructor (props: ChatWrapperProps) {
6566
StyleLoader.getInstance().load('components/chat/_chat-wrapper.scss');
@@ -392,6 +393,18 @@ export class ChatWrapper {
392393
// Check if messageId contains "modified-files-" prefix
393394
if (chatItem.messageId != null && chatItem.messageId !== '' && chatItem.messageId.includes('modified-files-')) {
394395
// Forward only to ModifiedFilesTracker, skip normal flow
396+
if (chatItem.fileList !== null) {
397+
this.allRenderedModifiedFileChatItems[chatItem.messageId] = chatItem;
398+
const size = Object.keys(this.allRenderedModifiedFileChatItems).length;
399+
chatItem.title = size === 1 ? '1 file modified!' : `${size} files modified!`;
400+
} else if (chatItem.fileList === null || chatItem.fileList === undefined) {
401+
// This will mean that it is reset signal i.e. new chat;
402+
// Ideally should be sent through controller
403+
chatItem.title = 'working ...';
404+
// remove all items from allRenderedModifiedFileChatItems
405+
this.allRenderedModifiedFileChatItems = {};
406+
this.modifiedFilesTracker = new ModifiedFilesTracker({ tabId: this.props.tabId });
407+
}
395408
this.modifiedFilesTracker.addChatItem(chatItem);
396409
return;
397410
}

src/components/modified-files-tracker.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@ export class ModifiedFilesTracker {
4646
type: 'div',
4747
classNames: [ 'mynah-modified-files-tracker-wrapper' ],
4848
testId: testIds.modifiedFilesTracker.container,
49-
children: [ this.collapsibleContent.render ],
50-
attributes: {
51-
style: 'display: block !important; visibility: visible !important;'
52-
}
49+
children: [ this.collapsibleContent.render ]
5350
});
5451

5552
console.log('[ModifiedFilesTracker] Render element created:', this.render);
@@ -160,7 +157,16 @@ export class ModifiedFilesTracker {
160157
return messageId.startsWith('modified-files-') ? messageId.replace('modified-files-', '') : messageId;
161158
}
162159

160+
private updateTitleText (chatItem: ChatItem): void {
161+
// check if chatItem
162+
if (chatItem.title !== undefined && chatItem.title !== '') {
163+
this.titleText = chatItem.title;
164+
this.collapsibleContent.updateTitle(this.titleText);
165+
}
166+
}
167+
163168
public addChatItem (chatItem: ChatItem): void {
169+
this.updateTitleText(chatItem);
164170
if (chatItem.header?.fileList != null) {
165171
// Store the current chatItem for button handling
166172
this.props.chatItem = chatItem;

0 commit comments

Comments
 (0)