CodeNomad/scripts/preview-git-history.mjs
Pascal André ee5f7382d7
feat(files): unify Workspace, Changes and Commits with central previews (#797)
## Summary

Unify the right-panel Git and file surfaces as **Files**, with a compact
**Workspace / Changes / Commits** switch and a shared central preview
above the
conversation composer.

- Workspace: lazy, keyboard-accessible directory tree; read-only source,
  Markdown and image previews; bounded binary-file fallback.
- Changes: indexed/working-tree files and central diffs, with existing
Git
  mutations kept in a collapsed actions section.
- Commits: paginated history of the browsed worktree, commit
details/files and
first-parent diffs, including root commits, renames, deletions and
gitlinks.
- Preserve drafts and mode navigation; fence late responses across
session and
worktree changes. Migrate previous tab customization and retain
diff/wrap
preferences. Bundle Monaco tokenizers locally for offline highlighting.
- Worktree browsing does not move a conversation or check out a branch.

## Implementation

The common Solid UI is used by Electron and Tauri. New file previews
reuse the
directory ownership boundary and bounded filesystem reader. Historical
reads use
worker Git commands with full-hash validation, authoritative file
membership,
bounded command output/time and snapshot-based paging. The old sidebar
editor
and split viewer are retired. See `dev-docs/FILES_PANEL.md`.

## Validation

Before rebasing onto current dev:
- Server, UI and Electron typechecks passed.
- Server/UI and Electron builds passed.
- 20 focused unit/route tests passed, including real isolated root and
linked
  repositories, preview bounds and directory ownership.
- 12 distinct browser scenarios passed: 5 Files flows (including real
SessionView/composer, Markdown/images/source and RTL keyboard
navigation) and
  7 existing Git lifecycle regressions.

Post-rebase validation, independent gatekeeper reviews and the Windows
Tauri
test build will be recorded below as they complete. This PR is intended
for
interactive validation before merge.
2026-10-01 11:10:50 +02:00

29 lines
1.5 KiB
JavaScript

// Interactive design fixture using the production Git panel and central reader.
// Synthetic data only; does not connect to OpenCode or mutate a repository.
import { fileURLToPath } from "node:url"
import { createServer } from "vite"
import solid from "vite-plugin-solid"
import { prepareGitPrototypeAssets } from "../packages/ui/tests/browser/fixtures/git-history-assets.mjs"
prepareGitPrototypeAssets()
const server = await createServer({
configFile: false,
root: fileURLToPath(new URL("../packages/ui/", import.meta.url)),
publicDir: fileURLToPath(new URL("../packages/ui/src/renderer/public", import.meta.url)),
plugins: [solid(), {
name: "git-history-prototype",
configureServer(server) {
server.middlewares.use("/fixture", async (_request, response) => {
response.setHeader("Content-Type", "text/html")
response.end(await server.transformIndexHtml("/fixture", '<html><head><title>CodeNomad · Files prototype</title></head><body><div id="root"></div><script type="module" src="/tests/browser/fixtures/git-history.tsx"></script></body></html>'))
})
},
}],
resolve: { dedupe: ["solid-js"] },
optimizeDeps: { exclude: ["lucide-solid"] },
server: { host: "127.0.0.1", port: 0, hmr: false, watch: null },
})
await server.listen()
console.log(`Git prototype: http://127.0.0.1:${server.httpServer.address().port}/fixture`)
for (const event of ["SIGINT", "SIGTERM"]) process.on(event, () => { void server.close().then(() => process.exit()) })