resolve conflicts

This commit is contained in:
w1gs 2024-09-21 07:46:19 -04:00
parent afa24231e6
commit bc027b2fca

View file

@ -46,8 +46,8 @@ const userInstructionsStr = (
${filesStr(files)}
${!selection
? ""
: `
? ""
: `
I am currently selecting this code:
\`\`\`${selection.selectionStr}\`\`\`
`
@ -62,35 +62,39 @@ If you make a change, rewrite the entire file.
const FilesSelector = ({ files, setFiles }: { files: vscode.Uri[], setFiles: (files: vscode.Uri[]) => void }) => {
return files.length !== 0 && <div className='my-2'>
Include files:
{files.map((filename, i) =>
<div key={i} className='flex'>
{/* X button on a file */}
<button type='button' onClick={() => {
let file_index = files.indexOf(filename)
setFiles([...files.slice(0, file_index), ...files.slice(file_index + 1, Infinity)])
}}>
-{' '}<span className='text-gray-500'>{getBasename(filename.fsPath)}</span>
</button>
</div>
)
return files.length !== 0 && (
<div className='my-2'>
Include files:
{files.map((filename, i) =>
<div key={i} className='flex'>
{/* X button on a file */}
<button type='button' onClick={() => {
let file_index = files.indexOf(filename)
setFiles([...files.slice(0, file_index), ...files.slice(file_index + 1, Infinity)])
}}>
-{' '}<span className='text-gray-500'>{getBasename(filename.fsPath)}</span>
</button>
</div>
)}
</div>
);
};
}
const IncludedFiles = ({ files }: { files: vscode.Uri[] }) => {
return files.length !== 0 && <div className='text-xs my-2'>
{files.map((filename, i) =>
<div key={i} className='flex'>
<button type='button'
className='btn btn-secondary pointer-events-none'
onClick={() => {
// TODO redirect to the document filename.fsPath, when add this remove pointer-events-none
return files.length !== 0 && (
<div className='text-xs my-2'>
{files.map((filename, i) =>
<div key={i} className='flex'>
<button type='button'
className='btn btn-secondary pointer-events-none'
onClick={() => {
// TODO redirect to the document filename.fsPath, when add this remove pointer-events-none
}}>
-{' '}<span className='text-gray-100'>{getBasename(filename.fsPath)}</span>
</button>
</div>
)
-{' '}<span className='text-gray-100'>{getBasename(filename.fsPath)}</span>
</button>
</div>
)}
</div>
);
};
@ -120,9 +124,11 @@ const ChatBubble = ({ chatMessage }: { chatMessage: ChatMessage }) => {
chatbubbleContents = <MarkdownRender tokens={tokens} />; // sectionsHTML
}
return <div className={`${role === 'user' ? 'text-right' : 'text-left'}`}>
<div className={`inline-block p-2 rounded-lg space-y-2 ${role === 'user' ? 'bg-vscode-input-bg text-vscode-input-fg' : ''} max-w-full`}>
{chatbubbleContents}
return (
<div className={`${role === 'user' ? 'text-right' : 'text-left'}`}>
<div className={`inline-block p-2 rounded-lg space-y-2 ${role === 'user' ? 'bg-vscode-input-bg text-vscode-input-fg' : ''} max-w-full`}>
{chatbubbleContents}
</div>
</div>
);
};
@ -174,7 +180,6 @@ const Sidebar = () => {
const [isDisabled, setIsDisabled] = useState(false);
const [errorShown, setErrorShown] = useState(false);
const abortFnRef = useRef<(() => void) | null>(null);
const [apiConfig, setApiConfig] = useState<ApiConfig | null>(null);
@ -192,7 +197,6 @@ const Sidebar = () => {
} else {
setIsDisabled(false);
}
}
// get Api Config on mount
@ -332,7 +336,6 @@ const Sidebar = () => {
<>
<div
className={`flex flex-col h-screen w-full ${isDisabled ? 'no-select' : ''}`}
>
<div className="overflow-y-auto overflow-x-hidden space-y-4">
{/* previous messages */}
@ -383,7 +386,6 @@ const Sidebar = () => {
}}
>
{/* input */}
<textarea
onChange={(e) => {
setInstructions(e.target.value);
@ -431,46 +433,9 @@ const Sidebar = () => {
)}
</form>
</div>
{isDisabled && (
<div className="absolute top-0 left-0 w-full h-full bg-gray-500 opacity-10 pointer-events-none" />
)}
<form
ref={formRef}
className="flex flex-row items-center rounded-md p-2 input"
onKeyDown={(e) => { if (e.key === 'Enter' && !e.shiftKey) onSubmit(e) }}
onSubmit={(e) => {
console.log('submit!')
e.preventDefault();
onSubmit(e)
}}>
<textarea
onChange={(e) => { setInstructions(e.target.value) }}
className="w-full p-2 leading-tight resize-none max-h-[50vh] overflow-hidden bg-transparent border-none !outline-none"
placeholder="Ctrl+L to select"
rows={1}
onInput={e => { e.currentTarget.style.height = 'auto'; e.currentTarget.style.height = e.currentTarget.scrollHeight + 'px' }} // Adjust height dynamically
/>
{isLoading ?
<button
onClick={onStop}
className="btn btn-primary rounded-r-lg max-h-10 p-2"
type='button'
>Stop</button>
: <button
className="btn btn-primary font-bold size-8 flex justify-center items-center rounded-full p-2 max-h-10"
disabled={!instructions}
type='submit'
>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
<line x1="12" y1="19" x2="12" y2="5"></line>
<polyline points="5 12 12 5 19 12"></polyline>
</svg>
</button>
}
</form>
</div>
</>
);