Skip to content

Phase 35: add native desktop repository browser - #51

Merged
tonibergholm merged 5 commits into
mainfrom
codex/phase-35-desktop-app
Jul 14, 2026
Merged

tonibergholm merged 5 commits into
mainfrom
codex/phase-35-desktop-app

Conversation

@tonibergholm

Copy link
Copy Markdown
Member

Summary

  • add the first native Tauri v2 desktop slice under apps/desktop/
  • browse native .sc branches, snapshot DAG history, provenance, trees, files, and first-parent changes
  • preserve protected-content and private-branch opacity through a narrow typed IPC boundary
  • document the desktop adapter, WebView trust boundary, development workflow, and architectural decisions

Why

Phase 35 proves that src-control's native object model can power a polished desktop experience without parsing CLI output or translating through Git. The slice is deliberately read-only and keyless so the new WebView boundary does not expand the repository's secret or mutation surfaces.

User and developer impact

Users can open an existing .sc repository and inspect local and remote-tracking branches, merge topology, signatures, transcript presence, public files, and first-parent comparisons. Protected files render as locked and unauthorized private branches remain opaque. Developers get exact setup and build commands, typed Rust/TypeScript DTOs, regression tests, and replaceable @pierre/trees and @pierre/diffs presentation adapters.

Validation

  • cargo test --workspace
  • cargo clippy -p scl-desktop --all-targets -- -D warnings
  • npm run typecheck
  • npm test -- --run
  • npm run tauri build -- --bundles app

The production macOS .app bundle completed successfully, and the PR includes screenshots for the main browser, protected comparison, and private-branch states.

These documents lay out strategic direction for the future productization of
`sc`. They cover recommendations, product shape, MVP features, technical
approaches, and security boundaries for both a desktop application and a native
hosting platform.

The desktop app is proposed as the stronger initial product surface,
emphasizing `sc`'s unique semantics and keeping sensitive data local. The
platform strategy focuses on a narrow native collaboration product for `sc`'s
differentiated features, with continued GitHub interoperability.
@tonibergholm
tonibergholm marked this pull request as ready for review July 14, 2026 08:05
@tonibergholm
tonibergholm requested a review from Copilot July 14, 2026 08:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds the Phase 35 native desktop “read-only repository browser” slice, introducing a new apps/desktop/ Tauri v2 + React/TypeScript application plus supporting ADR/design/threat-model documentation, while keeping protected/private content opaque via a narrow typed IPC boundary.

Changes:

  • Adds a new Tauri v2 desktop app (apps/desktop/) with a Rust read-model adapter and bundled React UI for browsing refs, snapshot DAG, trees, files, and first-parent diffs.
  • Extends architecture/roadmap/ADR/threat-model docs to cover the desktop/WebView trust boundary and Phase 35 scope.
  • Integrates the desktop Rust crate into the workspace and adds frontend build/test tooling and ignores.

Reviewed changes

