Skip to content

fix(desktop): show content for new files in changes sidebar#794

Merged
Kitenite merged 2 commits into
mainfrom
new-file-empty-in-git
Jan 18, 2026
Merged

fix(desktop): show content for new files in changes sidebar#794
Kitenite merged 2 commits into
mainfrom
new-file-empty-in-git

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Jan 17, 2026

Summary

git status without -uall shows untracked directories as single entries (e.g., .source/) instead of individual files inside. When the UI tries to read content for a directory path, it fails because directories can't be read as files.

Adding -uall flag shows all individual untracked files, allowing the changes sidebar to display and read each file correctly.

Test plan

  • Create a new folder with files (e.g., .source/file1.txt, .source/file2.txt)
  • Verify the changes sidebar shows individual files, not just the folder
  • Click on each file and verify content is displayed correctly

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 17, 2026

Warning

Rate limit exceeded

@Kitenite has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 25 minutes and 30 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 8396037 and 9f9765b.

📒 Files selected for processing (1)
  • apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts
📝 Walkthrough

Walkthrough

The changes enhance file content handling by introducing a safer disk reading utility with size limits and improving git status tracking. The file-contents router now passes worktree context to staged version retrieval and uses fallback-to-disk logic when git index content is unavailable. Git status invocation gains the -uall flag to list individual untracked files rather than directories only.

Changes

Cohort / File(s) Summary
File Content Safe Reading
apps/desktop/src/lib/trpc/routers/changes/file-contents.ts
Added safeReadFromDisk() helper for bounded file reading with error handling. Modified getStagedVersions() signature to accept worktreePath parameter. Updated getFileVersions() and getUnstagedVersions() to use the new helper and improved fallback logic when git index content is empty.
Git Status Tracking
apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts
Added -uall flag to git status command in getStatusNoLock() to expand untracked directory listings into individual file entries rather than directory-level entries.

Sequence Diagram(s)

sequenceDiagram
    participant Router as TRPC Router
    participant Git as Git Operations
    participant Disk as File System
    
    Router->>Git: getIndexContent(filePath)
    Git-->>Router: index content (may be empty)
    
    alt Index content exists
        Router->>Router: Use git index content
    else Index content empty
        Router->>Disk: safeReadFromDisk(worktreePath, filePath)
        Note over Disk: Check size limit, read with error handling
        Disk-->>Router: File content or empty string
        Router->>Router: Use disk fallback
    end
    
    Router-->>Router: Return versioned file content
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit's tale of files most fair,
Safe reading paths beyond compare!
With fallback logic, clever and sound,
Git and disk in harmony bound.
Untracked files now dance and shine,
Each one listed—oh, how divine! 🌟

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The pull request description is incomplete and missing required sections from the template. Add the missing sections: 'Related Issues', 'Type of Change' (with selection), 'Testing' (with detailed test results), 'Screenshots', and 'Additional Notes' to match the repository template structure.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and clearly summarizes the main change: fixing the display of content for new files in the changes sidebar, which is the primary objective addressed by both commits.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

git status without -uall shows untracked directories as single entries
(e.g., ".source/") instead of individual files. When the UI tries to
read content for a directory path, it fails silently.

Adding -uall shows all individual untracked files, allowing the changes
sidebar to display and read each file correctly.
@Kitenite Kitenite force-pushed the new-file-empty-in-git branch from 8396037 to d76c19b Compare January 18, 2026 18:54
@Kitenite Kitenite merged commit 79f2aeb into main Jan 18, 2026
5 checks passed
@Kitenite Kitenite deleted the new-file-empty-in-git branch January 18, 2026 18:57
@github-actions
Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch
  • ⚠️ Electric Fly.io app

Thank you for your contribution! 🎉

saddlepaddle pushed a commit that referenced this pull request Jan 18, 2026
git status without -uall shows untracked directories as single entries
(e.g., ".source/") instead of individual files. When the UI tries to
read content for a directory path, it fails silently.

Adding -uall shows all individual untracked files, allowing the changes
sidebar to display and read each file correctly.
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.

1 participant