Skip to content

Conversation

@tvarohohlavy
Copy link
Contributor

@tvarohohlavy tvarohohlavy commented Dec 23, 2025

Improve local repository path display and messaging

Changes

  • Created shared client constants file (constants.ts) with REPOSITORY_BASE to deduplicate hardcoded paths
  • Added effective local path display in repository info tab for local repositories
  • Updated host mount warning to clarify the default path is safe when using the recommended Docker Compose setup (instead of incorrectly claiming it's "already mounted")
  • Updated README to clarify local repositories can use custom mounted paths and that they are subfolders with no explicit name

Summary by CodeRabbit

  • Documentation

    • Clarified that local repository storage supports configurable locations rather than a single fixed path.
  • New Features

    • Local repositories can be stored in alternative (mounted) paths beyond the previous default.
    • Repository info now shows the computed "Effective Local Path" when applicable.

✏️ Tip: You can customize this high-level summary in your review settings.

- 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
Copilot AI review requested due to automatic review settings December 23, 2025 11:26
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 23, 2025

Note

Other AI code review bot(s) detected

CodeRabbit 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.

Walkthrough

Extracts 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

Cohort / File(s) Summary
Constants Module
app/client/lib/constants.ts
New file exporting REPOSITORY_BASE with value "/var/lib/zerobyte/repositories".
Local Repository Form
app/client/modules/repositories/components/repository-forms/local-repository-form.tsx
Replaced hardcoded "/var/lib/zerobyte/repositories" with REPOSITORY_BASE in displayed path, DirectoryBrowser selectedPath, and explanatory warning text; added import for the constant.
Repository Info Tab
app/client/modules/repositories/tabs/info.tsx
Added non-exported getEffectiveLocalPath(repository) using REPOSITORY_BASE; computes effectiveLocalPath and conditionally renders an "Effective Local Path" monospaced UI block when applicable.
Documentation
README.md
Updated description of local directories repository storage from a fixed path to a local disk subfolder of "/var/lib/zerobyte/repositories" or any other (mounted) path (configurable).

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main objective of the changeset: improving the display and messaging around local repository paths by introducing a shared constant, displaying the effective local path in the info tab, and updating documentation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2d6c939 and 86263fe.

📒 Files selected for processing (1)
  • README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • README.md

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

Copilot AI left a 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_BASE to 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

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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:

  1. The function is invoked twice (line 124 for conditional check, line 127 for display), causing redundant computation on each render.
  2. Path concatenation using ${basePath}/${config.name} could produce double slashes if config.path includes 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

📥 Commits

Reviewing files that changed from the base of the PR and between 3a54f11 and cd9f5a9.

📒 Files selected for processing (4)
  • README.md
  • app/client/lib/constants.ts
  • app/client/modules/repositories/components/repository-forms/local-repository-form.tsx
  • app/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.ts
  • app/client/modules/repositories/tabs/info.tsx
  • app/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.ts
  • app/client/modules/repositories/tabs/info.tsx
  • app/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.ts
  • app/client/modules/repositories/tabs/info.tsx
  • app/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.tsx
  • app/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.ts
  • app/client/modules/repositories/tabs/info.tsx
  • app/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.ts
  • app/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.ts
  • app/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.ts
  • README.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.tsx
  • app/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
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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:

  1. Trailing slash consistency: The text shows /var/lib/zerobyte/repositories/ with a trailing slash, but REPOSITORY_BASE is defined without one. Consider removing the trailing slash for consistency.

  2. 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

📥 Commits

Reviewing files that changed from the base of the PR and between a921fa4 and 2d6c939.

📒 Files selected for processing (3)
  • README.md
  • app/client/modules/repositories/components/repository-forms/local-repository-form.tsx
  • app/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 with bunx biome format --write ., or lint with bunx 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.md
  • app/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_BASE improves 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

@nicotsx nicotsx merged commit 86263fe into nicotsx:main Jan 5, 2026
3 checks passed
@tvarohohlavy tvarohohlavy deleted the local-repo-enhancements branch January 6, 2026 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants