-
Notifications
You must be signed in to change notification settings - Fork 111
feat(ui): improve local repository path display and messaging #226
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
Conversation
- Add shared client constants file with REPOSITORY_BASE - Show effective local path in repository info tab - Update host mount warning to clarify default path is safe when using recommended Docker setup - Update README to clarify local repositories can use custom paths
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughExtracts the hardcoded repository base path into a new constant, updates the local-repository form to use that constant, adds logic to compute and display an effective local path in the repository info tab, and revises README to describe a configurable local repository base path. Changes
Pre-merge checks✅ Passed checks (3 passed)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR improves the handling and display of local repository paths by introducing a shared constant and enhancing user-facing information. The changes consolidate the hardcoded repository base path into a reusable constant and add clearer messaging about repository paths in the UI.
Key changes:
- Created a shared client-side constant
REPOSITORY_BASEto deduplicate the hardcoded path/var/lib/zerobyte/repositories - Added an "Effective Local Path" display in the repository info tab to show the actual filesystem path used by local repositories
- Updated the host mount warning message to be more accurate about the default path's safety when using Docker Compose
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| app/client/lib/constants.ts | New file defining the REPOSITORY_BASE constant for client-side use |
| app/client/modules/repositories/components/repository-forms/local-repository-form.tsx | Replaced hardcoded path strings with REPOSITORY_BASE constant and clarified warning message |
| app/client/modules/repositories/tabs/info.tsx | Added getEffectiveLocalPath function and UI display for effective local repository paths |
| README.md | Updated documentation to clarify local repositories can use custom paths and are subfolders |
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
app/client/modules/repositories/tabs/info.tsx (2)
29-34: Consider memoizing to avoid redundant calls and improve path concatenation.Two observations:
- The function is invoked twice (line 124 for conditional check, line 127 for display), causing redundant computation on each render.
- Path concatenation using
${basePath}/${config.name}could produce double slashes ifconfig.pathincludes a trailing slash.🔎 Proposed refactor with memoization and robust path joining
+import { useMemo } from "react"; + const getEffectiveLocalPath = (repository: Repository): string | null => { if (repository.type !== "local") return null; const config = repository.config as { name: string; path?: string }; const basePath = config.path || REPOSITORY_BASE; - return `${basePath}/${config.name}`; + // Remove trailing slash if present to avoid double slashes + const normalizedBase = basePath.endsWith("/") ? basePath.slice(0, -1) : basePath; + return `${normalizedBase}/${config.name}`; }; export const RepositoryInfoTabContent = ({ repository }: Props) => { const [name, setName] = useState(repository.name); const [compressionMode, setCompressionMode] = useState<CompressionMode>( (repository.compressionMode as CompressionMode) || "off", ); const [showConfirmDialog, setShowConfirmDialog] = useState(false); + const effectiveLocalPath = useMemo(() => getEffectiveLocalPath(repository), [repository]); + const isImportedLocal = repository.type === "local" && repository.config.isExistingRepository;Then update the render to use the memoized value:
- {getEffectiveLocalPath(repository) && ( + {effectiveLocalPath && ( <div className="md:col-span-2"> <div className="text-sm font-medium text-muted-foreground">Effective Local Path</div> - <p className="mt-1 text-sm font-mono">{getEffectiveLocalPath(repository)}</p> + <p className="mt-1 text-sm font-mono">{effectiveLocalPath}</p> </div> )}
31-31: Type assertion could be made more robust.The type assertion
repository.config as { name: string; path?: string }assumes a specific structure without runtime validation. While this likely matches the actual config for local repositories, consider adding type guards or using a more specific type from the schema.💡 Alternative approach with type guard
const isLocalRepoConfig = (config: unknown): config is { name: string; path?: string; isExistingRepository?: boolean } => { return ( typeof config === "object" && config !== null && "name" in config && typeof (config as any).name === "string" ); }; const getEffectiveLocalPath = (repository: Repository): string | null => { if (repository.type !== "local") return null; const config = repository.config; if (!isLocalRepoConfig(config)) return null; const basePath = config.path || REPOSITORY_BASE; const normalizedBase = basePath.endsWith("/") ? basePath.slice(0, -1) : basePath; return `${normalizedBase}/${config.name}`; };
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
README.mdapp/client/lib/constants.tsapp/client/modules/repositories/components/repository-forms/local-repository-form.tsxapp/client/modules/repositories/tabs/info.tsx
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx,js,jsx,json}
📄 CodeRabbit inference engine (AGENTS.md)
Use Biome for code formatting and linting with tabs (not spaces), 120 character line width, and double quotes.
Files:
app/client/lib/constants.tsapp/client/modules/repositories/tabs/info.tsxapp/client/modules/repositories/components/repository-forms/local-repository-form.tsx
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Do not auto-organize imports in Biome - imports organization is disabled.
Files:
app/client/lib/constants.tsapp/client/modules/repositories/tabs/info.tsxapp/client/modules/repositories/components/repository-forms/local-repository-form.tsx
app/client/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
React client must use TanStack Query for server state management and auto-generated API client from OpenAPI spec.
Files:
app/client/lib/constants.tsapp/client/modules/repositories/tabs/info.tsxapp/client/modules/repositories/components/repository-forms/local-repository-form.tsx
app/client/**/*.tsx
📄 CodeRabbit inference engine (AGENTS.md)
Use Server-Sent Events hook (
use-server-events.ts) for real-time updates in React components.
Files:
app/client/modules/repositories/tabs/info.tsxapp/client/modules/repositories/components/repository-forms/local-repository-form.tsx
🧠 Learnings (5)
📚 Learning: 2025-12-19T18:25:52.583Z
Learnt from: CR
Repo: nicotsx/zerobyte PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-19T18:25:52.583Z
Learning: Applies to app/server/modules/repositories/**/*.ts : Rclone configuration must be dynamically generated and passed via environment variables for rclone-based repository backends.
Applied to files:
app/client/lib/constants.tsapp/client/modules/repositories/tabs/info.tsxapp/client/modules/repositories/components/repository-forms/local-repository-form.tsx
📚 Learning: 2025-12-19T18:25:52.583Z
Learnt from: CR
Repo: nicotsx/zerobyte PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-19T18:25:52.583Z
Learning: When adding a new repository backend, update `buildRepoUrl()` in `app/server/utils/restic.ts` and `buildEnv()` to handle credentials/configuration.
Applied to files:
app/client/lib/constants.tsapp/client/modules/repositories/components/repository-forms/local-repository-form.tsx
📚 Learning: 2025-12-19T18:25:52.583Z
Learnt from: CR
Repo: nicotsx/zerobyte PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-19T18:25:52.583Z
Learning: Applies to app/server/{utils/restic.ts,modules/repositories/**/*.ts} : Restic repository URLs must be constructed using `buildRepoUrl()` utility for different backends (S3, Azure, GCS, local, rclone).
Applied to files:
app/client/lib/constants.tsapp/client/modules/repositories/tabs/info.tsx
📚 Learning: 2025-12-22T19:49:56.761Z
Learnt from: nicotsx
Repo: nicotsx/zerobyte PR: 197
File: app/client/modules/repositories/components/create-repository-form.tsx:112-112
Timestamp: 2025-12-22T19:49:56.761Z
Learning: When importing existing local repositories in the repositories service, users provide the full path (path + name) to an existing restic repository. Restic itself validates whether a valid repository exists at that location, so server-side path sanitization is not required for the import flow—the operation will fail if the path doesn't point to a valid restic repo.
Applied to files:
app/client/lib/constants.tsREADME.md
📚 Learning: 2025-12-22T19:49:56.761Z
Learnt from: nicotsx
Repo: nicotsx/zerobyte PR: 197
File: app/client/modules/repositories/components/create-repository-form.tsx:112-112
Timestamp: 2025-12-22T19:49:56.761Z
Learning: During the repository import flow, when users provide a full path to an existing restic repository, do not implement server-side path sanitization for this flow. Rely on Restic to validate the path; the operation will fail if the path does not point to a valid restic repository. This guidance applies to repository import components under app/client/modules/repositories (not just the specified file).
Applied to files:
app/client/modules/repositories/tabs/info.tsxapp/client/modules/repositories/components/repository-forms/local-repository-form.tsx
🧬 Code graph analysis (2)
app/client/modules/repositories/tabs/info.tsx (2)
app/server/db/schema.ts (1)
Repository(64-64)app/client/lib/constants.ts (1)
REPOSITORY_BASE(2-2)
app/client/modules/repositories/components/repository-forms/local-repository-form.tsx (1)
app/client/lib/constants.ts (1)
REPOSITORY_BASE(2-2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Agent
🔇 Additional comments (6)
README.md (1)
148-148: LGTM! Documentation accurately reflects the flexible path configuration.The updated description correctly clarifies that local repositories can use either the default subfolder or custom mounted paths, aligning well with the code changes in this PR.
app/client/lib/constants.ts (1)
1-2: LGTM! Clean constant extraction improves maintainability.Centralizing the repository base path into a shared constant eliminates duplication and makes future updates easier. The JSDoc comment provides clear context.
app/client/modules/repositories/components/repository-forms/local-repository-form.tsx (3)
4-4: LGTM! Proper constant usage.The import correctly references the centralized REPOSITORY_BASE constant.
34-34: LGTM! Consistent use of REPOSITORY_BASE constant.Both the display and DirectoryBrowser now correctly use the centralized constant as the default path fallback.
Also applies to: 87-87
57-59: LGTM! Improved messaging accuracy.The updated warning text correctly states the default path is "safe to use if you followed the recommended Docker Compose setup," which is more accurate than the previous claim that it was "already mounted."
app/client/modules/repositories/tabs/info.tsx (1)
124-129: LGTM! Useful addition for local repository visibility.The new "Effective Local Path" display provides helpful visibility into where local repositories are actually stored, especially when custom paths are used.
- Imported repositories use config.path directly (matching server logic) - Removed unused isImportedLocal variable
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
README.md (1)
148-148: Consider minor clarification for consistency and precision.The documentation update accurately reflects the new flexibility. Two optional improvements:
Trailing slash consistency: The text shows
/var/lib/zerobyte/repositories/with a trailing slash, butREPOSITORY_BASEis defined without one. Consider removing the trailing slash for consistency.Subfolder naming: Based on learnings, subfolders are named after the repository (e.g.,
<repo-name>). The phrase "subfolder of/var/lib/zerobyte/repositories/" could be slightly more explicit, such as: "subfolder within/var/lib/zerobyte/repositories(named after your repository)".These are minor polish items that can help readers understand the path structure more clearly.
🔎 Suggested clarification
-- **Local directories** - Store backups on local disk subfolder of `/var/lib/zerobyte/repositories/` or any other (mounted) path +- **Local directories** - Store backups in a subfolder within `/var/lib/zerobyte/repositories` (named after your repository) or any other (mounted) path
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
README.mdapp/client/modules/repositories/components/repository-forms/local-repository-form.tsxapp/client/modules/repositories/tabs/info.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- app/client/modules/repositories/tabs/info.tsx
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx,js,jsx,json}
📄 CodeRabbit inference engine (AGENTS.md)
Use Biome for code formatting and linting with
bunx biome check --write ., format only withbunx biome format --write ., or lint withbunx biome lint .
Files:
app/client/modules/repositories/components/repository-forms/local-repository-form.tsx
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx,js,jsx}: Use tabs (not spaces) for indentation with a line width of 120 characters
Use double quotes for strings
Do not auto-organize imports - imports organization is disabled in Biome
All imports must include file extensions when targeting Node/Bun, as the project uses"type": "module"
Files:
app/client/modules/repositories/components/repository-forms/local-repository-form.tsx
app/client/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
app/client/**/*.{ts,tsx}: Client uses TanStack Query for server state management
Client uses Radix UI primitives with custom Tailwind styling
Use Server-Sent Events hook (use-server-events.ts) for real-time updates in the client
Files:
app/client/modules/repositories/components/repository-forms/local-repository-form.tsx
🧠 Learnings (6)
📓 Common learnings
Learnt from: CR
Repo: nicotsx/zerobyte PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T17:31:39.171Z
Learning: Applies to app/server/modules/repositories/**/*.ts : Local repositories are stored in `/var/lib/zerobyte/repositories/<repo-name>`
Learnt from: CR
Repo: nicotsx/zerobyte PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T17:31:39.171Z
Learning: Applies to app/server/utils/restic.ts : Update `buildRepoUrl()` in `app/server/utils/restic.ts` when adding a new repository backend
📚 Learning: 2025-12-28T17:31:39.171Z
Learnt from: CR
Repo: nicotsx/zerobyte PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T17:31:39.171Z
Learning: Applies to app/server/modules/repositories/**/*.ts : Local repositories are stored in `/var/lib/zerobyte/repositories/<repo-name>`
Applied to files:
README.mdapp/client/modules/repositories/components/repository-forms/local-repository-form.tsx
📚 Learning: 2025-12-22T19:50:04.233Z
Learnt from: nicotsx
Repo: nicotsx/zerobyte PR: 197
File: app/client/modules/repositories/components/create-repository-form.tsx:112-112
Timestamp: 2025-12-22T19:50:04.233Z
Learning: When importing existing local repositories in the repositories service, users provide the full path (path + name) to an existing restic repository. Restic itself validates whether a valid repository exists at that location, so server-side path sanitization is not required for the import flow—the operation will fail if the path doesn't point to a valid restic repo.
Applied to files:
README.md
📚 Learning: 2025-12-28T17:31:39.171Z
Learnt from: CR
Repo: nicotsx/zerobyte PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T17:31:39.171Z
Learning: Applies to app/server/modules/repositories/repositories.dto.ts : Add DTO schemas in `app/server/modules/repositories/repositories.dto.ts` when adding a new repository backend
Applied to files:
app/client/modules/repositories/components/repository-forms/local-repository-form.tsx
📚 Learning: 2025-12-28T17:31:39.171Z
Learnt from: CR
Repo: nicotsx/zerobyte PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T17:31:39.171Z
Learning: Applies to app/server/utils/restic.ts : Update `buildRepoUrl()` in `app/server/utils/restic.ts` when adding a new repository backend
Applied to files:
app/client/modules/repositories/components/repository-forms/local-repository-form.tsx
📚 Learning: 2025-12-22T19:49:56.761Z
Learnt from: nicotsx
Repo: nicotsx/zerobyte PR: 197
File: app/client/modules/repositories/components/create-repository-form.tsx:112-112
Timestamp: 2025-12-22T19:49:56.761Z
Learning: During the repository import flow, when users provide a full path to an existing restic repository, do not implement server-side path sanitization for this flow. Rely on Restic to validate the path; the operation will fail if the path does not point to a valid restic repository. This guidance applies to repository import components under app/client/modules/repositories (not just the specified file).
Applied to files:
app/client/modules/repositories/components/repository-forms/local-repository-form.tsx
🧬 Code graph analysis (1)
app/client/modules/repositories/components/repository-forms/local-repository-form.tsx (1)
app/client/lib/constants.ts (1)
REPOSITORY_BASE(2-2)
🔇 Additional comments (1)
app/client/modules/repositories/components/repository-forms/local-repository-form.tsx (1)
34-34: LGTM! Excellent refactor to use centralized constant.Replacing the hardcoded path strings with
REPOSITORY_BASEimproves maintainability and ensures consistency across the display, warning message, and directory browser. The fallback logic correctly uses the constant when no custom path is set.Also applies to: 57-58, 87-87
Improve local repository path display and messaging
Changes
REPOSITORY_BASEto deduplicate hardcoded pathsSummary by CodeRabbit
Documentation
New Features
✏️ Tip: You can customize this high-level summary in your review settings.