Remove Tauri backend code #511#513
Conversation
WalkthroughRemoves the Tauri test job from the PR workflow, adds frontend architecture docs, introduces a Tauri command get_server_path exposed via invoke_handler, and updates Tauri tests to validate this command (including a duplicated test block). Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor UI as Frontend (WebView)
participant Tauri as Tauri Main (main.rs)
participant Env as Environment
UI->>Tauri: invoke("get_server_path")
Tauri->>Env: read SERVER_URL
alt SERVER_URL set
Env-->>Tauri: value
Tauri-->>UI: value
else not set
Tauri-->>UI: "http://127.0.0.1:8000"
end
note over Tauri,UI: New command exposed via invoke_handler
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
frontend/src-tauri/src/main.rs (1)
20-55: Leftover builder chain after main; this won’t compile. Remove legacy block.
Stray plugins/setup/invoke_handler/run outside any function and referencing removed services/types.Apply:
- .plugin(tauri_plugin_dialog::init()) - .plugin(tauri_plugin_process::init()) - .setup(|app| { - let file_service = FileService::new(); - let cache_service = CacheService::new(); - let resource_path = app - .path() - .resolve("resources/backend", BaseDirectory::Resource)?; - println!("Resource path: {:?}", resource_path); - app.manage(file_service); - app.manage(cache_service); - Ok(()) - }) - .invoke_handler(tauri::generate_handler![ - services::get_folders_with_images, - services::get_images_in_folder, - services::get_all_images_with_cache, - services::get_all_videos_with_cache, - services::delete_cache, - services::share_file, - services::save_edited_image, - services::get_server_path, - services::move_to_secure_folder, - services::create_secure_folder, - services::unlock_secure_folder, - services::get_secure_media, - services::remove_from_secure_folder, - services::check_secure_folder_status, - services::get_random_memories, - services::open_folder, - services::open_with, - services::set_wallpaper, - ]) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); -} +// removed legacy Tauri builder chain and services
🧹 Nitpick comments (3)
docs/docs/frontend/architecture.md (1)
3-15: Optional: link slices to code and note Redux toolkit usage.
Add links to the slice files and indicate if RTK/RTK Query is used for clarity.frontend/src-tauri/tests/mod_test.rs (2)
1-16: Env var test can be flaky under parallel runner; guard or serialize it.
Rust runs tests in parallel; concurrent SERVER_URL mutation can race if similar tests are added later.Example (outside this hunk) to guard with a global mutex:
use std::sync::{Mutex, OnceLock}; static ENV_LOCK: OnceLock<Mutex<()>> = OnceLock::new(); #[test] fn test_get_server_path() { let _g = ENV_LOCK.get_or_init(|| Mutex::new(())).lock().unwrap(); env::set_var("SERVER_URL", "http://test.com"); assert_eq!(get_server_path(), "http://test.com"); env::remove_var("SERVER_URL"); assert_eq!(get_server_path(), "http://127.0.0.1:8000"); }
94-134: Dead test: async fn without #[tokio::test] will never run.
Either add the attribute or remove the function with the broader test cleanup.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
.github/workflows/pr-check-tests.yml(0 hunks)docs/docs/frontend/architecture.md(1 hunks)frontend/src-tauri/src/main.rs(1 hunks)frontend/src-tauri/tests/mod_test.rs(2 hunks)
💤 Files with no reviewable changes (1)
- .github/workflows/pr-check-tests.yml
🧰 Additional context used
🧬 Code graph analysis (2)
frontend/src-tauri/tests/mod_test.rs (2)
frontend/src-tauri/src/main.rs (1)
get_server_path(7-12)frontend/src-tauri/src/services/mod.rs (1)
get_server_path(963-969)
frontend/src-tauri/src/main.rs (1)
frontend/src-tauri/src/services/mod.rs (1)
get_server_path(963-969)
🔇 Additional comments (4)
docs/docs/frontend/architecture.md (1)
1-29: Docs addition looks good and matches the FastAPI migration scope.
Clear and scoped. No blockers from me.frontend/src-tauri/tests/mod_test.rs (1)
17-260: Incorrect — referenced services/types are present in src.rg confirms FileService, CacheService and the named get_/secure_/encryption helpers are implemented/exported under frontend/src-tauri/src (notably: main.rs, services/mod.rs, services/file_service.rs, services/cache_service.rs). The original suggestion to prune these tests for missing symbols is incorrect.
Likely an incorrect or invalid review comment.
frontend/src-tauri/src/main.rs (2)
6-12: get_server_path command: OK.
Simple and correct fallback to http://127.0.0.1:8000.
15-19: Builder invoke_handler wiring: OK.
Handler registration matches the only remaining command.
| ### Home Page | ||
|  | ||
| *Home page with sample images loaded* | ||
|
|
||
| ### Processing Results | ||
|  | ||
| *Face detection results on sample images* | ||
|
|
||
| ### Settings | ||
|  | ||
| *Application settings interface* |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Verify screenshot asset paths and presence in the repo.
Prevent broken images on the site by confirming the three PNGs exist at docs/docs/assets and the relative paths resolve from this page.
Run:
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Check files exist
for f in home-page.png results-page.png settings-page.png; do
if [[ ! -f "docs/docs/assets/$f" ]]; then
echo "Missing: docs/docs/assets/$f" && exit 1
fi
done
# Validate markdown references point to ../assets/<file>
rg -n '\!\[[^]]+\]\(\.\./assets/(home-page|results-page|settings-page)\.png\)' docs/docs/frontend/architecture.md || {
echo "Expected image references not found or paths differ"; exit 1; }
echo "Screenshots present and references OK."Length of output: 59
🏁 Script executed:
#!/bin/bash
set -euo pipefail
files=(home-page.png results-page.png settings-page.png)
missing=()
found_elsewhere=()
for f in "${files[@]}"; do
expected="docs/docs/assets/$f"
if [ -f "$expected" ]; then
continue
fi
found=$(find . -type f -name "$f" -print -quit || true)
if [ -n "$found" ]; then
found_elsewhere+=("$f -> $found")
else
missing+=("$expected")
fi
done
if [ "${#missing[@]}" -ne 0 ]; then
printf "Missing files at expected path:\n"
printf "%s\n" "${missing[@]}"
fi
if [ "${#found_elsewhere[@]}" -ne 0 ]; then
printf "Files found at other locations:\n"
printf "%s\n" "${found_elsewhere[@]}"
fi
if [ "${#missing[@]}" -ne 0 ]; then
echo "One or more expected files are missing from docs/docs/assets." >&2
exit 1
fi
md="docs/docs/frontend/architecture.md"
if [ ! -f "$md" ]; then
echo "Markdown file $md not found" >&2
exit 1
fi
refs_missing=()
for f in "${files[@]}"; do
if ! grep -nF "../assets/$f" "$md" >/dev/null 2>&1; then
refs_missing+=("$f")
fi
done
if [ "${#refs_missing[@]}" -ne 0 ]; then
printf "Missing markdown references (../assets/<file>) in %s:\n" "$md"
printf "%s\n" "${refs_missing[@]}"
exit 1
fi
echo "Screenshots present in docs/docs/assets and markdown references OK."Length of output: 193
Missing screenshot assets — add images to docs/docs/assets or update markdown paths.
docs/docs/frontend/architecture.md (lines 18–28) references ../assets/{home-page.png, results-page.png, settings-page.png} but the files are absent at:
- docs/docs/assets/home-page.png
- docs/docs/assets/results-page.png
- docs/docs/assets/settings-page.png
Action: add the three PNGs to docs/docs/assets/ or update the markdown to point to the actual image locations.
🤖 Prompt for AI Agents
In docs/docs/frontend/architecture.md around lines 18 to 28 the markdown
references ../assets/home-page.png, ../assets/results-page.png and
../assets/settings-page.png but those files are missing; fix by either (A)
adding the three PNG files with those exact names into docs/docs/assets/, or (B)
updating the image paths in the markdown to point to the actual existing
locations/names of the images in the repo (ensure relative paths are correct),
then commit the added images or path changes and verify the images render in the
docs build.
| use std::env; | ||
| use tauri_backend::get_server_path; | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::*; | ||
|
|
||
| #[test] | ||
| fn test_get_server_path() { | ||
| env::set_var("SERVER_URL", "http://test.com"); | ||
| assert_eq!(get_server_path(), "http://test.com"); | ||
| env::remove_var("SERVER_URL"); | ||
| assert_eq!(get_server_path(), "http://127.0.0.1:8000"); | ||
| } | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Optional: replace entire file with a minimal, stable test.
Keeps only the single env-guarded test and removes all legacy Tauri tests.
Outside-the-hunk replacement suggestion:
use std::env;
#[cfg(test)]
mod tests {
use super::*;
use std::sync::{Mutex, OnceLock};
static ENV_LOCK: OnceLock<Mutex<()>> = OnceLock::new();
#[test]
fn get_server_path_reads_env_or_defaults() {
let _g = ENV_LOCK.get_or_init(|| Mutex::new(())).lock().unwrap();
env::set_var("SERVER_URL", "http://test.com");
assert_eq!(tauri_backend::get_server_path(), "http://test.com");
env::remove_var("SERVER_URL");
assert_eq!(tauri_backend::get_server_path(), "http://127.0.0.1:8000");
}
}I can push this as a patch if you want.
Also applies to: 261-274
🤖 Prompt for AI Agents
frontend/src-tauri/tests/mod_test.rs lines 1-16: replace the legacy multi-test
file with a single, stable env-guarded test that avoids race conditions by using
a global OnceLock<Mutex<()>>; within that test set SERVER_URL, assert
tauri_backend::get_server_path() returns the env value, remove the env var,
assert the default "http://127.0.0.1:8000" is returned, and remove all other
legacy Tauri tests so only this minimal deterministic test remains.
| use std::env; | ||
| use tauri_backend::get_server_path; |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Verify crate path used in tests.
Ensure tauri_backend is the actual crate name in frontend/src-tauri/Cargo.toml; otherwise switch to crate::get_server_path.
Run:
🏁 Script executed:
#!/bin/bash
set -euo pipefail
toml=$(fd -HI Cargo.toml frontend/src-tauri -x cat {})
name=$(fd -HI Cargo.toml frontend/src-tauri -x rg -n '^name\s*=\s*".*"' {} | sed -E 's/.*"([^"]+)".*/\1/')
echo "Crate name: $name"
rg -nP "use\s+$name::get_server_path|use\s+crate::get_server_path" frontend/src-tauri/tests/mod_test.rs || {
echo "Adjust test import to use crate name: $name"; exit 1; }Length of output: 67
Replace test import to use crate name (picto_py)
frontend/src-tauri/tests/mod_test.rs — replace use tauri_backend::get_server_path; with use picto_py::get_server_path; (integration tests import the crate by its Cargo.toml name).
🤖 Prompt for AI Agents
In frontend/src-tauri/tests/mod_test.rs around lines 1 to 2, the test imports
the function from the library using the crate path tauri_backend which is
incorrect for integration tests; update the use statement to import
get_server_path from the crate name declared in Cargo.toml by replacing use
tauri_backend::get_server_path; with use picto_py::get_server_path; so the test
imports the crate by its package name.
| #[cfg(test)] | ||
| mod tests { | ||
| use std::env; | ||
| use tauri_backend::get_server_path; | ||
|
|
||
| #[test] | ||
| fn test_get_server_path() { | ||
| env::set_var("SERVER_URL", "http://test.com"); | ||
| assert_eq!(get_server_path(), "http://test.com"); | ||
|
|
||
| env::remove_var("SERVER_URL"); | ||
| assert_eq!(get_server_path(), "http://127.0.0.1:8000"); | ||
| } | ||
| } |
There was a problem hiding this comment.
Duplicate #[cfg(test)] mod tests; remove this block.
Two modules named tests in the same scope cause a redefinition error.
Apply:
-#[cfg(test)]
-mod tests {
- use std::env;
- use tauri_backend::get_server_path;
-
- #[test]
- fn test_get_server_path() {
- env::set_var("SERVER_URL", "http://test.com");
- assert_eq!(get_server_path(), "http://test.com");
-
- env::remove_var("SERVER_URL");
- assert_eq!(get_server_path(), "http://127.0.0.1:8000");
- }
-}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| #[cfg(test)] | |
| mod tests { | |
| use std::env; | |
| use tauri_backend::get_server_path; | |
| #[test] | |
| fn test_get_server_path() { | |
| env::set_var("SERVER_URL", "http://test.com"); | |
| assert_eq!(get_server_path(), "http://test.com"); | |
| env::remove_var("SERVER_URL"); | |
| assert_eq!(get_server_path(), "http://127.0.0.1:8000"); | |
| } | |
| } |
🤖 Prompt for AI Agents
In frontend/src-tauri/tests/mod_test.rs around lines 261 to 274, there is a
duplicate #[cfg(test)] mod tests block causing a redefinition error; remove this
entire duplicate tests module (the block from #[cfg(test)] mod tests { ... }) so
only a single tests module remains, and ensure any unique test cases inside are
merged into the remaining tests module if needed.
Description
This PR removes unwanted Tauri backend code since we've migrated to FastAPI. Changes include:
Testing:
Fixes #511
Summary by CodeRabbit