Repository navigation
Add daily-sites extension - #18763
Conversation
- Fixed issue with addsite.tsx where the form validation errors were always visible for a new site. Now they only only appear if the Name and/or URL textfields are blank when clicking Add. - Initial Commit
commented
Apr 24, 2025
|
Congratulations on your new Raycast extension! 🚀 You can expect an initial review within five business days. Once the PR is approved and merged, the extension will be available on our Store. |
- Fixed code style issues - Fixed errors that arose when running "npx ray build -e dist" that were due to unnecessary imports and incorrect syntax
left a comment
There was a problem hiding this comment.
PR Summary
This PR adds a new Daily Sites extension for managing and quickly accessing frequently visited websites, featuring site management, categorization, and import/export capabilities.
- README.md needs more detailed documentation about features, usage instructions, and examples to help users understand the extension's capabilities
- Extension requires a
metadatafolder with screenshots since it includesviewcommands in package.json - Consider adding URL validation in
addsite.tsxto ensure proper URL format before saving - Consider using
showFailureToastfrom@raycast/utilsin try-catch blocks instead of manualshowToastcalls for error handling - XML parsing in
utils.tscould benefit from more robust error handling and input validation to prevent potential security issues
💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!
13 file(s) reviewed, 10 comment(s)
Edit PR Review Bot Settings | Greptile
| { | ||
| "name": "dailysites", | ||
| "title": "Daily Sites", | ||
| "subtitle": "Daily Sites", |
There was a problem hiding this comment.
style: The subtitle 'Daily Sites' is redundant with the title. Consider using a more descriptive subtitle that differentiates the command
| // persist | ||
| const existing = await loadSites(); | ||
| const updated = initialValues | ||
| ? existing.map((s) => (s.url === initialValues.url ? newSite : s)) | ||
| : [...existing, newSite]; | ||
|
|
||
| await saveSites(updated); | ||
| await showToast(Toast.Style.Success, initialValues ? "Site updated" : "Site added"); |
There was a problem hiding this comment.
logic: loadSites and saveSites operations should be wrapped in try-catch to handle potential storage errors
| // persist | |
| const existing = await loadSites(); | |
| const updated = initialValues | |
| ? existing.map((s) => (s.url === initialValues.url ? newSite : s)) | |
| : [...existing, newSite]; | |
| await saveSites(updated); | |
| await showToast(Toast.Style.Success, initialValues ? "Site updated" : "Site added"); | |
| // persist | |
| try { | |
| const existing = await loadSites(); | |
| const updated = initialValues | |
| ? existing.map((s) => (s.url === initialValues.url ? newSite : s)) | |
| : [...existing, newSite]; | |
| await saveSites(updated); | |
| await showToast(Toast.Style.Success, initialValues ? "Site updated" : "Site added"); | |
| onDone(); | |
| } catch (error) { | |
| showFailureToast(error, { title: "Failed to save site" }); | |
| } |
| // load existing categories | ||
| useEffect(() => { | ||
| (async () => { | ||
| const all = await loadSites(); | ||
| const baseCategories = getCategories(all); | ||
| const merged = Array.from(new Set([initialCat, "custom", ...baseCategories])); | ||
| setCategories(merged); | ||
| })(); | ||
| }, [initialCat]); |
There was a problem hiding this comment.
logic: useEffect has no error handling for loadSites failure
| // load existing categories | |
| useEffect(() => { | |
| (async () => { | |
| const all = await loadSites(); | |
| const baseCategories = getCategories(all); | |
| const merged = Array.from(new Set([initialCat, "custom", ...baseCategories])); | |
| setCategories(merged); | |
| })(); | |
| }, [initialCat]); | |
| // load existing categories | |
| useEffect(() => { | |
| (async () => { | |
| try { | |
| const all = await loadSites(); | |
| const baseCategories = getCategories(all); | |
| const merged = Array.from(new Set([initialCat, "custom", ...baseCategories])); | |
| setCategories(merged); | |
| } catch (error) { | |
| showFailureToast(error, { title: "Failed to load categories" }); | |
| } | |
| })(); | |
| }, [initialCat]); |
| async function refresh() { | ||
| const loaded = await loadSites(); | ||
| setSites(loaded); | ||
| setCategories(getCategories(loaded)); | ||
| } |
There was a problem hiding this comment.
style: refresh() should be wrapped in try/catch to handle potential loadSites errors
| async function refresh() { | |
| const loaded = await loadSites(); | |
| setSites(loaded); | |
| setCategories(getCategories(loaded)); | |
| } | |
| async function refresh() { | |
| try { | |
| const loaded = await loadSites(); | |
| setSites(loaded); | |
| setCategories(getCategories(loaded)); | |
| } catch (error) { | |
| console.error('Error loading sites:', error); | |
| await showToast(Toast.Style.Failure, 'Failed to load sites'); | |
| } | |
| } |
| return ( | ||
| <List | ||
| searchBarPlaceholder="Filter by name, URL or category…" | ||
| searchBarAccessory={ | ||
| <List.Dropdown tooltip="Filter by category" value={filterCategory} onChange={setFilterCategory}> | ||
| <List.Dropdown.Item title="All Categories" value="" /> | ||
| {categories | ||
| .filter((cat) => cat !== "uncategorized") | ||
| .map((cat) => ( | ||
| <List.Dropdown.Item key={cat} title={cat} value={cat} /> | ||
| ))} | ||
| </List.Dropdown> | ||
| } | ||
| > |
There was a problem hiding this comment.
style: List should use isLoading prop while sites are being loaded to avoid empty state flicker
| return ( | |
| <List | |
| searchBarPlaceholder="Filter by name, URL or category…" | |
| searchBarAccessory={ | |
| <List.Dropdown tooltip="Filter by category" value={filterCategory} onChange={setFilterCategory}> | |
| <List.Dropdown.Item title="All Categories" value="" /> | |
| {categories | |
| .filter((cat) => cat !== "uncategorized") | |
| .map((cat) => ( | |
| <List.Dropdown.Item key={cat} title={cat} value={cat} /> | |
| ))} | |
| </List.Dropdown> | |
| } | |
| > | |
| return ( | |
| <List | |
| isLoading={sites.length === 0} | |
| searchBarPlaceholder="Filter by name, URL or category…" | |
| searchBarAccessory={ | |
| <List.Dropdown tooltip="Filter by category" value={filterCategory} onChange={setFilterCategory}> | |
| <List.Dropdown.Item title="All Categories" value="" /> | |
| {categories | |
| .filter((cat) => cat !== "uncategorized") | |
| .map((cat) => ( | |
| <List.Dropdown.Item key={cat} title={cat} value={cat} /> | |
| ))} | |
| </List.Dropdown> | |
| } | |
| > |
| console.error("handleDelete error:", error); | ||
| await showToast(Toast.Style.Failure, "Error deleting site"); |
There was a problem hiding this comment.
style: Replace with showFailureToast from @raycast/utils for consistent error handling
| console.error("handleDelete error:", error); | |
| await showToast(Toast.Style.Failure, "Error deleting site"); | |
| console.error("handleDelete error:", error); | |
| showFailureToast(error, { title: "Error deleting site" }); |
| } catch (e) { | ||
| console.error(e); | ||
| await showToast(Toast.Style.Failure, "Import failed"); | ||
| } |
There was a problem hiding this comment.
style: Use showFailureToast from @raycast/utils instead of manual error handling. Example: showFailureToast(error, { title: "Could not import sites" })
| } catch (e) { | |
| console.error(e); | |
| await showToast(Toast.Style.Failure, "Import failed"); | |
| } | |
| } catch (error) { | |
| console.error(error); | |
| await showFailureToast(error, { title: "Could not import sites" }); | |
| } |
| } catch (e) { | ||
| console.error(e); | ||
| await showToast(Toast.Style.Failure, "Export failed"); | ||
| } |
There was a problem hiding this comment.
style: Use showFailureToast from @raycast/utils instead of manual error handling. Example: showFailureToast(error, { title: 'Could not export sites' })
| } catch (e) { | |
| console.error(e); | |
| await showToast(Toast.Style.Failure, "Export failed"); | |
| } | |
| } catch (error) { | |
| console.error(error); | |
| await showFailureToast(error, { title: "Could not export sites" }); | |
| } |
|
|
||
| if (!raw || !raw.trim().startsWith("<?xml")) { | ||
| const empty = `<?xml version="1.0"?><sites></sites>`; | ||
| await LocalStorage.setItem(STORAGE_KEY, empty).catch(() => {}); |
There was a problem hiding this comment.
logic: Empty catch block silently ignores storage errors. Use showFailureToast from @raycast/utils instead.
| await LocalStorage.setItem(STORAGE_KEY, empty).catch(() => {}); | |
| await LocalStorage.setItem(STORAGE_KEY, empty).catch((error) => showFailureToast(error, { title: "Failed to initialize sites storage" })); |
| export async function saveSites(sites: Site[]): Promise<void> { | ||
| const sorted = sortSites(sites); | ||
| const xml = sitesToXml(sorted); | ||
| await LocalStorage.setItem(STORAGE_KEY, xml); |
There was a problem hiding this comment.
logic: Missing error handling for LocalStorage.setItem. Should wrap in try-catch with showFailureToast.
| await LocalStorage.setItem(STORAGE_KEY, xml); | |
| try { | |
| await LocalStorage.setItem(STORAGE_KEY, xml); | |
| } catch (error) { | |
| showFailureToast(error, { title: "Failed to save sites" }); | |
| } |
- Adding media directory and adding new images to metadata - Made changes suggested by greptile-apps bot so my PR can be approved. :)
… issue with Site Manager where the isLoading state would continue to be true even when there were no sites to be loaded.
commented
Apr 30, 2025
|
There are still some CI errors you need to look into, do you need help? I'm waiting until checks complete to review it 🙂 |
… in my package.json which caused a ci error, so I changed the version number back and properly ran npm install @raycast/api@latest
left a comment
There was a problem hiding this comment.
PR Summary
(updates since last review)
The PR has been updated with significant improvements to documentation, error handling, and core functionality for the Daily Sites extension.
- Added comprehensive setup and usage documentation in
README.mdwith clear examples and screenshots - Implemented
showFailureToastfrom@raycast/utilsacross all error handling inexportsites.tsx,importsites.tsx, andutils.ts - Added URL validation in
addsite.tsxto ensure valid http/https URLs and defaulting new URLs to 'https://' - Improved XML handling with proper escaping and error handling in
utils.ts - All view commands now use consistent "Daily Sites" subtitle in
package.jsonfor better organization
Note: The PR now addresses all major points from the previous review and implements proper error handling and validation throughout the codebase.
7 file(s) reviewed, 7 comment(s)
Edit PR Review Bot Settings | Greptile
| "type": "directory", | ||
| "name": "xmlFolder", | ||
| "title": "XML Folder", | ||
| "description": "Where your exported sites XML file will live", |
There was a problem hiding this comment.
style: The description should end with a period for consistency with other descriptions
| "description": "Where your exported sites XML file will live", | |
| "description": "Where your exported sites XML file will live.", |
|
|
||
| Daily Sites lets you collect frequently used websites, filter them by name, URL, and category, and easily open them in your default web browser. | ||
|
|
||
|  |
There was a problem hiding this comment.
style: Image path 'media/launcher.png' should be relative to the metadata folder for store submission
|  | |
|  |
|
|
||
| The first time you open the extension you will be asked to choose an XML folder, this defaults to your Documents folder. This folder is used by the “Export Sites” and “Import Sites” commands. It’s where exported XML files are saved and the default import directory. | ||
|
|
||
|  |
There was a problem hiding this comment.
style: Image path 'media/setup.png' should be relative to the metadata folder for store submission
|  | |
|  |
| const out = path.join(values.folder[0], `${values.filename || "sites"}.xml`); | ||
| fs.writeFileSync(out, xml, "utf8"); |
There was a problem hiding this comment.
style: Use fs.promises.writeFile instead of synchronous writeFileSync to avoid blocking the main thread
| const updated = initialValues | ||
| ? existing.map((s) => (s.url === initialValues.url ? newSite : s)) | ||
| : [...existing, newSite]; |
There was a problem hiding this comment.
style: Consider adding duplicate URL check when updating to prevent accidental duplicates
| const updated = initialValues | |
| ? existing.map((s) => (s.url === initialValues.url ? newSite : s)) | |
| : [...existing, newSite]; | |
| const isDuplicate = !initialValues && existing.some(s => s.url === newSite.url); | |
| if (isDuplicate) { | |
| showToast(Toast.Style.Failure, "A site with this URL already exists"); | |
| return; | |
| } | |
| const updated = initialValues | |
| ? existing.map((s) => (s.url === initialValues.url ? newSite : s)) | |
| : [...existing, newSite]; |
|
|
||
| async function handleSubmit(values: { file: string[] }) { | ||
| try { | ||
| const xmlPath = values.file[0]; /* or `${xmlFolder}/yourfile.xml` */ |
There was a problem hiding this comment.
style: Remove commented code suggestion since it's not being used
| const xmlPath = values.file[0]; /* or `${xmlFolder}/yourfile.xml` */ | |
| const xmlPath = values.file[0]; |
| useEffect(() => { | ||
| setTimeout(() => { | ||
| refresh(); | ||
| setIsLoading(false); | ||
| }, 1500); | ||
| }, []); |
There was a problem hiding this comment.
style: Consider removing artificial delay of 1500ms - it may make the app feel slow without providing value
commented
Apr 30, 2025
I appreciate the heads-up! The CI errors should now be resolved, thank you! |
…loading indicator won\'t fire if there are no sites to be loaded like on the initial launch.
left a comment
There was a problem hiding this comment.
PR Summary
(updates since last review)
The PR has been further refined with improvements to the Daily Sites extension's file handling and error management.
- Implemented non-blocking file operations using
fs.promises.writeFileinexportsites.tsxfor better performance - Added proper file path handling using
path.join()inexportsites.tsxfor cross-platform compatibility - Improved error handling in
importsites.tsxwith better error messages and validation for XML imports - Added default directory handling in
exportsites.tsxusing user preferences
Note: The changes show continued improvement in code quality and robustness, particularly around file system operations.
5 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile
| useEffect(() => { | ||
| (async () => { | ||
| const all = await loadSites(); | ||
| const baseCats = getCategories(all); | ||
| setCategories(Array.from(new Set([initialCat, "custom", ...baseCats]))); | ||
| })(); | ||
| }, [initialCat]); |
There was a problem hiding this comment.
style: useEffect has no cleanup function to cancel the async operation if the component unmounts during the load
left a comment
There was a problem hiding this comment.
PR Summary
(updates since last review)
The PR has been updated with improvements to form handling and state management in the Daily Sites extension.
- Added cleanup for async operations in
addsite.tsxusingisActiveflag to prevent state updates after unmount - Improved form validation in
addsite.tsxwith separate error states for name and URL fields - Implemented proper state management for custom categories with
useStateand conditional rendering - Added proper type definitions for form props and values in
addsite.tsx
Note: The changes demonstrate better React practices and form handling, particularly around component lifecycle and validation.
1 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile
| value={customCategory} | ||
| onChange={setCustomCategory} | ||
| /> |
There was a problem hiding this comment.
style: Consider trimming whitespace from customCategory as it's entered rather than only on submit
left a comment
There was a problem hiding this comment.
PR Summary
(updates since last review)
Recent changes focus on improving the Daily Sites extension's error handling and storage operations.
- Implemented proper error handling for LocalStorage operations in
utils.tsusingshowFailureToast - Added XML validation in
utils.tsto ensure proper format before parsing withstartsWith("<?xml") - Improved error recovery in
loadSites()by resetting to empty XML state on parse failures - Added sorting functionality in
utils.tsto maintain consistent site ordering
Note: These changes enhance the robustness of data handling and storage operations, particularly around error cases and data consistency.
1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile
commented
May 2, 2025
@pernielsentikaer I had some other style related changes recommended by the bot after fixing the CI errors, but everything should be ready to go now! 🙌 |
left a comment
There was a problem hiding this comment.
Hi 👋
Thanks for your contribution 💪
I have now tested your extension, and I have some feedback ready for you:
- You should popToRoot after adding a new site (or add a preference to let the user switch between popToRoot and going back to root
I'm looking forward to testing this extension again 🔥
Request a new review when you are ready. Feel free to contact me here or at Slack if you have any questions.
…add. If you choose yes, the fields reset to default values. If you choose no, popToRoot is called if you launched Add Site directly, otherwise it returns to Site Launcher. Import Site now calls popToRoot after a successful import if you launched Import Sites directly, otherwise it returns to Site Launcher. Export Site now calls popToRoot after a successful export if you launched Export Sites directly, otherwise it returns to Site Launcher.
left a comment
There was a problem hiding this comment.
PR Summary
(updates since last review)
The PR has been updated with improved navigation handling in the Daily Sites extension, particularly around form submission flows.
- Added
popToRoot()after site addition inaddsite.tsxto ensure consistent navigation behavior - Implemented "Add Another" confirmation dialog in
addsite.tsxto improve user workflow - Added form reset functionality when adding multiple sites consecutively
- Standardized navigation behavior across all commands using
popToRoot()
Note: These changes provide a more consistent and user-friendly navigation experience throughout the extension.
3 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile
| // Ask user if they want to add another | ||
| const again = await confirmAlert({ | ||
| title: "Add another site?", | ||
| message: "Would you like to add one more site?", | ||
| primaryAction: { title: "Yes" }, | ||
| dismissAction: { title: "No" }, | ||
| }); |
There was a problem hiding this comment.
style: Consider moving confirmAlert call before saveSites to prevent showing success toast if user cancels
…t call before saveSites to prevent showing success toast if user cancels
left a comment
There was a problem hiding this comment.
PR Summary
(updates since last review)
Recent changes to the Daily Sites extension introduce potential issues with the site saving workflow in addsite.tsx.
- The
saveSitesoperation inaddsite.tsxshould occur before showing the "Add another site?" dialog to prevent data loss if save fails - Consider adding error handling around the
confirmAlertcall inaddsite.tsxto handle potential failures - The form reset logic in
addsite.tsxshould be moved into a separate function to improve code organization
Note: These changes focus on improving the reliability and error handling of the site addition workflow.
1 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile
| // Ask user if they want to add another | ||
| const again = await confirmAlert({ | ||
| title: "Add another site?", | ||
| message: "Would you like to add one more site?", | ||
| primaryAction: { title: "Yes" }, | ||
| dismissAction: { title: "No" }, | ||
| }); |
There was a problem hiding this comment.
logic: confirmAlert should only be shown when not in edit mode (initialValues is undefined), as it doesn't make sense to ask about adding another when editing
| // Ask user if they want to add another | |
| const again = await confirmAlert({ | |
| title: "Add another site?", | |
| message: "Would you like to add one more site?", | |
| primaryAction: { title: "Yes" }, | |
| dismissAction: { title: "No" }, | |
| }); | |
| // Ask user if they want to add another (only in add mode) | |
| const again = !initialValues && await confirmAlert({ | |
| title: "Add another site?", | |
| message: "Would you like to add one more site?", | |
| primaryAction: { title: "Yes" }, | |
| dismissAction: { title: "No" }, | |
| }); |
… edit mode (initialValues is undefined), as it doesn\'t make sense to ask about adding another when editing
left a comment
There was a problem hiding this comment.
PR Summary
(updates since last review)
Recent changes to the Daily Sites extension improve the site saving workflow and error handling in addsite.tsx.
- Reordered operations in
addsite.tsxto save sites before showing the "Add another" dialog - Added proper error handling around
confirmAlertusing try-catch inaddsite.tsx - Improved form state management with proper cleanup and error handling in
addsite.tsx
Note: These changes enhance the reliability of the site addition workflow and maintain data consistency.
1 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile
| await saveSites(updated); | ||
| await showToast(Toast.Style.Success, initialValues ? "Site updated" : "Site added"); |
There was a problem hiding this comment.
style: Consider moving showToast after the 'again' check to avoid showing success when user might continue adding more
| onDone={async () => { | ||
| // runs when Add Site is invoked directly | ||
| await popToRoot(); | ||
| }} |
There was a problem hiding this comment.
logic: popToRoot should be wrapped in try-catch to handle potential navigation errors
…oid showing success when user might continue adding more. Fixed logic issue by wrapping popToRoot in try-catch to handle potential navigation errors.
left a comment
There was a problem hiding this comment.
PR Summary
(updates since last review)
Recent changes improve error handling and navigation in the Daily Sites extension's core commands.
- Added proper error handling for
popToRootnavigation in all command wrappers (addsite.tsx,importsites.tsx,exportsites.tsx) - Improved error feedback using
showFailureToastconsistently across import/export operations - Implemented non-blocking file write operations in
exportsites.tsxfor better performance
Note: These changes enhance the robustness of navigation and file operations throughout the extension.
3 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile
| defaultValue="dailysites" | ||
| placeholder="dailysites" |
There was a problem hiding this comment.
style: defaultValue and placeholder are identical - consider removing placeholder since it's redundant
…e identical, removed placeholder since it was redundant.
left a comment
There was a problem hiding this comment.
PR Summary
(updates since last review)
Recent changes focus on minor improvements to the export functionality in the Daily Sites extension.
- Removed redundant placeholder in
exportsites.tsxfilename field since it matched the defaultValue - Improved file path handling in
exportsites.tsxby using proper path joining for cross-platform compatibility
Note: These changes represent minor refinements to the export functionality, with no significant changes to core behavior.
1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile
commented
May 3, 2025
When Add Site is opened directly and you add a new site it now asks if you want to add another site, if yes it replaces fields/popup with default values, if no it does a popToRoot. When the Add Site action is invoked from Site Launcher and you choose no after adding a site, it returns to Site Launcher. For consistency sake I updated the functionality of Import Sites and Export Sites to behave in the same manner. Definitely feels a little bit more polished now, pretty happy with these changes! 😀 |
commented
May 7, 2025
@pernielsentikaer Realizing that I didn't mention that I had requested a new review, figured I would leave a comment here just in case, thank you! |
commented
May 9, 2025
|
Published to the Raycast Store: |
commented
May 9, 2025
|
🎉 🎉 🎉 We've rewarded your Raycast account with some credits. You will soon be able to exchange them for some swag. |
Daily Sites - Site Launcher
Description
Daily Sites lets you collect frequently used websites, filter them by name, URL, and category, and easily open them in your default web browser.
Setup
The first time you open the extension you will be asked to choose an XML folder, this defaults to your Documents folder. This folder is used by the “Export Sites” and “Import Sites” commands. It’s where exported XML files are saved and the default import directory.
Features
Site Launcher
Add Site
Export Sites
Import Sites
Usage
As the name implies, Daily Sites was created to make it easier for you to access websites that you view on a daily basis. A prime example of this is technology news sites which may be updated multiple times a day.
We can create a series of sites with the category “News” and then every time you want to browse your tech news sites, you can either type “news” or select the “News” category from the Category dropdown menu.
Author
Developed by Derek William Scott (@dubsdotla on GitHub).
License
Distributed under the MIT License.
Screencast
Kapture.2025-04-28.at.18.15.08.mp4
Checklist
npm run buildand tested this distribution build in Raycastassetsfolder are used by the extension itselfREADMEare placed outside of themetadatafolder