CodeNomad/scripts
Pascal André 2570764c41
feat(files): initialize Git from the Files panel for plain folders (#933)
## Summary
When Git is available but the opened folder is not a repository
(temporary workspaces, plain folders), the Files panel's Changes and
Commits views now say so and offer **Initialize Git**. Directory-only
mode, where the backend cannot run Git, is unchanged.

## Design
- **Route:** `POST /api/workspaces/:id/git-init` accepts only the exact
opened folder.
- It refuses directory-only mode, folders already inside a repository,
unowned folders and folders being deleted.
- It checks that OpenCode resolves the same folder as the project
directory, then calls native `vcs.init` once, without retry.
  - A 501 maps to a localized "not supported" message.
- **Refresh after init:**
- The server re-reads the worktree inventory and resets the git-status
cache.
- The UI refreshes file caches, worktrees, project metadata and the
session list.
- Initialization changes the folder's native project ID, so stale
project metadata would otherwise leave later session pages empty.
- **No confirmation dialog:** creating `.git` is non-destructive and
easily undone.
- **Also fixed:** a spurious "detached HEAD" suffix on non-repository
folders in the worktree selector.

## Validation
- Server unit and route tests: authorization, refusals, 501, refresh.
- New browser regression `git-init.test.ts` (2/2): empty state, button,
refreshed Changes and branch, 501 message with no retry. The existing
Files panel suite passes 18/18.
- Isolated native check `scripts/test-git-init-native.mjs` against a
private OpenCode 2.0.27 daemon.
- Server and UI typechecks pass.

Oversized files touched: `workspaces/manager.ts` (~1307 lines) and
`lib/api-client.ts` (~809 lines).

An independent gatekeeper review will be published before the admin
merge.
2026-10-13 03:11:00 +02:00
..
fixtures
missions-child-environment
recurring-simple-native
winget
benchmark-session-history.mjs
bump-version.js
compare-user-html-rendering.mjs
desktop-server-resources.cjs
desktop-server-resources.test.cjs
native-fixture-diagnostics.mjs
native-fixture-diagnostics.test.mjs
native-fixture-guards.mjs
native-fixture-guards.test.mjs
native-product-fixture.mjs
prepare-node-runtime.cjs
prepare-node-runtime.test.cjs
preview-git-history.mjs
profile-outline-projection.mjs
profile-outline-responsiveness.mts
profile-streaming-responsiveness.mjs
profile-ui-motion.mjs
run-session-pruning-native.mjs
smoke-packaged-resources.cjs
test-attachment-picker-desktop.mjs
test-automation-native.mjs
test-blank-session-cleanup-native.mjs
test-compaction-isolation-native.mjs
test-electron-owner-close.mjs
test-git-degraded-native.mjs
test-git-init-native.mjs feat(files): initialize Git from the Files panel for plain folders (#933) 2026-10-13 03:11:00 +02:00
test-missions-native-contract.mjs
test-missions-native-family-control.mjs
test-missions-native-trajectory.mjs
test-missions-native.mjs
test-native-event-relay.mjs
test-native-worktree-management.mjs
test-opencode-history-migration.mjs
test-opencode-install-native.mjs
test-opencode-location-native.mjs
test-opencode-proxy-native.mjs
test-opencode-setup-desktop.mjs
test-opencode-setup-wsl.mjs
test-opencode-upgrade-native.mjs
test-panel-extension-native.mjs
test-pending-snapshot-native.mjs
test-permission-receipts-native.mjs
test-plugin-runtime-native.mjs
test-prompt-skills-native.mjs
test-provider-account-selection-native.mjs
test-provider-accounts-native.mjs
test-provider-usage-native.mjs
test-recurring-simple-native.mjs
test-release-workspace-version.mjs
test-render-cost-audit.mjs
test-session-aside-native.mjs
test-session-environment-native.mjs
test-session-fork-native.mjs
test-session-history-native.mjs
test-session-interrupt-native.mjs
test-session-navigation-native.mjs
test-session-pruning-native.mjs
test-session-pruning-ui.mjs
test-subagent-depth-settings-native.mjs
test-tauri-f6.ps1
test-tauri-input-deadlock.mjs
test-tauri-macos-window-result.test.mjs
test-tauri-macos-window.mjs
test-tauri-view-menu.mjs
test-temporary-workspaces-native.mjs
test-websearch-settings-native.mjs
test-worktree-families-native.mjs
verify-bundled-node.cjs