Repository navigation
Backend Services
Backend covers commands, errors, the git CLI runner and the watcher. This page maps everything else in src-tauri/src/. Each service has a feature chapter with the details; this page shows how they fit the backend's rules.
Memory is a feature (see Architecture), so every service starts empty and starts threads only when a feature asks. When the feature closes or is switched off, the threads stop and the memory is given back.
flowchart LR
State["AppState"] --> Terms["terminals<br/>TerminalRegistry"]
State --> Search["file_search<br/>files, symbols, text"]
State --> Console["git_console<br/>ring buffer"]
State --> Mcp["mcp<br/>server and tools"]
State --> Log["memory_log<br/>sampler thread"]
Terms -->|"first terminal or script run"| PTY["PTY plus writer, reader<br/>and waiter threads"]
Search -->|"popup opens"| Walk["ripgrep walker threads"]
Search -->|"2 minutes idle"| Drop["index dropped"]
Console -->|"setting on"| Rec["records git commands"]
Mcp -->|"a switch on"| Http["listener on 127.0.0.1"]
Log -->|"setting on"| Thread["reads memory each interval"]
-
terminal.rsfinds the installed shells (/etc/shellson macOS and Linux; PowerShell, Command Prompt and Git Bash on Windows) and runs them in pseudo terminals withportable-pty. Each terminal has a writer, a reader and a waiter thread. Closing hangs up the shell's process group and kills it after a grace period; app exit kills every shell, so none is left behind. -
run_process.rsruns a project script as its own process in a PTY, with no shell typed into. It uses the login shell's environment (read once with$SHELL -l -i -c, cached, refreshed when the Scripts panel refreshes) and puts the chosen Node version first onPATH. Runs share the terminal registry.
See How the Terminal Works and How Scripts Work.
-
scripts/readspackage.json(npm, yarn, pnpm or bun),composer.json,Makefile,deno.jsonandjustfile;node_wanted.rsfinds the Node version a package asks for. Nothing is cached; every call rescans. -
node_versions.rslists Node versions installed by version managers and Homebrew by reading folders only; it never startsnode. The Windows layouts are not compile checked on Windows yet.
All search shares one file list, so it follows one set of walker rules (.gitignore respected), and the watcher marks it stale when files change.
-
file_search.rs: an in-memory index built by theignorecrate (ripgrep's walker), matched withnucleo-matcher. Queries answer from a partly built index and never wait. At most 500,000 files; dropped after 2 minutes without use. -
symbols/: definitions found by small line scanners per language, like universal ctags, stored compactly beside the file index. -
text_search.rs: Find in Files with ripgrep'sgrep-searcher, streamed in batches and capped at 2,000 lines or 300 files.text_search/replace.rswrites atomically and never touches files with unsaved edits. See How Search Everywhere Works and How Find and Replace Works.
-
git_console.rsrecords every commandgit/cli.rsruns (at most 500, with 16 KB of output each and 4 MB in all), masking tokens and passwords first. It starts off and records nothing until the Git Console setting is on. See How the Git Console Works. -
shelf/keeps shelved changes as<id>.patchand<id>.jsonin<git dir>/nibtree-shelf/, so they stay with the repository and are never committed. See How the Shelf Works. -
git/worktree.rs,git/submodule.rs,git/lfs.rsread with git2 where it can (submodules, LFS patterns) and change everything through the git CLI. See How Worktrees Work, How Submodules Work and How Git LFS Works. -
git/history.rsrunsgit log --followandgit log -Lfor file and line history, which libgit2 cannot do. -
git/cancel.rsruns a long command (clone) in its own process group under a cancel id, so Cancel stops git and its helpers together. -
commands/rebase_merges.rslays out an interactive rebase todo that keeps merge commits. See How Interactive Rebase Works.
The token lives only in the system keychain (secrets.rs, the keyring crate) or comes from gh auth token when needed (gh.rs); ~/.nibtree/github.json keeps only the login. The REST client uses a blocking ureq agent on the system TLS stack, so no async runtime or bundled certificates enter the binary. Network, keychain and gh sit behind traits, so the tests use fakes. See How GitHub Works.
A local MCP (Model Context Protocol) server lets AI tools and nibtree cli use the app. It is off by default; while both switches are off nothing listens and no thread runs.
-
http.rsserves Streamable HTTP on127.0.0.1only, with our own loop aroundhttparse, at most 8 connections and 1 MB bodies, so it can stop every thread when switched off. -
token.rskeeps the bearer token in~/.nibtree/mcp.json, readable by you only;paths.rslimits tools to the workspace folders open in the app. -
tools/holds the backend tools, which call the same Rust functions as the app's own commands.bridge.rssends tools the window must run asmcp-ui-requestevents and waits up to 30 seconds formcp_ui_respond. -
mcp::cliis the command line client, its own crate insrc-tauri/cli:lib.rshandsnibtree cli ...to it before any window opens.install.rslinks it into~/.local/bin(anibtree.cmdon Windows).
See How MCP and CLI Work.
-
memory_log.rs: the debug memory log (Settings > Automation). While on, a thread writes a line to~/.nibtree/logs/memory.logwhen memory changes by the threshold, plus the UI events the window reports; past 5 MB it keeps the old file asmemory.log.1. See Debugging. -
images.rs: local images for the Markdown preview as data URLs, only from the document's workspace folder. See How the Markdown Editor Works. -
preview_scheme.rsandmedia.rs: thegmpreviewURL scheme that streams images and PDFs to the previews, only from the open workspace folders, idle until a preview asks. See How the Preview Scheme Works. -
memory.rs: the memory readout of the status bar, also used by the memory log and the MCP performance tools. -
terminal_memory.rs: each terminal's memory for the details popup, its shell's whole process tree (how).
Keep it behind a field in AppState (or a module with no state at all), start threads only on first use, stop them when the feature closes, and put anything that talks to the network, the keychain or another program behind a trait so the tests can replace it. Add its commands to the right Commands page and its tests to Test Suites.
These pages are generated from docs/wiki. To correct something, open a pull request against the source file; edits made here are overwritten.
Using Nibtree
- Getting Started
- Welcome Screen
- Workspaces
- Files Panel
- File Operations
- File Icons
- Rounded Panels
- Editor and Tabs
- Pin Reorder and Wrap Tabs
- Single Tab Title
- Split Editor
- New File and Unsaved Changes
- Unload Hidden Tabs
- Editing Code
- Code Appearance
- Markdown Editor
- Image and PDF Preview
- Search Everywhere
- Recent Files
- Navigation Bar
- Find and Replace
- Changes and Commits
- Sign In Prompts
- Commit Box Layout
- Repository Actions
- Commit Options
- Ignoring Files
- Diffs
- Inline Diffs
- Staging View
- Revert a Change
- Resolving Conflicts
- Merge Tool
- Blame
- History and Log
- Merge Commits
- Branches and Tags
- Branches Popup
- Remotes
- Stashes
- Shelf
- Git Menu
- Git Dialogs
- Interactive Rebase
- Worktrees
- AI Agents
- AI Tasks
- AI Usage
- Keep Computer Awake
- Submodules
- Git LFS
- GitHub
- Git Console
- Terminal
- Terminal Features
- Scripts
- Navigation
- Menus
- Settings
- Settings Search
- Color Themes
- Settings Terminal and Automation
- Settings Files
- Updates
- Status Bar and Help
- Notifications
- Memory Use
- Clear Cache
- MCP and CLI
- Git Mergetool
- Keyboard Shortcuts
- Keyboard Shortcuts Editor
- Troubleshooting
- Troubleshooting Git
Developers
- Developer Guide
- Architecture
- Project Layout
- Backend
- How Folder Watching Works
- Folder Watching Bugs We Fixed
- How Workspace Files Work
- How the Preview Scheme Works
- Backend Services
- How Terminal Features Work
- Terminal Bugs We Fixed
- Frontend
- How the Rich Markdown Editor Works
- Rich Markdown Bugs We Fixed
- Git Menu Links
- Menu Keys and Routing
- Frontend Modules
- Blame Bugs We Fixed
- Project Color And Title Bar
- One Diff View
- Diff Bugs We Fixed
- Merge Tool Layouts
- Merge Tool Bugs We Fixed
- Color Theme Bugs We Fixed
- How the Connected Diff Works
- Rounded Panels Bugs We Fixed
- Update Bugs We Fixed
- Status Bar Bugs We Fixed
- MCP and CLI Bugs We Fixed
- Repository Actions Bugs We Fixed
- How the Changes Tab Works
- CodeMirror Patterns
- How the Cursor Works
- How Editor Features Work
- How the Path Bar Works
- Commands and Events
- Settings Reference
- Commands Workspace and Changes
- Commands Branches and Remotes
- Commands History and Extras
- Commands App and Tools
- Testing
- Test Suites
- Debugging
- Debugging with MCP
- Measuring Setting Memory
- How Terminal Memory Is Measured
- How Markdown Diagrams Work
- Releases and CI
- Publishing the Wiki
- Versioning and Changelog
- Browser Version Packages
- Browser Release Checks
- Docker Image
- Platforms and Signing
- Windows Support
- Windows Bugs We Fixed
- Windows MCP and CLI
- Docs and Screenshots
- UI Library
- UI Library MCP
- UI Library Bugs
- UI Library Migration
- Contributing
How features work
- Welcome screen
- Workspaces and folders
- Files panel
- File operations
- File icons
- Editor and tabs
- Pin, reorder and wrap tabs
- Single tab title
- Split editor
- New File and unsaved changes
- Unload hidden tabs
- Editing code
- Code appearance
- Markdown editor
- Image and PDF preview
- Search Everywhere
- Recent Files
- Navigation Bar
- Find and replace
- Changes and commits
- Sign-in prompts
- Commit box layout
- Repository actions
- Commit options
- Ignoring files
- Diffs
- Inline diffs
- Staging view
- Revert a change
- Resolving conflicts
- Merge tool
- Blame
- History and log
- Merge commits
- Commit tabs
- Branches and tags
- Branches popup
- Remotes
- Stashes
- Shelf
- Git menu
- Git dialogs
- Interactive rebase
- Worktrees
- AI agents
- AI usage
- Keep computer awake
- AI tasks
- Submodules
- Git LFS
- GitHub account
- Git Console
- Back and Forward
- Integrated terminal
- Scripts tool window
- Menu bar
- Settings
- Search in Settings
- Color themes
- Rounded panels
- Updates and release channels
- Status bar and help links
- Notifications
- Memory readout and memory log
- Clear Cache
- MCP server and command line tool
- git mergetool mode