chore: context tab updates
- Context tab updates with the latest file changes and will not be removed from context when a message is sent
This commit is contained in:
parent
e7d9989931
commit
e384607d24
@ -150,8 +150,6 @@ export default function AIChat({
|
|||||||
false,
|
false,
|
||||||
templateType
|
templateType
|
||||||
)
|
)
|
||||||
// Clear context tabs after sending
|
|
||||||
setContextTabs([])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set context for the chat
|
// Set context for the chat
|
||||||
@ -169,6 +167,22 @@ export default function AIChat({
|
|||||||
addContextTab("code", name, context, range)
|
addContextTab("code", name, context, range)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update context tabs when file contents change
|
||||||
|
useEffect(() => {
|
||||||
|
setContextTabs((prevTabs) =>
|
||||||
|
prevTabs.map((tab) => {
|
||||||
|
if (tab.type === "file" && tab.name === activeFileName) {
|
||||||
|
const fileExt = tab.name.split(".").pop() || "txt"
|
||||||
|
return {
|
||||||
|
...tab,
|
||||||
|
content: `\`\`\`${fileExt}\n${activeFileContent}\n\`\`\``
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tab
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}, [activeFileContent, activeFileName])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col h-screen w-full">
|
<div className="flex flex-col h-screen w-full">
|
||||||
<div className="flex justify-between items-center p-2 border-b">
|
<div className="flex justify-between items-center p-2 border-b">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user