Skip to content

Commit cd11065

Browse files
committed
msg: working-partially;
- Added session functionality for every new chat the modified files are getting cleared
1 parent 023480d commit cd11065

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class ChatWrapper {
6060
private readonly dragBlurOverlay: HTMLElement;
6161
private dragOverlayVisibility: boolean = true;
6262
private imageContextFeatureEnabled: boolean = false;
63-
private modifiedFilesTracker: ModifiedFilesTracker;
63+
private readonly modifiedFilesTracker: ModifiedFilesTracker;
6464

6565
constructor (props: ChatWrapperProps) {
6666
StyleLoader.getInstance().load('components/chat/_chat-wrapper.scss');
@@ -393,18 +393,13 @@ export class ChatWrapper {
393393
// Check if messageId contains "modified-files-" prefix
394394
if (chatItem.messageId != null && chatItem.messageId !== '' && chatItem.messageId.includes('modified-files-')) {
395395
// Forward only to ModifiedFilesTracker, skip normal flow
396-
if (chatItem.fileList !== null) {
396+
if (chatItem.header?.fileList !== null && chatItem.header?.fileList !== undefined) {
397397
this.allRenderedModifiedFileChatItems[chatItem.messageId] = chatItem;
398398
const size = Object.keys(this.allRenderedModifiedFileChatItems).length;
399399
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 });
407400
}
401+
// else clear the component and render empty
402+
// previous implementation was not working; Need a fix
408403
this.modifiedFilesTracker.addChatItem(chatItem);
409404
return;
410405
}
@@ -440,6 +435,9 @@ export class ChatWrapper {
440435
this.allRenderedChatItems[currentMessageId] = chatItemCard;
441436

442437
if (chatItem.type === ChatItemType.PROMPT || chatItem.type === ChatItemType.SYSTEM_PROMPT) {
438+
// Clear modified files tracker on new prompt
439+
this.allRenderedModifiedFileChatItems = {};
440+
this.modifiedFilesTracker.clear();
443441
// Make sure we align to top when there is a new prompt.
444442
// Only if it is a PROMPT!
445443
// Check css application

src/components/modified-files-tracker.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,15 @@ export class ModifiedFilesTracker {
107107
children: []
108108
});
109109

110+
// Create horizontal container for file and buttons
111+
const horizontalContainer = DomBuilder.getInstance().build({
112+
type: 'div',
113+
classNames: [ 'mynah-modified-files-horizontal-container' ],
114+
children: []
115+
});
116+
110117
// Render the file tree for single file
111-
singleFileWrapper.appendChild(new ChatItemTreeViewWrapper({
118+
const fileTreeWrapper = new ChatItemTreeViewWrapper({
112119
tabId: this.props.tabId,
113120
messageId: this.getOriginalMessageId(messageId),
114121
files: [ filePath ],
@@ -123,7 +130,8 @@ export class ModifiedFilesTracker {
123130
referenceSuggestionLabel: '',
124131
references: [],
125132
onRootCollapsedStateChange: () => {}
126-
}).render);
133+
});
134+
horizontalContainer.appendChild(fileTreeWrapper.render);
127135

128136
// Add buttons for this specific file if they exist
129137
if (this.props.chatItem?.buttons != null && Array.isArray(this.props.chatItem.buttons) && this.props.chatItem.buttons.length > 0) {
@@ -142,9 +150,10 @@ export class ModifiedFilesTracker {
142150
});
143151
}
144152
});
145-
singleFileWrapper.appendChild(buttonsWrapper.render);
153+
horizontalContainer.appendChild(buttonsWrapper.render);
146154
}
147155

156+
singleFileWrapper.appendChild(horizontalContainer);
148157
fileGroupWrapper.appendChild(singleFileWrapper);
149158
});
150159

@@ -174,6 +183,13 @@ export class ModifiedFilesTracker {
174183
}
175184
}
176185

186+
public clear (): void {
187+
this.allFiles.clear();
188+
this.titleText = 'No files modified!';
189+
this.collapsibleContent.updateTitle(this.titleText);
190+
this.renderModifiedFiles(null);
191+
}
192+
177193
public setVisible (visible: boolean): void {
178194
// No-op: component is always visible
179195
}

0 commit comments

Comments
 (0)