Copilot reviewed 36 out of 61 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
ROADMAP.md Records Phase 34/35 descriptions and completion status.
docs/THREAT-MODEL.md Adds explicit WebView/desktop trust-boundary section for Phase 35.
docs/research/platform-strategy.md New research note on native hosting/platform direction.
docs/research/desktop-app-strategy.md New research note on desktop strategy and scope.
docs/design/phase-35-desktop-app.md New design doc defining the typed IPC boundary and DTO states.
docs/adr/README.md Registers ADR-0044 and ADR-0045 in the ADR index.
docs/adr/0045-native-desktop-read-model.md New ADR defining the desktop adapter, IPC boundary, and confidentiality behavior.
CLAUDE.md Updates repo guide: adds desktop slice, commands, and Phase 35 capability notes.
Cargo.toml Adds apps/desktop/src-tauri to the workspace members.
ARCHITECTURE.md Updates workspace description and adds Phase 35 architecture notes.
apps/desktop/vite.config.ts Adds Vite/Vitest config for the desktop renderer bundle.
apps/desktop/tsconfig.node.json Adds TS config for node-side tooling (Vite config).
apps/desktop/tsconfig.json Adds TS project references for app + node configs.
apps/desktop/tsconfig.app.json Adds strict TS config for the React renderer.
apps/desktop/src/vite-env.d.ts Adds Vite env type reference.
apps/desktop/src/test/setup.ts Adds Vitest + DOM test setup/mocks.
apps/desktop/src/test/DemoApp.tsx Adds dev-only demo fixtures used for screenshots.
apps/desktop/src/styles/app.css Adds desktop UI styling for the three-panel browser.
apps/desktop/src/model.ts Defines renderer-side DTO types mirroring the IPC boundary.
apps/desktop/src/main.tsx Adds app entrypoint + dev-only demo loading.
apps/desktop/src/components/RepositoryTree.tsx Adds Pierre Trees adapter for browsing snapshot paths.
apps/desktop/src/components/PresentationSpike.test.tsx Adds smoke tests that Pierre components mount correctly.
apps/desktop/src/components/FileSurface.tsx Adds Pierre Diffs/File rendering with locked/binary/unavailable states.
apps/desktop/src/App.tsx Implements the main browser UI and typed async flow handling.
apps/desktop/src/App.test.tsx Adds renderer tests for flows (open, errors, navigation, locked/private states).
apps/desktop/src/api.ts Adds typed IPC wrapper over Tauri invoke.
apps/desktop/src-tauri/tauri.conf.json Adds Tauri v2 config including CSP/dev CSP.
apps/desktop/src-tauri/src/read_model.rs Implements Rust read-model adapter enforcing reachability/path constraints and confidentiality states.
apps/desktop/src-tauri/src/main.rs Adds Tauri binary entry calling scl_desktop::run().
apps/desktop/src-tauri/src/lib.rs Exposes run() for launching the desktop shell.
apps/desktop/src-tauri/src/commands.rs Implements the five-command typed IPC surface + repo selection dialog.
apps/desktop/src-tauri/icon.svg Adds desktop app icon.
apps/desktop/src-tauri/Cargo.toml Adds scl-desktop crate dependencies and build deps.
apps/desktop/src-tauri/capabilities/default.json Adds minimal Tauri capability configuration.
apps/desktop/src-tauri/build.rs Adds Tauri build script hook.
apps/desktop/README.md Documents desktop dev workflow, security boundary, and screenshot fixtures.
apps/desktop/package.json Adds renderer dependencies/scripts (Vite/Vitest/Tauri CLI).
apps/desktop/index.html Adds renderer HTML entry.
.gitignore Ignores desktop build artifacts and generated capability schemas.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +96 to +102
if (mode === "locked") {
const timer = window.setTimeout(() => {
Array.from(document.querySelectorAll<HTMLButtonElement>("[role=tab]")).find((button) => button.textContent === "changes")?.click();
window.setTimeout(() => Array.from(document.querySelectorAll<HTMLButtonElement>(".change-pane button")).find((button) => button.textContent?.includes("release.env"))?.click(), 100);
}, 250);
return () => window.clearTimeout(timer);
}
Comment on lines +11 to +33
const paths = useMemo(() => files.map((file) => file.path), [files]);
const filePaths = useMemo(() => new Set(paths), [paths]);
const { model } = useFileTree({
paths,
initialExpansion: 1,
flattenEmptyDirectories: true,
search: paths.length > 8,
density: "compact",
onSelectionChange(selected) {
const path = selected.at(-1);
if (path && filePaths.has(path)) onSelect(path);
},
renderRowDecoration({ item }) {
const file = files.find((candidate) => candidate.path === item.path);
if (file?.contentState === "protected_locked") {
return { text: "locked", title: "Protected content is locked" };
}
if (file?.contentState === "binary") {
return { text: "binary" };
}
return null;
},
});

@tonibergholm tonibergholm left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall the design is sound — the WebView trust boundary is well-defined, protected and private-branch content is correctly redacted at the Rust layer, and the dependency rules are respected. A few issues need to be addressed before merge:

Must fix before merge

  • TreeFileView.contentState includes "binary" which tree_view() never emits — dead branch in RepositoryTree.tsx that will silently misbehave if the type union is ever narrowed (inline comment on model.ts)
  • validate_relative_path does not reject null bytes — security-relevant, easy fix (inline comment on read_model.rs)
  • compare_first_parent has no size cap before loading both blob sides — can spike memory on large local blobs (inline comment on read_model.rs)

Should fix

  • reachable_snapshot re-walks the full DAG on every read_file / compare_first_parent call — will be visibly slow on real repos (inline comment on read_model.rs)
  • Mutex vs RwLock choice for the read-only command set needs either a fix or an explanatory comment (inline comment on commands.rs)
  • $schema in capabilities/default.json points to a gitignored generated file, breaking fresh-checkout IDE experience
  • CLAUDE.md and ARCHITECTURE.md disagree on whether tlsio depends on core

