-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor: Enhance file handling and code editing functionality #2646
Merged
tobitege
merged 29 commits into
All-Hands-AI:main
from
PierrunoYT:refactor/enhance-file-handling-and-editing
Jul 2, 2024
Merged
Changes from 5 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
665d260
refactor: Enhance file handling and code editing functionality
PierrunoYT fe7ebbe
Merge branch 'refactor/enhance-file-handling-and-editing' of https://…
PierrunoYT 2b0c00f
Added Docstrings back
PierrunoYT c6c8a05
Fix
PierrunoYT 19cbb81
Merge branch 'main' into refactor/enhance-file-handling-and-editing
PierrunoYT 0023260
Merge branch 'main' into refactor/enhance-file-handling-and-editing
PierrunoYT ca6b4ac
Add internationalization for 'File saved successfully' message
PierrunoYT 90176be
Merge branch 'refactor/enhance-file-handling-and-editing' of https://…
PierrunoYT 0fd564e
Add toast notifications for error handling in fileService
PierrunoYT 3951cbf
Add file path safety check and improve error handling in file services
PierrunoYT e10a235
Add docstrings to listen.py
PierrunoYT 4f3c56f
Revert exclude_list formatting and add docstrings in listen.py
PierrunoYT cdf66eb
Merge branch 'main' into refactor/enhance-file-handling-and-editing
PierrunoYT 6e4b170
Merge branch 'main' into refactor/enhance-file-handling-and-editing
PierrunoYT 59fa355
Merge branch 'main' into refactor/enhance-file-handling-and-editing
PierrunoYT 453f645
made code reviewable
tobitege ebcbf7d
Merge branch 'main' into refactor/enhance-file-handling-and-editing
tobitege fb610cc
fixed ruff issues
tobitege fe22dba
Merge branch 'main' into refactor/enhance-file-handling-and-editing
tobitege 3411938
Update listen.py docstrings
tobitege 6be5729
Merge branch 'main' into refactor/enhance-file-handling-and-editing
tobitege eee8a17
Merge branch 'main' into refactor/enhance-file-handling-and-editing
tobitege dccae4f
Merge branch 'main' into refactor/enhance-file-handling-and-editing
tobitege 3bcb973
Merge branch 'main' into refactor/enhance-file-handling-and-editing
tobitege ba0160e
Merge branch 'main' into refactor/enhance-file-handling-and-editing
tobitege e4db390
final tweaks
tobitege 1da375a
Merge branch 'main' into refactor/enhance-file-handling-and-editing
amanape 419756c
re-added encodedURIComponent in selectFile
tobitege 2c374f7
Merge branch 'main' into refactor/enhance-file-handling-and-editing
tobitege File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tobitege marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,57 @@ | ||
import { request } from "./api"; | ||
|
||
export async function selectFile(file: string): Promise<string> { | ||
const data = await request(`/api/select-file?file=${file}`); | ||
return data.code as string; | ||
try { | ||
const data = await request(`/api/select-file?file=${encodeURIComponent(file)}`); | ||
if (typeof data.code !== 'string') { | ||
throw new Error('Invalid response format: code is not a string'); | ||
} | ||
return data.code; | ||
} catch (error) { | ||
console.error('Error selecting file:', error); | ||
throw error; | ||
} | ||
} | ||
|
||
export async function uploadFiles(files: FileList) { | ||
const formData = new FormData(); | ||
for (let i = 0; i < files.length; i += 1) { | ||
formData.append("files", files[i]); | ||
} | ||
export async function uploadFiles(files: FileList): Promise<void> { | ||
try { | ||
const formData = new FormData(); | ||
Array.from(files).forEach(file => formData.append("files", file)); | ||
|
||
await request("/api/upload-files", { | ||
method: "POST", | ||
body: formData, | ||
}); | ||
await request("/api/upload-files", { | ||
method: "POST", | ||
body: formData, | ||
}); | ||
} catch (error) { | ||
console.error('Error uploading files:', error); | ||
throw error; | ||
PierrunoYT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
||
export async function listFiles(path: string = "/"): Promise<string[]> { | ||
const data = await request(`/api/list-files?path=${path}`); | ||
return data as string[]; | ||
try { | ||
const data = await request(`/api/list-files?path=${encodeURIComponent(path)}`); | ||
if (!Array.isArray(data)) { | ||
throw new Error('Invalid response format: data is not an array'); | ||
} | ||
return data; | ||
} catch (error) { | ||
console.error('Error listing files:', error); | ||
throw error; | ||
} | ||
} | ||
|
||
export async function saveFile(filePath: string, content: string): Promise<void> { | ||
try { | ||
PierrunoYT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
await request("/api/save-file", { | ||
method: "POST", | ||
body: JSON.stringify({ filePath, content }), | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
}); | ||
} catch (error) { | ||
console.error('Error saving file:', error); | ||
throw error; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure tbh