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)} ${filesStr(files)}
${!selection ${!selection
? "" ? ""
: ` : `
I am currently selecting this code: I am currently selecting this code:
\`\`\`${selection.selectionStr}\`\`\` \`\`\`${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 }) => { const FilesSelector = ({ files, setFiles }: { files: vscode.Uri[], setFiles: (files: vscode.Uri[]) => void }) => {
return files.length !== 0 && <div className='my-2'> return files.length !== 0 && (
Include files: <div className='my-2'>
{files.map((filename, i) => Include files:
<div key={i} className='flex'> {files.map((filename, i) =>
{/* X button on a file */} <div key={i} className='flex'>
<button type='button' onClick={() => { {/* X button on a file */}
let file_index = files.indexOf(filename) <button type='button' onClick={() => {
setFiles([...files.slice(0, file_index), ...files.slice(file_index + 1, Infinity)]) 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> -{' '}<span className='text-gray-500'>{getBasename(filename.fsPath)}</span>
</div> </button>
) </div>
)}
</div>
); );
}; }
const IncludedFiles = ({ files }: { files: vscode.Uri[] }) => { const IncludedFiles = ({ files }: { files: vscode.Uri[] }) => {
return files.length !== 0 && <div className='text-xs my-2'> return files.length !== 0 && (
{files.map((filename, i) => <div className='text-xs my-2'>
<div key={i} className='flex'> {files.map((filename, i) =>
<button type='button' <div key={i} className='flex'>
className='btn btn-secondary pointer-events-none' <button type='button'
onClick={() => { className='btn btn-secondary pointer-events-none'
// TODO redirect to the document filename.fsPath, when add this remove 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> -{' '}<span className='text-gray-100'>{getBasename(filename.fsPath)}</span>
</button> </button>
</div> </div>
) )}
</div>
); );
}; };
@ -120,9 +124,11 @@ const ChatBubble = ({ chatMessage }: { chatMessage: ChatMessage }) => {
chatbubbleContents = <MarkdownRender tokens={tokens} />; // sectionsHTML chatbubbleContents = <MarkdownRender tokens={tokens} />; // sectionsHTML
} }
return <div className={`${role === 'user' ? 'text-right' : 'text-left'}`}> return (
<div className={`inline-block p-2 rounded-lg space-y-2 ${role === 'user' ? 'bg-vscode-input-bg text-vscode-input-fg' : ''} max-w-full`}> <div className={`${role === 'user' ? 'text-right' : 'text-left'}`}>
{chatbubbleContents} <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> </div>
); );
}; };
@ -174,7 +180,6 @@ const Sidebar = () => {
const [isDisabled, setIsDisabled] = useState(false); const [isDisabled, setIsDisabled] = useState(false);
const [errorShown, setErrorShown] = useState(false); const [errorShown, setErrorShown] = useState(false);
const abortFnRef = useRef<(() => void) | null>(null); const abortFnRef = useRef<(() => void) | null>(null);
const [apiConfig, setApiConfig] = useState<ApiConfig | null>(null); const [apiConfig, setApiConfig] = useState<ApiConfig | null>(null);
@ -192,7 +197,6 @@ const Sidebar = () => {
} else { } else {
setIsDisabled(false); setIsDisabled(false);
} }
} }
// get Api Config on mount // get Api Config on mount
@ -332,7 +336,6 @@ const Sidebar = () => {
<> <>
<div <div
className={`flex flex-col h-screen w-full ${isDisabled ? 'no-select' : ''}`} className={`flex flex-col h-screen w-full ${isDisabled ? 'no-select' : ''}`}
> >
<div className="overflow-y-auto overflow-x-hidden space-y-4"> <div className="overflow-y-auto overflow-x-hidden space-y-4">
{/* previous messages */} {/* previous messages */}
@ -383,7 +386,6 @@ const Sidebar = () => {
}} }}
> >
{/* input */} {/* input */}
<textarea <textarea
onChange={(e) => { onChange={(e) => {
setInstructions(e.target.value); setInstructions(e.target.value);
@ -431,46 +433,9 @@ const Sidebar = () => {
)} )}
</form> </form>
</div> </div>
{isDisabled && ( {isDisabled && (
<div className="absolute top-0 left-0 w-full h-full bg-gray-500 opacity-10 pointer-events-none" /> <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> </div>
</> </>
); );