Nice to have

  • O(n²) files.find in RepositoryTree.tsx renderRowDecoration — easy useMemo Map fix
  • load_trust_map silently returns empty on parse errors, making corrupt-trust-file and missing-key indistinguishable in the UI
  • from_repo leaks raw Rust error strings to the UI error card
  • @pierre/trees pre-release pin semantics and missing registry note for contributors

Generated by Claude Code

Comment thread apps/desktop/src/model.ts Resolved
Comment thread apps/desktop/src-tauri/src/commands.rs Resolved
fn reachable_snapshot(
&self,
repo: &Repo,
snapshot_id: &str,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Performance: full DAG re-walk on every file access

reachable_snapshot is called by snapshot_details, read_file, and compare_first_parent. Each call opens a fresh Repo, collects all public refs, and walks the entire commit graph to verify the supplied snapshot id is reachable. On a repo with thousands of commits and the user clicking through files in the inspector, this means multiple full DAG walks per interaction.

The session flow already guarantees ordering: the frontend only calls read_file / compare_first_parent after select_reference has returned a HistoryView containing the snapshot id. Caching the reachable set (even just as a HashSet<ObjectId> in AppState alongside the repo path, invalidated on choose_repository) would reduce these to O(1) lookups.

Alternatively, add a bounded walk with a depth cap as a short-term guard against latency spikes on large repos.


Generated by Claude Code

Comment thread apps/desktop/package.json Resolved
Comment thread CLAUDE.md Resolved

@tonibergholm tonibergholm left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review after f6da8dd + cf84d5e

Excellent response to the review — all 10 must/should items are addressed and most of the nice-to-haves landed too. Resolved threads accordingly.

Fixed ✅

Finding How addressed
"binary" dead-code in tree panel TreeContentState = "public_available" | "protected_locked" — RepositoryTree no longer references ContentView's discriminants
O(n²) renderRowDecoration useMemo + Map<string, TreeFileView> — O(1) lookup
Mutex serialising reads Comment added explaining the guard is released immediately after clone, before any I/O — the design is intentional and correct
reachable_snapshot full re-walk per call Arc<RwLock<HashSet<ObjectId>>> in DesktopRepository — cache checked first, populated on first walk, shared across clones
Null byte in validate_relative_path !path.contains('\0') added
No size cap before diffing MAX_RENDER_BYTES = 4 MiB cap, ContentView::TooLarge returned + rendered in the UI
from_repo leaks raw error strings Matched variant-by-variant to human-readable messages; raw to_string() no longer crosses IPC
load_trust_map silent on parse errors Only NotFound returns empty map; unreadable or malformed files now surface "repository_error" / "corrupt_repository"
$schema pointing to gitignored file Now https://schema.tauri.app/config/2
@pierre/trees pre-release ^ range Exact-pinned to 1.0.0-beta.5; README note added explaining both packages resolve from the public registry
CLAUDE.md/ARCHITECTURE.md tlsio disagreement ARCHITECTURE.md now shows repo → tlsio as a separate leaf edge, consistent with the "not even core" clause
Copilot: tree_view marks missing partial-clone blobs as readable store.blob_size checked before marking public_available; missing blobs surface ContentView::Unavailable (resolved by author)
Copilot: DemoApp setTimeout leak clearTimeout cleanup added in all timer paths

One minor follow-on (inline comment on read_model.rs)

select_reference walks the full DAG but doesn't write the results into self.reachable, so the first read_file call after each reference switch still triggers a second walk before the cache warms. Easy fix, not a blocker.

This is ready to merge once the CI is green.


Generated by Claude Code

let valid = !path.is_empty()
&& !path.starts_with('/')
&& !path.contains('\\')
&& !path.contains('\0')

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up on DAG re-walk: cache is correct but warms lazily

The Arc<RwLock<HashSet<ObjectId>>> reachable cache is a good fix — subsequent read_file / compare_first_parent calls within a session are O(1) after the first hit. One gap remains: select_reference performs a full DAG walk and populates a local seen set, but does not write those ids into self.reachable. This means the first read_file call after switching a reference still triggers a second full walk before the cache warms.

Cheapest fix — at the end of select_reference's walk loop, extend the shared cache with the local seen set:

// after the while loop in select_reference:
if let Ok(mut guard) = self.reachable.write() {
    guard.extend(seen.iter().copied());
}

This is a minor latency improvement (one extra walk per reference switch), not a correctness issue, so happy to leave it as a follow-on ticket rather than blocking merge.


Generated by Claude Code

@tonibergholm
tonibergholm merged commit 11957c2 into main Jul 14, 2026
6 checks passed
@tonibergholm
tonibergholm deleted the codex/phase-35-desktop-app branch July 14, 2026 09:39
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