gitspace 0.2.0-rc.20 → 0.2.0-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +11 -6
- package/.claude/settings.local.json +0 -10
- package/.gitspace/bundle.json +0 -50
- package/.gitspace/events.json +0 -11
- package/.gitspace/processes.json +0 -23
- package/.gitspace/scripts/select/01-status.sh +0 -39
- package/.gitspace/scripts/setup/01-install-deps.sh +0 -12
- package/.gitspace/scripts/setup/02-typecheck.sh +0 -16
- package/AGENTS.md +0 -469
- package/CLAUDE.md +0 -1
- package/bun.lock +0 -794
- package/docs/CONNECTION.md +0 -623
- package/docs/GATEWAY-WORKER.md +0 -319
- package/docs/GETTING-STARTED.md +0 -448
- package/docs/GITSPACE-PLATFORM.md +0 -1819
- package/docs/INFRASTRUCTURE.md +0 -1347
- package/docs/PROTOCOL.md +0 -619
- package/docs/QUICKSTART.md +0 -183
- package/docs/RELAY.md +0 -327
- package/docs/REMOTE-DESIGN.md +0 -554
- package/docs/ROADMAP.md +0 -564
- package/docs/SITE_DOCS_FIGMA_MAKE.md +0 -1176
- package/docs/STACK-DESIGN.md +0 -588
- package/docs/UNIFIED_ARCHITECTURE.md +0 -138
- package/experiments/pty-benchmark.ts +0 -148
- package/experiments/pty-latency.ts +0 -100
- package/experiments/router/client.ts +0 -199
- package/experiments/router/protocol.ts +0 -74
- package/experiments/router/router.ts +0 -217
- package/experiments/router/session.ts +0 -180
- package/experiments/router/test.ts +0 -133
- package/experiments/socket-bandwidth.ts +0 -77
- package/homebrew/gitspace.rb +0 -45
- package/landing-page/ATTRIBUTIONS.md +0 -3
- package/landing-page/README.md +0 -11
- package/landing-page/bun.lock +0 -801
- package/landing-page/guidelines/Guidelines.md +0 -61
- package/landing-page/index.html +0 -37
- package/landing-page/package.json +0 -90
- package/landing-page/postcss.config.mjs +0 -15
- package/landing-page/public/_redirects +0 -1
- package/landing-page/public/favicon.png +0 -0
- package/landing-page/src/app/App.tsx +0 -53
- package/landing-page/src/app/components/figma/ImageWithFallback.tsx +0 -27
- package/landing-page/src/app/components/ui/accordion.tsx +0 -66
- package/landing-page/src/app/components/ui/alert-dialog.tsx +0 -157
- package/landing-page/src/app/components/ui/alert.tsx +0 -66
- package/landing-page/src/app/components/ui/aspect-ratio.tsx +0 -11
- package/landing-page/src/app/components/ui/avatar.tsx +0 -53
- package/landing-page/src/app/components/ui/badge.tsx +0 -46
- package/landing-page/src/app/components/ui/breadcrumb.tsx +0 -109
- package/landing-page/src/app/components/ui/button.tsx +0 -57
- package/landing-page/src/app/components/ui/calendar.tsx +0 -75
- package/landing-page/src/app/components/ui/card.tsx +0 -92
- package/landing-page/src/app/components/ui/carousel.tsx +0 -241
- package/landing-page/src/app/components/ui/chart.tsx +0 -353
- package/landing-page/src/app/components/ui/checkbox.tsx +0 -32
- package/landing-page/src/app/components/ui/collapsible.tsx +0 -33
- package/landing-page/src/app/components/ui/command.tsx +0 -177
- package/landing-page/src/app/components/ui/context-menu.tsx +0 -252
- package/landing-page/src/app/components/ui/dialog.tsx +0 -135
- package/landing-page/src/app/components/ui/drawer.tsx +0 -132
- package/landing-page/src/app/components/ui/dropdown-menu.tsx +0 -257
- package/landing-page/src/app/components/ui/form.tsx +0 -168
- package/landing-page/src/app/components/ui/hover-card.tsx +0 -44
- package/landing-page/src/app/components/ui/input-otp.tsx +0 -77
- package/landing-page/src/app/components/ui/input.tsx +0 -21
- package/landing-page/src/app/components/ui/label.tsx +0 -24
- package/landing-page/src/app/components/ui/menubar.tsx +0 -276
- package/landing-page/src/app/components/ui/navigation-menu.tsx +0 -168
- package/landing-page/src/app/components/ui/pagination.tsx +0 -127
- package/landing-page/src/app/components/ui/popover.tsx +0 -48
- package/landing-page/src/app/components/ui/progress.tsx +0 -31
- package/landing-page/src/app/components/ui/radio-group.tsx +0 -45
- package/landing-page/src/app/components/ui/resizable.tsx +0 -56
- package/landing-page/src/app/components/ui/scroll-area.tsx +0 -58
- package/landing-page/src/app/components/ui/select.tsx +0 -189
- package/landing-page/src/app/components/ui/separator.tsx +0 -28
- package/landing-page/src/app/components/ui/sheet.tsx +0 -139
- package/landing-page/src/app/components/ui/sidebar.tsx +0 -726
- package/landing-page/src/app/components/ui/skeleton.tsx +0 -13
- package/landing-page/src/app/components/ui/slider.tsx +0 -63
- package/landing-page/src/app/components/ui/sonner.tsx +0 -25
- package/landing-page/src/app/components/ui/switch.tsx +0 -31
- package/landing-page/src/app/components/ui/table.tsx +0 -116
- package/landing-page/src/app/components/ui/tabs.tsx +0 -66
- package/landing-page/src/app/components/ui/textarea.tsx +0 -18
- package/landing-page/src/app/components/ui/toggle-group.tsx +0 -73
- package/landing-page/src/app/components/ui/toggle.tsx +0 -47
- package/landing-page/src/app/components/ui/tooltip.tsx +0 -61
- package/landing-page/src/app/components/ui/use-mobile.ts +0 -21
- package/landing-page/src/app/components/ui/utils.ts +0 -6
- package/landing-page/src/components/docs/DocsContent.tsx +0 -801
- package/landing-page/src/components/docs/DocsSidebar.tsx +0 -90
- package/landing-page/src/components/landing/CTA.tsx +0 -59
- package/landing-page/src/components/landing/Comparison.tsx +0 -84
- package/landing-page/src/components/landing/FaultyTerminal.tsx +0 -424
- package/landing-page/src/components/landing/Features.tsx +0 -201
- package/landing-page/src/components/landing/Hero.tsx +0 -142
- package/landing-page/src/components/landing/Pricing.tsx +0 -140
- package/landing-page/src/components/landing/Roadmap.tsx +0 -86
- package/landing-page/src/components/landing/Security.tsx +0 -81
- package/landing-page/src/components/landing/TerminalWindow.tsx +0 -27
- package/landing-page/src/components/landing/UseCases.tsx +0 -55
- package/landing-page/src/components/landing/Workflow.tsx +0 -101
- package/landing-page/src/components/layout/DashboardNavbar.tsx +0 -37
- package/landing-page/src/components/layout/Footer.tsx +0 -55
- package/landing-page/src/components/layout/LandingNavbar.tsx +0 -82
- package/landing-page/src/components/ui/badge.tsx +0 -39
- package/landing-page/src/components/ui/breadcrumb.tsx +0 -115
- package/landing-page/src/components/ui/button.tsx +0 -57
- package/landing-page/src/components/ui/card.tsx +0 -79
- package/landing-page/src/components/ui/mock-terminal.tsx +0 -68
- package/landing-page/src/components/ui/separator.tsx +0 -28
- package/landing-page/src/lib/utils.ts +0 -6
- package/landing-page/src/main.tsx +0 -10
- package/landing-page/src/pages/Dashboard.tsx +0 -133
- package/landing-page/src/pages/DocsPage.tsx +0 -79
- package/landing-page/src/pages/LandingPage.tsx +0 -31
- package/landing-page/src/pages/TerminalView.tsx +0 -106
- package/landing-page/src/styles/fonts.css +0 -0
- package/landing-page/src/styles/index.css +0 -3
- package/landing-page/src/styles/tailwind.css +0 -4
- package/landing-page/src/styles/theme.css +0 -181
- package/landing-page/vite.config.ts +0 -19
- package/scripts/GHOSTTY_TAB_BUG.md +0 -106
- package/scripts/build.ts +0 -298
- package/scripts/migrate-secrets.ts +0 -77
- package/scripts/release.ts +0 -140
- package/scripts/sample-events.ts +0 -263
- package/scripts/test-tabs-minimal.ts +0 -68
- package/scripts/test-tabs-workaround.ts +0 -95
- package/scripts/test-tabs.ts +0 -171
- package/src/__tests__/test-utils.ts +0 -298
- package/src/app/input/__tests__/sessionCommands.test.ts +0 -40
- package/src/app/input/sessionCommands.ts +0 -94
- package/src/app/session/__tests__/useAttachController.test.ts +0 -229
- package/src/app/session/createSessionBackend.bun.ts +0 -76
- package/src/app/session/createSessionBackend.web.ts +0 -104
- package/src/app/session/types.ts +0 -16
- package/src/app/session/useAttachController.ts +0 -220
- package/src/app/session/useProcessActions.ts +0 -201
- package/src/app/session/useSessionClient.ts +0 -35
- package/src/app/session/useWorkspaceDeleteFlow.ts +0 -170
- package/src/app.tui.tsx +0 -2929
- package/src/app.web.tsx +0 -1454
- package/src/commands/__tests__/connect-key.test.ts +0 -10
- package/src/commands/__tests__/events.test.ts +0 -201
- package/src/commands/__tests__/notifications.test.ts +0 -349
- package/src/commands/__tests__/process.test.ts +0 -251
- package/src/commands/__tests__/serve-messages.test.ts +0 -190
- package/src/commands/__tests__/serve-process-hosting.test.ts +0 -63
- package/src/commands/access.ts +0 -298
- package/src/commands/add.ts +0 -455
- package/src/commands/auth.ts +0 -369
- package/src/commands/bundle.ts +0 -232
- package/src/commands/config.ts +0 -242
- package/src/commands/connect-key.ts +0 -1
- package/src/commands/connect.ts +0 -576
- package/src/commands/directory.ts +0 -16
- package/src/commands/events.ts +0 -157
- package/src/commands/host.ts +0 -566
- package/src/commands/identity.ts +0 -184
- package/src/commands/linear.ts +0 -717
- package/src/commands/list.ts +0 -181
- package/src/commands/migrate.ts +0 -52
- package/src/commands/notifications.ts +0 -351
- package/src/commands/process.ts +0 -104
- package/src/commands/relay.ts +0 -315
- package/src/commands/remove.ts +0 -279
- package/src/commands/review.ts +0 -787
- package/src/commands/serve.ts +0 -1946
- package/src/commands/share.ts +0 -451
- package/src/commands/status.ts +0 -125
- package/src/commands/switch.ts +0 -361
- package/src/commands/tmux.ts +0 -317
- package/src/components/DPad.web.tsx +0 -343
- package/src/components/DiffViewer.web.tsx +0 -1192
- package/src/components/Events.tsx +0 -137
- package/src/components/Events.tui.tsx +0 -129
- package/src/components/Events.web.tsx +0 -386
- package/src/components/FloatingControls.web.tsx +0 -112
- package/src/components/FloatingJogWheel.web.tsx +0 -240
- package/src/components/Flow.tsx +0 -458
- package/src/components/Flow.tui.tsx +0 -343
- package/src/components/Flow.web.tsx +0 -442
- package/src/components/Inbox.tsx +0 -448
- package/src/components/Inbox.tui.tsx +0 -262
- package/src/components/Inbox.web.tsx +0 -329
- package/src/components/MachineList.tsx +0 -187
- package/src/components/MachineList.tui.tsx +0 -161
- package/src/components/MachineList.web.tsx +0 -210
- package/src/components/NumPad.web.tsx +0 -270
- package/src/components/ProjectList.tsx +0 -175
- package/src/components/ProjectList.tui.tsx +0 -109
- package/src/components/ProjectList.web.tsx +0 -143
- package/src/components/ProjectOnboardingStep.ts +0 -23
- package/src/components/ProjectOnboardingStep.tui.tsx +0 -88
- package/src/components/ProjectOnboardingStep.web.tsx +0 -59
- package/src/components/RemoteMachineScreen.tui.tsx +0 -690
- package/src/components/ScriptTerminal.tui.tsx +0 -160
- package/src/components/ScriptTerminal.web.tsx +0 -89
- package/src/components/SessionTerminal.tui.tsx +0 -406
- package/src/components/SessionTerminal.web.tsx +0 -467
- package/src/components/SpacesBrowser.tsx +0 -540
- package/src/components/SpacesBrowser.tui.tsx +0 -258
- package/src/components/SpacesBrowser.web.tsx +0 -332
- package/src/components/TerminalControls.web.tsx +0 -464
- package/src/components/ThreadPanel.web.tsx +0 -798
- package/src/components/__tests__/SpacesBrowser.test.ts +0 -541
- package/src/components/__tests__/SpacesBrowser.tui.test.tsx +0 -249
- package/src/components/__tests__/script-terminal-buffer.tui.test.ts +0 -72
- package/src/components/index.ts +0 -105
- package/src/components/review-decision-colors.ts +0 -11
- package/src/components/script-terminal-buffer.tui.ts +0 -37
- package/src/components/session-terminal-page-navigation.ts +0 -48
- package/src/components/terminal-bracketed-paste.tui.test.ts +0 -43
- package/src/components/terminal-bracketed-paste.tui.ts +0 -46
- package/src/core/__tests__/access.test.ts +0 -240
- package/src/core/__tests__/bundle-refresh.test.ts +0 -567
- package/src/core/__tests__/bundle.test.ts +0 -209
- package/src/core/__tests__/github-review.test.ts +0 -781
- package/src/core/__tests__/project-lifecycle.test.ts +0 -137
- package/src/core/__tests__/workspace-lifecycle.test.ts +0 -159
- package/src/core/__tests__/workspace.test.ts +0 -149
- package/src/core/access.ts +0 -277
- package/src/core/bundle-refresh.ts +0 -1064
- package/src/core/bundle.ts +0 -326
- package/src/core/config.ts +0 -405
- package/src/core/git.ts +0 -768
- package/src/core/github-review.ts +0 -761
- package/src/core/github.ts +0 -151
- package/src/core/identity.ts +0 -631
- package/src/core/linear.ts +0 -403
- package/src/core/preferences-service.ts +0 -17
- package/src/core/project-catalog.ts +0 -52
- package/src/core/project-lifecycle.ts +0 -163
- package/src/core/review-executor.ts +0 -316
- package/src/core/review.ts +0 -407
- package/src/core/secret-runtime.ts +0 -167
- package/src/core/shell.ts +0 -117
- package/src/core/trusted-relays.ts +0 -315
- package/src/core/workspace-lifecycle.ts +0 -216
- package/src/core/workspace.ts +0 -363
- package/src/hooks/__tests__/useLocalSession.tui.test.ts +0 -557
- package/src/hooks/index.ts +0 -8
- package/src/hooks/index.tui.ts +0 -32
- package/src/hooks/useDaemonStatus.tui.ts +0 -174
- package/src/hooks/useLocalSession.tui.ts +0 -395
- package/src/hooks/useRelayConnection.web.ts +0 -54
- package/src/hooks/useRemoteMachines.tui.ts +0 -166
- package/src/hooks/useRemoteTerminal.tui.ts +0 -22
- package/src/hooks/useReview.web.ts +0 -248
- package/src/hooks/useTerminal.web.ts +0 -36
- package/src/hooks/useUserActivity.ts +0 -61
- package/src/hooks/useVisualViewport.web.ts +0 -104
- package/src/index.ts +0 -1376
- package/src/lib/events/__tests__/collector-filter.test.ts +0 -105
- package/src/lib/events/__tests__/store-query.test.ts +0 -103
- package/src/lib/events/collector.ts +0 -494
- package/src/lib/events/filters.ts +0 -26
- package/src/lib/events/index.ts +0 -11
- package/src/lib/events/indexer.ts +0 -14
- package/src/lib/events/paths.ts +0 -69
- package/src/lib/events/reader.ts +0 -212
- package/src/lib/events/store.ts +0 -141
- package/src/lib/invite.web.ts +0 -58
- package/src/lib/preferences-service.web.ts +0 -41
- package/src/lib/processes/__tests__/config.test.ts +0 -83
- package/src/lib/processes/__tests__/names.test.ts +0 -125
- package/src/lib/processes/__tests__/schema.test.ts +0 -208
- package/src/lib/processes/__tests__/watchdog.test.ts +0 -210
- package/src/lib/processes/autostart.ts +0 -16
- package/src/lib/processes/config.ts +0 -187
- package/src/lib/processes/control.ts +0 -53
- package/src/lib/processes/editor.ts +0 -32
- package/src/lib/processes/events-config.ts +0 -37
- package/src/lib/processes/index.ts +0 -14
- package/src/lib/processes/instances.ts +0 -20
- package/src/lib/processes/manager.ts +0 -131
- package/src/lib/processes/names.ts +0 -71
- package/src/lib/processes/registry.ts +0 -26
- package/src/lib/processes/runner.ts +0 -211
- package/src/lib/processes/scheduler.ts +0 -17
- package/src/lib/processes/schema.ts +0 -74
- package/src/lib/processes/session-list.ts +0 -15
- package/src/lib/processes/state.ts +0 -82
- package/src/lib/processes/watchdog.test.ts +0 -79
- package/src/lib/processes/watchdog.ts +0 -106
- package/src/lib/remote-session/__tests__/protocol.test.ts +0 -291
- package/src/lib/remote-session/index.ts +0 -7
- package/src/lib/remote-session/protocol.ts +0 -443
- package/src/lib/remote-session/session-handler.ts +0 -1298
- package/src/lib/remote-session/workspace-scanner.ts +0 -161
- package/src/lib/sonner.web.ts +0 -1
- package/src/lib/storage/identity-store.web.ts +0 -94
- package/src/lib/tmux-lite/README.md +0 -81
- package/src/lib/tmux-lite/cli.ts +0 -855
- package/src/lib/tmux-lite/crypto/__tests__/helpers/handshake-runner.ts +0 -349
- package/src/lib/tmux-lite/crypto/__tests__/helpers/mock-relay.ts +0 -291
- package/src/lib/tmux-lite/crypto/__tests__/helpers/test-identities.ts +0 -142
- package/src/lib/tmux-lite/crypto/__tests__/integration/authorization.integration.test.ts +0 -339
- package/src/lib/tmux-lite/crypto/__tests__/integration/e2e-communication.integration.test.ts +0 -477
- package/src/lib/tmux-lite/crypto/__tests__/integration/error-handling.integration.test.ts +0 -499
- package/src/lib/tmux-lite/crypto/__tests__/integration/handshake.integration.test.ts +0 -371
- package/src/lib/tmux-lite/crypto/__tests__/integration/security.integration.test.ts +0 -573
- package/src/lib/tmux-lite/crypto/access-control.test.ts +0 -512
- package/src/lib/tmux-lite/crypto/access-control.ts +0 -320
- package/src/lib/tmux-lite/crypto/frames.test.ts +0 -262
- package/src/lib/tmux-lite/crypto/frames.ts +0 -141
- package/src/lib/tmux-lite/crypto/handshake.ts +0 -894
- package/src/lib/tmux-lite/crypto/identity.test.ts +0 -220
- package/src/lib/tmux-lite/crypto/identity.ts +0 -286
- package/src/lib/tmux-lite/crypto/index.ts +0 -51
- package/src/lib/tmux-lite/crypto/invites.test.ts +0 -381
- package/src/lib/tmux-lite/crypto/invites.ts +0 -215
- package/src/lib/tmux-lite/crypto/keyexchange.ts +0 -435
- package/src/lib/tmux-lite/crypto/keys.test.ts +0 -58
- package/src/lib/tmux-lite/crypto/keys.ts +0 -47
- package/src/lib/tmux-lite/crypto/secretbox.test.ts +0 -169
- package/src/lib/tmux-lite/crypto/secretbox.ts +0 -124
- package/src/lib/tmux-lite/handshake-handler.ts +0 -451
- package/src/lib/tmux-lite/process-run.integration.test.ts +0 -266
- package/src/lib/tmux-lite/protocol.test.ts +0 -307
- package/src/lib/tmux-lite/protocol.ts +0 -291
- package/src/lib/tmux-lite/relay-client.ts +0 -506
- package/src/lib/tmux-lite/server-lifecycle.test.ts +0 -212
- package/src/lib/tmux-lite/server.ts +0 -1412
- package/src/lib/tmux-lite/shell-integration.sh +0 -37
- package/src/lib/tmux-lite/terminal-queries.test.ts +0 -54
- package/src/lib/tmux-lite/terminal-queries.ts +0 -49
- package/src/notifications/__tests__/useNotifications.test.ts +0 -739
- package/src/notifications/index.ts +0 -32
- package/src/notifications/policy.test.ts +0 -424
- package/src/notifications/policy.ts +0 -139
- package/src/notifications/types.ts +0 -82
- package/src/notifications/useNotifications.ts +0 -350
- package/src/pages/ReviewPage.web.tsx +0 -511
- package/src/preferences/index.ts +0 -1
- package/src/preferences/types.ts +0 -9
- package/src/relay/__tests__/e2e-flow.test.ts +0 -1284
- package/src/relay/__tests__/helpers/auth.ts +0 -354
- package/src/relay/__tests__/helpers/ports.ts +0 -51
- package/src/relay/__tests__/protocol-validation.test.ts +0 -265
- package/src/relay/authorization.ts +0 -303
- package/src/relay/embedded-assets.generated.d.ts +0 -15
- package/src/relay/identity.ts +0 -352
- package/src/relay/index.ts +0 -57
- package/src/relay/pipes.test.ts +0 -427
- package/src/relay/pipes.ts +0 -195
- package/src/relay/protocol.ts +0 -804
- package/src/relay/registries.test.ts +0 -437
- package/src/relay/registries.ts +0 -593
- package/src/relay/server.test.ts +0 -1323
- package/src/relay/server.ts +0 -1128
- package/src/relay/signing.ts +0 -238
- package/src/relay/types.ts +0 -69
- package/src/relay-client/__tests__/machine-directory-client.test.ts +0 -152
- package/src/relay-client/__tests__/useMachineDirectory.test.ts +0 -172
- package/src/relay-client/adapters/browser.ts +0 -27
- package/src/relay-client/adapters/node.ts +0 -29
- package/src/relay-client/index.ts +0 -33
- package/src/relay-client/machine-directory-client.ts +0 -244
- package/src/relay-client/useMachineDirectory.ts +0 -175
- package/src/serve/client-session-manager.ts +0 -635
- package/src/serve/daemon.ts +0 -497
- package/src/serve/pty-session.ts +0 -236
- package/src/serve/types.ts +0 -174
- package/src/session/__tests__/backend-manager.test.ts +0 -101
- package/src/session/__tests__/local-session-backend.test.ts +0 -1129
- package/src/session/__tests__/reducer.test.ts +0 -80
- package/src/session/__tests__/remote-session-backend.test.ts +0 -995
- package/src/session/__tests__/session-name.test.ts +0 -35
- package/src/session/__tests__/useBundleRefreshAttachFlow.test.ts +0 -431
- package/src/session/__tests__/useRemoteSessionClient.test.ts +0 -424
- package/src/session/__tests__/workspace-shell-hooks.integration.test.ts +0 -268
- package/src/session/__tests__/workspace-shell-hooks.test.ts +0 -24
- package/src/session/adapters/browser-remote.ts +0 -101
- package/src/session/adapters/node-remote.ts +0 -135
- package/src/session/backend-key.ts +0 -5
- package/src/session/backend-manager.ts +0 -80
- package/src/session/backend.ts +0 -93
- package/src/session/backends/local-session-backend.ts +0 -1119
- package/src/session/backends/remote-session-backend.ts +0 -1378
- package/src/session/crypto/__tests__/web-terminal.test.ts +0 -1158
- package/src/session/crypto/frames.web.ts +0 -205
- package/src/session/crypto/handshake.web.ts +0 -396
- package/src/session/crypto/identity.web.ts +0 -133
- package/src/session/crypto/keyexchange.web.ts +0 -246
- package/src/session/crypto/relay-signing.web.ts +0 -53
- package/src/session/events.ts +0 -38
- package/src/session/index.ts +0 -116
- package/src/session/reducer.ts +0 -274
- package/src/session/selectors.ts +0 -28
- package/src/session/session-name.ts +0 -50
- package/src/session/types.ts +0 -101
- package/src/session/useBundleRefreshAttachFlow.ts +0 -608
- package/src/session/useRemoteSessionClient.ts +0 -424
- package/src/session/useSessionEngine.ts +0 -432
- package/src/session/workspace-shell-hooks.ts +0 -35
- package/src/tui/__tests__/input-text.test.ts +0 -24
- package/src/tui/__tests__/local-terminal-sync.test.ts +0 -82
- package/src/tui/__tests__/session-terminal-page-navigation.test.ts +0 -94
- package/src/tui/app.tsx +0 -2
- package/src/tui/index.ts +0 -18
- package/src/tui/input-text.ts +0 -38
- package/src/tui/local-terminal-sync.ts +0 -41
- package/src/types/bundle-refresh.ts +0 -42
- package/src/types/bundle.ts +0 -130
- package/src/types/config.ts +0 -287
- package/src/types/errors.ts +0 -292
- package/src/types/events.ts +0 -91
- package/src/types/identity.ts +0 -284
- package/src/types/processes.ts +0 -45
- package/src/types/review.ts +0 -349
- package/src/types/script-phase.ts +0 -3
- package/src/types/workspace-fuzzy.ts +0 -49
- package/src/types/workspace.ts +0 -151
- package/src/utils/__tests__/onboarding.test.ts +0 -358
- package/src/utils/__tests__/run-scripts.test.ts +0 -535
- package/src/utils/__tests__/run-workspace-scripts.test.ts +0 -406
- package/src/utils/__tests__/workspace-setup.integration.test.ts +0 -633
- package/src/utils/__tests__/workspace-state.test.ts +0 -78
- package/src/utils/bun-socket-writer.ts +0 -80
- package/src/utils/clipboard.ts +0 -53
- package/src/utils/deps.test.ts +0 -31
- package/src/utils/deps.ts +0 -145
- package/src/utils/device.web.ts +0 -163
- package/src/utils/fuzzy-match.ts +0 -125
- package/src/utils/hostnames.ts +0 -43
- package/src/utils/hunk-header.ts +0 -17
- package/src/utils/id.ts +0 -9
- package/src/utils/logger.ts +0 -127
- package/src/utils/markdown.ts +0 -254
- package/src/utils/normalize-env-key.ts +0 -13
- package/src/utils/onboarding.ts +0 -279
- package/src/utils/prompts.ts +0 -176
- package/src/utils/run-commands.ts +0 -112
- package/src/utils/run-scripts.ts +0 -337
- package/src/utils/run-workspace-scripts.ts +0 -355
- package/src/utils/sanitize.test.ts +0 -149
- package/src/utils/sanitize.ts +0 -162
- package/src/utils/secrets.ts +0 -836
- package/src/utils/shell-escape.ts +0 -40
- package/src/utils/utf8.ts +0 -79
- package/src/utils/workspace-id.ts +0 -55
- package/src/utils/workspace-state.ts +0 -427
- package/src/version.generated.d.ts +0 -2
- package/todo-security.md +0 -92
- package/tsconfig.json +0 -29
- package/web/README.md +0 -73
- package/web/bun.lock +0 -675
- package/web/eslint.config.js +0 -23
- package/web/index.css +0 -249
- package/web/index.html +0 -16
- package/web/main.tsx +0 -10
- package/web/package.json +0 -39
- package/web/public/vite.svg +0 -1
- package/web/tsconfig.app.json +0 -35
- package/web/tsconfig.json +0 -7
- package/web/tsconfig.node.json +0 -26
- package/web/vite.config.ts +0 -39
- package/worker/bun.lock +0 -237
- package/worker/package.json +0 -22
- package/worker/schema.sql +0 -96
- package/worker/src/handlers/auth.ts +0 -451
- package/worker/src/handlers/subdomains.ts +0 -376
- package/worker/src/handlers/user.ts +0 -98
- package/worker/src/index.ts +0 -70
- package/worker/src/middleware/auth.ts +0 -152
- package/worker/src/services/cloudflare.ts +0 -609
- package/worker/src/types.ts +0 -96
- package/worker/tsconfig.json +0 -15
- package/worker/wrangler.toml +0 -26
|
@@ -1,1192 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource react */
|
|
2
|
-
|
|
3
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
|
-
import type { CSSProperties } from 'react';
|
|
5
|
-
import { FileDiff } from '@pierre/diffs/react';
|
|
6
|
-
import {
|
|
7
|
-
parsePatchFiles,
|
|
8
|
-
type AnnotationSide,
|
|
9
|
-
type DiffLineAnnotation,
|
|
10
|
-
type FileDiffMetadata,
|
|
11
|
-
type FileDiffOptions,
|
|
12
|
-
type Hunk,
|
|
13
|
-
type SelectedLineRange,
|
|
14
|
-
} from '@pierre/diffs';
|
|
15
|
-
import type { HunkDecision, ReviewChangedFile, ReviewThread, ThreadTarget } from '../types/review.js';
|
|
16
|
-
import { SpacesError, toSpacesError } from '../types/errors.js';
|
|
17
|
-
import { normalizeHunkHeader } from '../utils/hunk-header.js';
|
|
18
|
-
import { getReviewDecisionColor } from './review-decision-colors.js';
|
|
19
|
-
|
|
20
|
-
export interface HunkFocusTarget {
|
|
21
|
-
filePath: string;
|
|
22
|
-
hunkHeader: string;
|
|
23
|
-
oldStart: number;
|
|
24
|
-
oldEnd: number;
|
|
25
|
-
newStart: number;
|
|
26
|
-
newEnd: number;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface DiffViewerProps {
|
|
30
|
-
files: ReviewChangedFile[];
|
|
31
|
-
threads: ReviewThread[];
|
|
32
|
-
onCreateThread: (target: ThreadTarget, body: string, decision?: HunkDecision) => Promise<void>;
|
|
33
|
-
onUpdateThread: (threadId: string, updates: { decision?: HunkDecision }) => Promise<void>;
|
|
34
|
-
onRequestFileDiff: (filePath: string, prevFilePath?: string) => Promise<string>;
|
|
35
|
-
onRequestFileContextRange: (
|
|
36
|
-
filePath: string,
|
|
37
|
-
prevFilePath?: string,
|
|
38
|
-
range?: { oldStart?: number; oldEnd?: number; newStart?: number; newEnd?: number }
|
|
39
|
-
) => Promise<{
|
|
40
|
-
oldStart: number;
|
|
41
|
-
oldLines: string[];
|
|
42
|
-
oldTotal: number;
|
|
43
|
-
newStart: number;
|
|
44
|
-
newLines: string[];
|
|
45
|
-
newTotal: number;
|
|
46
|
-
}>;
|
|
47
|
-
onThreadClick?: (threadId: string) => void;
|
|
48
|
-
onThreadHover?: (threadId: string | null) => void;
|
|
49
|
-
onSelectedFileChange?: (filePath: string | null) => void;
|
|
50
|
-
onHunkFocus?: (target: HunkFocusTarget | null) => void;
|
|
51
|
-
focusRequest?: { threadId: string; nonce: number } | null;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
interface CommentFormState {
|
|
55
|
-
target: ThreadTarget;
|
|
56
|
-
decision?: HunkDecision;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
interface HunkInfo {
|
|
60
|
-
header: string;
|
|
61
|
-
anchorSide: AnnotationSide;
|
|
62
|
-
anchorLine: number;
|
|
63
|
-
oldStart: number;
|
|
64
|
-
oldEnd: number;
|
|
65
|
-
newStart: number;
|
|
66
|
-
newEnd: number;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
interface LoadedFileDiff {
|
|
70
|
-
fileDiff: FileDiffMetadata;
|
|
71
|
-
hunks: HunkInfo[];
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
type FileDiffState =
|
|
75
|
-
| { status: 'idle' }
|
|
76
|
-
| { status: 'loading' }
|
|
77
|
-
| { status: 'ready'; data: LoadedFileDiff }
|
|
78
|
-
| { status: 'error'; error: SpacesError };
|
|
79
|
-
|
|
80
|
-
type FileContextState =
|
|
81
|
-
| { status: 'idle' }
|
|
82
|
-
| { status: 'loading' }
|
|
83
|
-
| {
|
|
84
|
-
status: 'ready';
|
|
85
|
-
oldLines: string[];
|
|
86
|
-
newLines: string[];
|
|
87
|
-
oldTotal: number;
|
|
88
|
-
newTotal: number;
|
|
89
|
-
contextHash: string;
|
|
90
|
-
}
|
|
91
|
-
| { status: 'error'; error: SpacesError };
|
|
92
|
-
|
|
93
|
-
type InlineAnnotationMeta =
|
|
94
|
-
| { kind: 'thread'; thread: ReviewThread }
|
|
95
|
-
| {
|
|
96
|
-
kind: 'hunk-control';
|
|
97
|
-
hunkHeader: string;
|
|
98
|
-
decision: HunkDecision;
|
|
99
|
-
threadId?: string;
|
|
100
|
-
threadIds: string[];
|
|
101
|
-
commentCount: number;
|
|
102
|
-
oldStart: number;
|
|
103
|
-
oldEnd: number;
|
|
104
|
-
newStart: number;
|
|
105
|
-
newEnd: number;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
type HunkControlMeta = Extract<InlineAnnotationMeta, { kind: 'hunk-control' }>;
|
|
109
|
-
|
|
110
|
-
const CHANGE_COLOR: Record<ReviewChangedFile['changeType'], string> = {
|
|
111
|
-
new: '#22c55e',
|
|
112
|
-
deleted: '#f85149',
|
|
113
|
-
renamed: '#d29922',
|
|
114
|
-
copied: '#3fb950',
|
|
115
|
-
modified: '#58a6ff',
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
const CHANGE_LABEL: Record<ReviewChangedFile['changeType'], string> = {
|
|
119
|
-
new: 'A',
|
|
120
|
-
deleted: 'D',
|
|
121
|
-
renamed: 'R',
|
|
122
|
-
copied: 'C',
|
|
123
|
-
modified: 'M',
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
export function DiffViewer({
|
|
127
|
-
files,
|
|
128
|
-
threads,
|
|
129
|
-
onCreateThread,
|
|
130
|
-
onUpdateThread,
|
|
131
|
-
onRequestFileDiff,
|
|
132
|
-
onRequestFileContextRange,
|
|
133
|
-
onThreadClick,
|
|
134
|
-
onThreadHover,
|
|
135
|
-
onSelectedFileChange,
|
|
136
|
-
onHunkFocus,
|
|
137
|
-
focusRequest,
|
|
138
|
-
}: DiffViewerProps) {
|
|
139
|
-
const [selectedFileKey, setSelectedFileKey] = useState<string | null>(null);
|
|
140
|
-
const [fileDiffStateByKey, setFileDiffStateByKey] = useState<Record<string, FileDiffState>>({});
|
|
141
|
-
const [contextStateByKey, setContextStateByKey] = useState<Record<string, FileContextState>>({});
|
|
142
|
-
|
|
143
|
-
const [commentForm, setCommentForm] = useState<CommentFormState | null>(null);
|
|
144
|
-
const [commentBody, setCommentBody] = useState('');
|
|
145
|
-
const [submitting, setSubmitting] = useState(false);
|
|
146
|
-
|
|
147
|
-
const diffHostRef = useRef<HTMLDivElement | null>(null);
|
|
148
|
-
const loadingFileDiffKeysRef = useRef<Set<string>>(new Set());
|
|
149
|
-
const loadingContextKeysRef = useRef<Set<string>>(new Set());
|
|
150
|
-
const decidingHunkKeysRef = useRef<Set<string>>(new Set());
|
|
151
|
-
const fileDiffStateByKeyRef = useRef<Record<string, FileDiffState>>({});
|
|
152
|
-
const contextStateByKeyRef = useRef<Record<string, FileContextState>>({});
|
|
153
|
-
const hunkThreadByHeaderRef = useRef<Map<string, ReviewThread[]>>(new Map());
|
|
154
|
-
|
|
155
|
-
const fileByKey = useMemo(() => {
|
|
156
|
-
const map = new Map<string, ReviewChangedFile>();
|
|
157
|
-
for (const file of files) {
|
|
158
|
-
map.set(fileKey(file.filePath, file.prevFilePath), file);
|
|
159
|
-
}
|
|
160
|
-
return map;
|
|
161
|
-
}, [files]);
|
|
162
|
-
|
|
163
|
-
const selectedFile = useMemo(() => {
|
|
164
|
-
if (selectedFileKey) {
|
|
165
|
-
const match = fileByKey.get(selectedFileKey);
|
|
166
|
-
if (match) {
|
|
167
|
-
return match;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return files[0] ?? null;
|
|
171
|
-
}, [selectedFileKey, fileByKey, files]);
|
|
172
|
-
|
|
173
|
-
useEffect(() => {
|
|
174
|
-
if (!commentForm) {
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (commentForm.target.kind === 'workspace') {
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
const selectedFilePath = selectedFile?.filePath;
|
|
183
|
-
if (!selectedFilePath || commentForm.target.file !== selectedFilePath) {
|
|
184
|
-
setCommentForm(null);
|
|
185
|
-
setCommentBody('');
|
|
186
|
-
}
|
|
187
|
-
}, [commentForm, selectedFile?.filePath]);
|
|
188
|
-
|
|
189
|
-
const selectedKey = selectedFile ? fileKey(selectedFile.filePath, selectedFile.prevFilePath) : null;
|
|
190
|
-
const selectedDiffState = selectedKey ? fileDiffStateByKey[selectedKey] ?? ({ status: 'idle' } as const) : null;
|
|
191
|
-
const selectedContextState = selectedKey ? contextStateByKey[selectedKey] ?? ({ status: 'idle' } as const) : null;
|
|
192
|
-
|
|
193
|
-
useEffect(() => {
|
|
194
|
-
onSelectedFileChange?.(selectedFile?.filePath ?? null);
|
|
195
|
-
}, [onSelectedFileChange, selectedFile]);
|
|
196
|
-
|
|
197
|
-
useEffect(() => {
|
|
198
|
-
fileDiffStateByKeyRef.current = fileDiffStateByKey;
|
|
199
|
-
}, [fileDiffStateByKey]);
|
|
200
|
-
|
|
201
|
-
useEffect(() => {
|
|
202
|
-
contextStateByKeyRef.current = contextStateByKey;
|
|
203
|
-
}, [contextStateByKey]);
|
|
204
|
-
|
|
205
|
-
useEffect(() => {
|
|
206
|
-
const valid = new Set(files.map((file) => fileKey(file.filePath, file.prevFilePath)));
|
|
207
|
-
const validFilePaths = new Set(files.map((file) => file.filePath));
|
|
208
|
-
|
|
209
|
-
for (const key of [...loadingFileDiffKeysRef.current]) {
|
|
210
|
-
if (!valid.has(key)) {
|
|
211
|
-
loadingFileDiffKeysRef.current.delete(key);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
for (const key of [...loadingContextKeysRef.current]) {
|
|
215
|
-
if (!valid.has(key)) {
|
|
216
|
-
loadingContextKeysRef.current.delete(key);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
for (const key of [...decidingHunkKeysRef.current]) {
|
|
220
|
-
const separator = key.indexOf('::');
|
|
221
|
-
const filePath = separator >= 0 ? key.slice(0, separator) : key;
|
|
222
|
-
if (!validFilePaths.has(filePath)) {
|
|
223
|
-
decidingHunkKeysRef.current.delete(key);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
setFileDiffStateByKey((prev) => {
|
|
228
|
-
const next: Record<string, FileDiffState> = {};
|
|
229
|
-
for (const [key, value] of Object.entries(prev)) {
|
|
230
|
-
if (valid.has(key)) {
|
|
231
|
-
next[key] = value;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
return next;
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
setContextStateByKey((prev) => {
|
|
238
|
-
const next: Record<string, FileContextState> = {};
|
|
239
|
-
for (const [key, value] of Object.entries(prev)) {
|
|
240
|
-
if (valid.has(key)) {
|
|
241
|
-
next[key] = value;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
return next;
|
|
245
|
-
});
|
|
246
|
-
}, [files]);
|
|
247
|
-
|
|
248
|
-
const loadFileDiff = useCallback(async (file: ReviewChangedFile) => {
|
|
249
|
-
const key = fileKey(file.filePath, file.prevFilePath);
|
|
250
|
-
|
|
251
|
-
const current = fileDiffStateByKeyRef.current[key];
|
|
252
|
-
if (current?.status === 'loading' || current?.status === 'ready') {
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
if (loadingFileDiffKeysRef.current.has(key)) {
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
loadingFileDiffKeysRef.current.add(key);
|
|
261
|
-
|
|
262
|
-
setFileDiffStateByKey((prev) => {
|
|
263
|
-
const existing = prev[key];
|
|
264
|
-
if (existing?.status === 'loading' || existing?.status === 'ready') {
|
|
265
|
-
return prev;
|
|
266
|
-
}
|
|
267
|
-
return { ...prev, [key]: { status: 'loading' } };
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
try {
|
|
271
|
-
const diff = await onRequestFileDiff(file.filePath, file.prevFilePath);
|
|
272
|
-
const parsed = parseSingleFileDiff(diff, file);
|
|
273
|
-
setFileDiffStateByKey((prev) => ({
|
|
274
|
-
...prev,
|
|
275
|
-
[key]: { status: 'ready', data: parsed },
|
|
276
|
-
}));
|
|
277
|
-
} catch (error) {
|
|
278
|
-
const typed = toSpacesError(error, 'Failed to load file diff');
|
|
279
|
-
setFileDiffStateByKey((prev) => ({
|
|
280
|
-
...prev,
|
|
281
|
-
[key]: { status: 'error', error: typed },
|
|
282
|
-
}));
|
|
283
|
-
} finally {
|
|
284
|
-
loadingFileDiffKeysRef.current.delete(key);
|
|
285
|
-
}
|
|
286
|
-
}, [onRequestFileDiff]);
|
|
287
|
-
|
|
288
|
-
useEffect(() => {
|
|
289
|
-
if (!selectedFile || !selectedKey) {
|
|
290
|
-
return;
|
|
291
|
-
}
|
|
292
|
-
const state = fileDiffStateByKey[selectedKey] ?? { status: 'idle' as const };
|
|
293
|
-
if (state.status === 'idle') {
|
|
294
|
-
void loadFileDiff(selectedFile);
|
|
295
|
-
}
|
|
296
|
-
}, [selectedFile, selectedKey, fileDiffStateByKey, loadFileDiff]);
|
|
297
|
-
|
|
298
|
-
useEffect(() => {
|
|
299
|
-
if (!focusRequest) {
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
const thread = threads.find((entry) => entry.id === focusRequest.threadId);
|
|
304
|
-
if (!thread || thread.target.kind === 'workspace') {
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
const target = thread.target;
|
|
308
|
-
|
|
309
|
-
const targetFile = files.find((entry) => (
|
|
310
|
-
entry.filePath === target.file || entry.prevFilePath === target.file
|
|
311
|
-
));
|
|
312
|
-
if (!targetFile) {
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
const key = fileKey(targetFile.filePath, targetFile.prevFilePath);
|
|
317
|
-
setSelectedFileKey(key);
|
|
318
|
-
}, [files, focusRequest, threads]);
|
|
319
|
-
|
|
320
|
-
useEffect(() => {
|
|
321
|
-
if (!focusRequest || !selectedFile || !selectedKey) {
|
|
322
|
-
return;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
const thread = threads.find((entry) => entry.id === focusRequest.threadId);
|
|
326
|
-
if (!thread || thread.target.kind === 'workspace') {
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
if (thread.target.file !== selectedFile.filePath && thread.target.file !== selectedFile.prevFilePath) {
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
if (selectedDiffState?.status !== 'ready') {
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
const host = diffHostRef.current;
|
|
339
|
-
if (!host) {
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
const marker = host.querySelector<HTMLElement>(`[data-thread-id="${thread.id}"]`);
|
|
344
|
-
if (marker) {
|
|
345
|
-
marker.scrollIntoView({ block: 'center', behavior: 'smooth' });
|
|
346
|
-
marker.focus?.();
|
|
347
|
-
return;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
const scrollContainer = host.querySelector<HTMLElement>('[data-diff-scroll-container]');
|
|
351
|
-
if (scrollContainer) {
|
|
352
|
-
scrollContainer.scrollTo({ top: 0, behavior: 'smooth' });
|
|
353
|
-
}
|
|
354
|
-
}, [focusRequest, selectedDiffState?.status, selectedFile, selectedKey, threads]);
|
|
355
|
-
|
|
356
|
-
const ensureContextLoaded = useCallback(async () => {
|
|
357
|
-
if (!selectedFile || !selectedKey) {
|
|
358
|
-
return;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
const current = contextStateByKeyRef.current[selectedKey] ?? { status: 'idle' as const };
|
|
362
|
-
if (current.status === 'loading' || current.status === 'ready') {
|
|
363
|
-
return;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
if (loadingContextKeysRef.current.has(selectedKey)) {
|
|
367
|
-
return;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
loadingContextKeysRef.current.add(selectedKey);
|
|
371
|
-
|
|
372
|
-
setContextStateByKey((prev) => ({
|
|
373
|
-
...prev,
|
|
374
|
-
[selectedKey]: { status: 'loading' },
|
|
375
|
-
}));
|
|
376
|
-
|
|
377
|
-
try {
|
|
378
|
-
const context = await onRequestFileContextRange(
|
|
379
|
-
selectedFile.filePath,
|
|
380
|
-
selectedFile.prevFilePath
|
|
381
|
-
);
|
|
382
|
-
|
|
383
|
-
setContextStateByKey((prev) => ({
|
|
384
|
-
...prev,
|
|
385
|
-
[selectedKey]: {
|
|
386
|
-
status: 'ready',
|
|
387
|
-
oldLines: expandToAbsoluteLines(context.oldLines, context.oldStart, context.oldTotal),
|
|
388
|
-
newLines: expandToAbsoluteLines(context.newLines, context.newStart, context.newTotal),
|
|
389
|
-
oldTotal: context.oldTotal,
|
|
390
|
-
newTotal: context.newTotal,
|
|
391
|
-
contextHash: `${context.oldTotal}:${context.newTotal}:${context.oldLines.length}:${context.newLines.length}`,
|
|
392
|
-
},
|
|
393
|
-
}));
|
|
394
|
-
} catch (error) {
|
|
395
|
-
const typed = toSpacesError(error, 'Failed to load file context');
|
|
396
|
-
setContextStateByKey((prev) => ({
|
|
397
|
-
...prev,
|
|
398
|
-
[selectedKey]: { status: 'error', error: typed },
|
|
399
|
-
}));
|
|
400
|
-
} finally {
|
|
401
|
-
loadingContextKeysRef.current.delete(selectedKey);
|
|
402
|
-
}
|
|
403
|
-
}, [selectedFile, selectedKey, onRequestFileContextRange]);
|
|
404
|
-
|
|
405
|
-
// On-demand expansion trigger: clicking line-info separators when context is
|
|
406
|
-
// not loaded will load context first, then user can click again to expand.
|
|
407
|
-
useEffect(() => {
|
|
408
|
-
const host = diffHostRef.current;
|
|
409
|
-
if (!host || !selectedKey) {
|
|
410
|
-
return;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
const onCaptureClick = (event: MouseEvent) => {
|
|
414
|
-
const current = contextStateByKeyRef.current[selectedKey] ?? { status: 'idle' as const };
|
|
415
|
-
if (current.status === 'loading' || current.status === 'ready') {
|
|
416
|
-
return;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
const path = event.composedPath();
|
|
420
|
-
const clickedSeparator = path.some((node) => {
|
|
421
|
-
return node instanceof HTMLElement && (
|
|
422
|
-
node.hasAttribute('data-unmodified-lines') ||
|
|
423
|
-
node.hasAttribute('data-separator-content') ||
|
|
424
|
-
node.getAttribute('data-separator') === 'line-info'
|
|
425
|
-
);
|
|
426
|
-
});
|
|
427
|
-
|
|
428
|
-
if (!clickedSeparator) {
|
|
429
|
-
return;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
event.preventDefault();
|
|
433
|
-
event.stopPropagation();
|
|
434
|
-
void ensureContextLoaded();
|
|
435
|
-
};
|
|
436
|
-
|
|
437
|
-
host.addEventListener('click', onCaptureClick, true);
|
|
438
|
-
return () => {
|
|
439
|
-
host.removeEventListener('click', onCaptureClick, true);
|
|
440
|
-
};
|
|
441
|
-
}, [selectedKey, ensureContextLoaded]);
|
|
442
|
-
|
|
443
|
-
const selectedLoadedDiff = selectedDiffState?.status === 'ready' ? selectedDiffState.data : null;
|
|
444
|
-
const selectedContextReady = selectedContextState?.status === 'ready' ? selectedContextState : null;
|
|
445
|
-
|
|
446
|
-
const hunkThreadByHeader = useMemo(() => {
|
|
447
|
-
const map = new Map<string, ReviewThread[]>();
|
|
448
|
-
if (!selectedFile) {
|
|
449
|
-
return map;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
for (const thread of threads) {
|
|
453
|
-
if (thread.target.kind !== 'hunk') {
|
|
454
|
-
continue;
|
|
455
|
-
}
|
|
456
|
-
if (thread.target.file !== selectedFile.filePath) {
|
|
457
|
-
continue;
|
|
458
|
-
}
|
|
459
|
-
const normalizedHeader = normalizeHunkHeader(thread.target.hunkHeader);
|
|
460
|
-
const list = map.get(normalizedHeader) ?? [];
|
|
461
|
-
list.push(thread);
|
|
462
|
-
map.set(normalizedHeader, list);
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
return map;
|
|
466
|
-
}, [threads, selectedFile]);
|
|
467
|
-
|
|
468
|
-
useEffect(() => {
|
|
469
|
-
hunkThreadByHeaderRef.current = hunkThreadByHeader;
|
|
470
|
-
}, [hunkThreadByHeader]);
|
|
471
|
-
|
|
472
|
-
const lineAnnotations = useMemo((): DiffLineAnnotation<InlineAnnotationMeta>[] => {
|
|
473
|
-
if (!selectedLoadedDiff || !selectedFile) {
|
|
474
|
-
return [];
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
const annotations: DiffLineAnnotation<InlineAnnotationMeta>[] = [];
|
|
478
|
-
|
|
479
|
-
for (const hunk of selectedLoadedDiff.hunks) {
|
|
480
|
-
const normalizedHeader = normalizeHunkHeader(hunk.header);
|
|
481
|
-
const existingThreads = hunkThreadByHeader.get(normalizedHeader) ?? [];
|
|
482
|
-
const primaryThread = pickPrimaryThread(existingThreads);
|
|
483
|
-
annotations.push({
|
|
484
|
-
side: hunk.anchorSide,
|
|
485
|
-
lineNumber: hunk.anchorLine,
|
|
486
|
-
metadata: {
|
|
487
|
-
kind: 'hunk-control',
|
|
488
|
-
hunkHeader: normalizedHeader,
|
|
489
|
-
decision: aggregateHunkDecision(existingThreads),
|
|
490
|
-
threadId: primaryThread?.id,
|
|
491
|
-
threadIds: existingThreads.map((thread) => thread.id),
|
|
492
|
-
commentCount: existingThreads.reduce((sum, thread) => sum + thread.comments.length, 0),
|
|
493
|
-
oldStart: hunk.oldStart,
|
|
494
|
-
oldEnd: hunk.oldEnd,
|
|
495
|
-
newStart: hunk.newStart,
|
|
496
|
-
newEnd: hunk.newEnd,
|
|
497
|
-
},
|
|
498
|
-
});
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
for (const thread of threads) {
|
|
502
|
-
if (thread.target.kind === 'line' && thread.target.file === selectedFile.filePath) {
|
|
503
|
-
annotations.push({
|
|
504
|
-
side: thread.target.side === 'LEFT' ? 'deletions' : 'additions',
|
|
505
|
-
lineNumber: thread.target.startLine,
|
|
506
|
-
metadata: { kind: 'thread', thread },
|
|
507
|
-
});
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
return annotations;
|
|
512
|
-
}, [selectedLoadedDiff, selectedFile, hunkThreadByHeader, threads]);
|
|
513
|
-
|
|
514
|
-
const handleSubmitComment = useCallback(async () => {
|
|
515
|
-
if (!commentForm || !commentBody.trim()) {
|
|
516
|
-
return;
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
setSubmitting(true);
|
|
520
|
-
try {
|
|
521
|
-
await onCreateThread(commentForm.target, commentBody.trim(), commentForm.decision);
|
|
522
|
-
setCommentForm(null);
|
|
523
|
-
setCommentBody('');
|
|
524
|
-
} catch {
|
|
525
|
-
// Error is surfaced via review hook state; avoid unhandled promise rejections.
|
|
526
|
-
} finally {
|
|
527
|
-
setSubmitting(false);
|
|
528
|
-
}
|
|
529
|
-
}, [commentForm, commentBody, onCreateThread]);
|
|
530
|
-
|
|
531
|
-
const setHunkDecision = useCallback(async (hunkMeta: HunkControlMeta, decision: HunkDecision) => {
|
|
532
|
-
if (!selectedFile) {
|
|
533
|
-
return;
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
const normalizedHeader = normalizeHunkHeader(hunkMeta.hunkHeader);
|
|
537
|
-
const hunkKey = `${selectedFile.filePath}::${normalizedHeader}`;
|
|
538
|
-
if (decidingHunkKeysRef.current.has(hunkKey)) {
|
|
539
|
-
return;
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
decidingHunkKeysRef.current.add(hunkKey);
|
|
543
|
-
|
|
544
|
-
try {
|
|
545
|
-
onHunkFocus?.({
|
|
546
|
-
filePath: selectedFile.filePath,
|
|
547
|
-
hunkHeader: hunkMeta.hunkHeader,
|
|
548
|
-
oldStart: hunkMeta.oldStart,
|
|
549
|
-
oldEnd: hunkMeta.oldEnd,
|
|
550
|
-
newStart: hunkMeta.newStart,
|
|
551
|
-
newEnd: hunkMeta.newEnd,
|
|
552
|
-
});
|
|
553
|
-
|
|
554
|
-
const existingThreads = hunkThreadByHeaderRef.current.get(normalizedHeader) ?? [];
|
|
555
|
-
const primary = pickPrimaryThread(existingThreads);
|
|
556
|
-
if (primary) {
|
|
557
|
-
try {
|
|
558
|
-
await onUpdateThread(primary.id, { decision });
|
|
559
|
-
} catch {
|
|
560
|
-
// Error is surfaced via review hook state; avoid unhandled promise rejections.
|
|
561
|
-
}
|
|
562
|
-
return;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
if (decision === 'pending') {
|
|
566
|
-
return;
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
try {
|
|
570
|
-
await onCreateThread(
|
|
571
|
-
{ kind: 'hunk', file: selectedFile.filePath, hunkHeader: normalizedHeader },
|
|
572
|
-
decision === 'approved'
|
|
573
|
-
? 'Approved hunk via inline controls.'
|
|
574
|
-
: 'Rejected hunk via inline controls.',
|
|
575
|
-
decision
|
|
576
|
-
);
|
|
577
|
-
} catch {
|
|
578
|
-
// Error is surfaced via review hook state; avoid unhandled promise rejections.
|
|
579
|
-
}
|
|
580
|
-
} finally {
|
|
581
|
-
decidingHunkKeysRef.current.delete(hunkKey);
|
|
582
|
-
}
|
|
583
|
-
}, [selectedFile, onUpdateThread, onCreateThread, onHunkFocus]);
|
|
584
|
-
|
|
585
|
-
const openHunkCommentForm = useCallback((hunkMeta: HunkControlMeta) => {
|
|
586
|
-
if (!selectedFile) {
|
|
587
|
-
return;
|
|
588
|
-
}
|
|
589
|
-
onHunkFocus?.({
|
|
590
|
-
filePath: selectedFile.filePath,
|
|
591
|
-
hunkHeader: hunkMeta.hunkHeader,
|
|
592
|
-
oldStart: hunkMeta.oldStart,
|
|
593
|
-
oldEnd: hunkMeta.oldEnd,
|
|
594
|
-
newStart: hunkMeta.newStart,
|
|
595
|
-
newEnd: hunkMeta.newEnd,
|
|
596
|
-
});
|
|
597
|
-
setCommentForm({
|
|
598
|
-
target: {
|
|
599
|
-
kind: 'hunk',
|
|
600
|
-
file: selectedFile.filePath,
|
|
601
|
-
hunkHeader: normalizeHunkHeader(hunkMeta.hunkHeader),
|
|
602
|
-
},
|
|
603
|
-
});
|
|
604
|
-
setCommentBody('');
|
|
605
|
-
}, [selectedFile, onHunkFocus]);
|
|
606
|
-
|
|
607
|
-
const handleLineSelectionEnd = useCallback((range: SelectedLineRange | null) => {
|
|
608
|
-
if (!range || !selectedFile) {
|
|
609
|
-
return;
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
setCommentForm({
|
|
613
|
-
target: {
|
|
614
|
-
kind: 'line',
|
|
615
|
-
file: selectedFile.filePath,
|
|
616
|
-
startLine: Math.min(range.start, range.end),
|
|
617
|
-
endLine: Math.max(range.start, range.end),
|
|
618
|
-
side: (range.side ?? 'additions') === 'deletions' ? 'LEFT' : 'RIGHT',
|
|
619
|
-
},
|
|
620
|
-
});
|
|
621
|
-
setCommentBody('');
|
|
622
|
-
}, [selectedFile]);
|
|
623
|
-
|
|
624
|
-
const renderHoverUtility = useCallback((
|
|
625
|
-
getHoveredLine: () => { lineNumber: number; side: AnnotationSide } | undefined
|
|
626
|
-
) => {
|
|
627
|
-
return (
|
|
628
|
-
<button
|
|
629
|
-
type="button"
|
|
630
|
-
aria-label="Add line comment"
|
|
631
|
-
title="Add comment"
|
|
632
|
-
onMouseDown={(event) => {
|
|
633
|
-
event.preventDefault();
|
|
634
|
-
const hovered = getHoveredLine();
|
|
635
|
-
if (!hovered || !selectedFile) {
|
|
636
|
-
return;
|
|
637
|
-
}
|
|
638
|
-
setCommentForm({
|
|
639
|
-
target: {
|
|
640
|
-
kind: 'line',
|
|
641
|
-
file: selectedFile.filePath,
|
|
642
|
-
startLine: hovered.lineNumber,
|
|
643
|
-
endLine: hovered.lineNumber,
|
|
644
|
-
side: hovered.side === 'deletions' ? 'LEFT' : 'RIGHT',
|
|
645
|
-
},
|
|
646
|
-
});
|
|
647
|
-
setCommentBody('');
|
|
648
|
-
}}
|
|
649
|
-
style={{
|
|
650
|
-
width: '20px',
|
|
651
|
-
height: '20px',
|
|
652
|
-
borderRadius: '999px',
|
|
653
|
-
border: 'none',
|
|
654
|
-
background: '#1a76d4',
|
|
655
|
-
color: '#0d1117',
|
|
656
|
-
cursor: 'pointer',
|
|
657
|
-
fontSize: '14px',
|
|
658
|
-
fontWeight: 700,
|
|
659
|
-
display: 'inline-flex',
|
|
660
|
-
alignItems: 'center',
|
|
661
|
-
justifyContent: 'center',
|
|
662
|
-
lineHeight: 1,
|
|
663
|
-
}}
|
|
664
|
-
>
|
|
665
|
-
+
|
|
666
|
-
</button>
|
|
667
|
-
);
|
|
668
|
-
}, [selectedFile]);
|
|
669
|
-
|
|
670
|
-
const renderAnnotation = useCallback((annotation: DiffLineAnnotation<InlineAnnotationMeta>) => {
|
|
671
|
-
const meta = annotation.metadata;
|
|
672
|
-
|
|
673
|
-
if (meta.kind === 'thread') {
|
|
674
|
-
const thread = meta.thread;
|
|
675
|
-
const color = thread.decision ? getReviewDecisionColor(thread.decision) : '#58a6ff';
|
|
676
|
-
const count = thread.comments.length;
|
|
677
|
-
|
|
678
|
-
return (
|
|
679
|
-
<div style={{ position: 'relative', height: 0, overflow: 'visible', pointerEvents: 'none' }}>
|
|
680
|
-
<button
|
|
681
|
-
title={`Open thread (${count} comment${count === 1 ? '' : 's'})`}
|
|
682
|
-
onClick={() => onThreadClick?.(thread.id)}
|
|
683
|
-
onMouseEnter={() => onThreadHover?.(thread.id)}
|
|
684
|
-
onMouseLeave={() => onThreadHover?.(null)}
|
|
685
|
-
data-thread-id={thread.id}
|
|
686
|
-
style={{
|
|
687
|
-
position: 'absolute',
|
|
688
|
-
top: '-9px',
|
|
689
|
-
right: '8px',
|
|
690
|
-
width: '16px',
|
|
691
|
-
height: '16px',
|
|
692
|
-
borderRadius: '999px',
|
|
693
|
-
border: `1px solid ${color}66`,
|
|
694
|
-
background: `${color}33`,
|
|
695
|
-
color,
|
|
696
|
-
cursor: 'pointer',
|
|
697
|
-
fontSize: '10px',
|
|
698
|
-
fontWeight: 700,
|
|
699
|
-
lineHeight: 1,
|
|
700
|
-
display: 'inline-flex',
|
|
701
|
-
alignItems: 'center',
|
|
702
|
-
justifyContent: 'center',
|
|
703
|
-
pointerEvents: 'auto',
|
|
704
|
-
}}
|
|
705
|
-
>
|
|
706
|
-
{count > 1 ? String(Math.min(count, 9)) : '•'}
|
|
707
|
-
</button>
|
|
708
|
-
</div>
|
|
709
|
-
);
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
const tint = getReviewDecisionColor(meta.decision);
|
|
713
|
-
return (
|
|
714
|
-
<div style={{ position: 'relative', zIndex: 10, height: 0, overflow: 'visible', pointerEvents: 'none' }}>
|
|
715
|
-
<div
|
|
716
|
-
data-thread-id={meta.threadId}
|
|
717
|
-
style={{
|
|
718
|
-
position: 'absolute',
|
|
719
|
-
top: '4px',
|
|
720
|
-
right: '28px',
|
|
721
|
-
display: 'inline-flex',
|
|
722
|
-
alignItems: 'center',
|
|
723
|
-
gap: '4px',
|
|
724
|
-
pointerEvents: 'auto',
|
|
725
|
-
boxShadow: '0 1px 3px rgba(0, 0, 0, 0.2)',
|
|
726
|
-
borderRadius: '4px',
|
|
727
|
-
border: `1px solid ${tint}33`,
|
|
728
|
-
background: '#161b22',
|
|
729
|
-
padding: '1px',
|
|
730
|
-
}}
|
|
731
|
-
onMouseEnter={() => meta.threadId && onThreadHover?.(meta.threadId)}
|
|
732
|
-
onMouseLeave={() => onThreadHover?.(null)}
|
|
733
|
-
>
|
|
734
|
-
<button
|
|
735
|
-
title="Reject hunk"
|
|
736
|
-
onClick={() => {
|
|
737
|
-
void setHunkDecision(meta, 'rejected').catch(() => {});
|
|
738
|
-
}}
|
|
739
|
-
style={actionButtonStyle(meta.decision === 'rejected', '#f85149')}
|
|
740
|
-
>
|
|
741
|
-
Reject
|
|
742
|
-
</button>
|
|
743
|
-
<button
|
|
744
|
-
title="Approve hunk"
|
|
745
|
-
onClick={() => {
|
|
746
|
-
void setHunkDecision(meta, 'approved').catch(() => {});
|
|
747
|
-
}}
|
|
748
|
-
style={actionButtonStyle(meta.decision === 'approved', '#22c55e', true)}
|
|
749
|
-
>
|
|
750
|
-
Approve
|
|
751
|
-
</button>
|
|
752
|
-
{meta.threadId && (
|
|
753
|
-
<button
|
|
754
|
-
title="Open hunk thread"
|
|
755
|
-
onClick={() => {
|
|
756
|
-
if (!selectedFile) {
|
|
757
|
-
return;
|
|
758
|
-
}
|
|
759
|
-
onHunkFocus?.({
|
|
760
|
-
filePath: selectedFile.filePath,
|
|
761
|
-
hunkHeader: meta.hunkHeader,
|
|
762
|
-
oldStart: meta.oldStart,
|
|
763
|
-
oldEnd: meta.oldEnd,
|
|
764
|
-
newStart: meta.newStart,
|
|
765
|
-
newEnd: meta.newEnd,
|
|
766
|
-
});
|
|
767
|
-
if (meta.threadId) {
|
|
768
|
-
onThreadClick?.(meta.threadId);
|
|
769
|
-
}
|
|
770
|
-
}}
|
|
771
|
-
style={actionButtonStyle(false, '#58a6ff')}
|
|
772
|
-
>
|
|
773
|
-
Threads {meta.threadIds.length > 1 ? `(${meta.threadIds.length})` : ''}
|
|
774
|
-
</button>
|
|
775
|
-
)}
|
|
776
|
-
{!meta.threadId && (
|
|
777
|
-
<button
|
|
778
|
-
title="Comment on hunk"
|
|
779
|
-
onClick={() => openHunkCommentForm(meta)}
|
|
780
|
-
style={actionButtonStyle(false, '#58a6ff')}
|
|
781
|
-
>
|
|
782
|
-
Comment
|
|
783
|
-
</button>
|
|
784
|
-
)}
|
|
785
|
-
</div>
|
|
786
|
-
</div>
|
|
787
|
-
);
|
|
788
|
-
}, [onThreadClick, onThreadHover, openHunkCommentForm, onHunkFocus, selectedFile, setHunkDecision]);
|
|
789
|
-
|
|
790
|
-
const fileDiffOptions = useMemo((): FileDiffOptions<InlineAnnotationMeta> => ({
|
|
791
|
-
diffStyle: 'unified',
|
|
792
|
-
hunkSeparators: 'line-info',
|
|
793
|
-
enableHoverUtility: true,
|
|
794
|
-
enableLineSelection: true,
|
|
795
|
-
onLineSelectionEnd: handleLineSelectionEnd,
|
|
796
|
-
}), [handleLineSelectionEnd]);
|
|
797
|
-
|
|
798
|
-
const renderedFileDiff = useMemo((): FileDiffMetadata | null => {
|
|
799
|
-
if (!selectedLoadedDiff) {
|
|
800
|
-
return null;
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
const base = selectedLoadedDiff.fileDiff;
|
|
804
|
-
if (selectedContextReady && selectedContextReady.oldTotal > 0 && selectedContextReady.newTotal > 0) {
|
|
805
|
-
return {
|
|
806
|
-
...base,
|
|
807
|
-
cacheKey: `${base.cacheKey ?? selectedKey}:context:${selectedContextReady.contextHash}`,
|
|
808
|
-
oldLines: selectedContextReady.oldLines,
|
|
809
|
-
newLines: selectedContextReady.newLines,
|
|
810
|
-
};
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
return base;
|
|
814
|
-
}, [selectedLoadedDiff, selectedContextReady, selectedKey]);
|
|
815
|
-
|
|
816
|
-
if (files.length === 0) {
|
|
817
|
-
return (
|
|
818
|
-
<div style={{ padding: '32px', textAlign: 'center', color: '#8b949e' }}>
|
|
819
|
-
No changed files.
|
|
820
|
-
</div>
|
|
821
|
-
);
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
const selectedDiffLoading = selectedDiffState?.status === 'loading' || selectedDiffState?.status === 'idle';
|
|
825
|
-
const selectedDiffError = selectedDiffState?.status === 'error' ? selectedDiffState.error.message : null;
|
|
826
|
-
const contextLoading = selectedContextState?.status === 'loading';
|
|
827
|
-
const contextError = selectedContextState?.status === 'error' ? selectedContextState.error.message : null;
|
|
828
|
-
const contextReady = selectedContextState?.status === 'ready';
|
|
829
|
-
|
|
830
|
-
return (
|
|
831
|
-
<div style={{ display: 'flex', height: '100%', overflow: 'hidden' }}>
|
|
832
|
-
<div style={{
|
|
833
|
-
width: '220px',
|
|
834
|
-
flexShrink: 0,
|
|
835
|
-
borderRight: '1px solid #30363d',
|
|
836
|
-
overflow: 'auto',
|
|
837
|
-
background: '#0d1117',
|
|
838
|
-
display: 'flex',
|
|
839
|
-
flexDirection: 'column',
|
|
840
|
-
}}>
|
|
841
|
-
<div style={{
|
|
842
|
-
padding: '8px 10px 6px',
|
|
843
|
-
fontSize: '11px',
|
|
844
|
-
color: '#6e7681',
|
|
845
|
-
fontWeight: 600,
|
|
846
|
-
textTransform: 'uppercase',
|
|
847
|
-
letterSpacing: '0.06em',
|
|
848
|
-
borderBottom: '1px solid #21262d',
|
|
849
|
-
flexShrink: 0,
|
|
850
|
-
}}>
|
|
851
|
-
{files.length} file{files.length !== 1 ? 's' : ''}
|
|
852
|
-
</div>
|
|
853
|
-
|
|
854
|
-
<div style={{ flex: 1, overflow: 'auto' }}>
|
|
855
|
-
{files.map((file) => {
|
|
856
|
-
const key = fileKey(file.filePath, file.prevFilePath);
|
|
857
|
-
const isSelected = selectedKey === key;
|
|
858
|
-
const color = CHANGE_COLOR[file.changeType];
|
|
859
|
-
const label = CHANGE_LABEL[file.changeType];
|
|
860
|
-
const lastSlash = file.filePath.lastIndexOf('/');
|
|
861
|
-
const dirPart = lastSlash >= 0 ? file.filePath.slice(0, lastSlash + 1) : '';
|
|
862
|
-
const basePart = lastSlash >= 0 ? file.filePath.slice(lastSlash + 1) : file.filePath;
|
|
863
|
-
|
|
864
|
-
return (
|
|
865
|
-
<button
|
|
866
|
-
key={key}
|
|
867
|
-
onClick={() => setSelectedFileKey(key)}
|
|
868
|
-
title={file.filePath}
|
|
869
|
-
style={{
|
|
870
|
-
width: '100%',
|
|
871
|
-
display: 'flex',
|
|
872
|
-
alignItems: 'center',
|
|
873
|
-
gap: '6px',
|
|
874
|
-
padding: '5px 10px',
|
|
875
|
-
background: isSelected ? '#161b22' : 'transparent',
|
|
876
|
-
borderLeft: isSelected ? '2px solid #58a6ff' : '2px solid transparent',
|
|
877
|
-
borderTop: 'none',
|
|
878
|
-
borderRight: 'none',
|
|
879
|
-
borderBottom: 'none',
|
|
880
|
-
cursor: 'pointer',
|
|
881
|
-
textAlign: 'left',
|
|
882
|
-
minWidth: 0,
|
|
883
|
-
}}
|
|
884
|
-
>
|
|
885
|
-
<span style={{ fontSize: '10px', fontWeight: 700, color, flexShrink: 0, width: '12px', textAlign: 'center' }}>
|
|
886
|
-
{label}
|
|
887
|
-
</span>
|
|
888
|
-
<span style={{
|
|
889
|
-
flex: 1,
|
|
890
|
-
minWidth: 0,
|
|
891
|
-
overflow: 'hidden',
|
|
892
|
-
textOverflow: 'ellipsis',
|
|
893
|
-
whiteSpace: 'nowrap',
|
|
894
|
-
fontSize: '12px',
|
|
895
|
-
color: isSelected ? '#e6edf3' : '#8b949e',
|
|
896
|
-
fontFamily: 'monospace',
|
|
897
|
-
}}>
|
|
898
|
-
{dirPart && <span style={{ color: '#6e7681' }}>{dirPart}</span>}
|
|
899
|
-
{basePart}
|
|
900
|
-
</span>
|
|
901
|
-
</button>
|
|
902
|
-
);
|
|
903
|
-
})}
|
|
904
|
-
</div>
|
|
905
|
-
</div>
|
|
906
|
-
|
|
907
|
-
<div ref={diffHostRef} style={{ flex: 1, display: 'flex', flexDirection: 'column', overflow: 'hidden', minWidth: 0 }}>
|
|
908
|
-
<div style={{
|
|
909
|
-
padding: '8px 12px',
|
|
910
|
-
borderBottom: '1px solid #30363d',
|
|
911
|
-
background: '#161b22',
|
|
912
|
-
color: '#8b949e',
|
|
913
|
-
fontSize: '12px',
|
|
914
|
-
display: 'flex',
|
|
915
|
-
gap: '14px',
|
|
916
|
-
flexWrap: 'wrap',
|
|
917
|
-
alignItems: 'center',
|
|
918
|
-
}}>
|
|
919
|
-
<span>Hover a line and click <b>+</b> to comment</span>
|
|
920
|
-
<span>Drag line numbers to comment on a range</span>
|
|
921
|
-
<span>
|
|
922
|
-
Hunk actions: <span style={{ color: '#22c55e' }}>Approve</span> / <span style={{ color: '#f85149' }}>Reject</span>
|
|
923
|
-
</span>
|
|
924
|
-
|
|
925
|
-
{!contextReady && (
|
|
926
|
-
<button
|
|
927
|
-
onClick={() => void ensureContextLoaded()}
|
|
928
|
-
disabled={contextLoading || !selectedFile || !selectedLoadedDiff}
|
|
929
|
-
style={{
|
|
930
|
-
fontSize: '11px',
|
|
931
|
-
padding: '2px 8px',
|
|
932
|
-
borderRadius: '4px',
|
|
933
|
-
border: '1px solid #30363d',
|
|
934
|
-
background: '#21262d',
|
|
935
|
-
color: '#8b949e',
|
|
936
|
-
cursor: contextLoading ? 'wait' : 'pointer',
|
|
937
|
-
}}
|
|
938
|
-
>
|
|
939
|
-
{contextLoading ? 'Loading context...' : 'Enable context expansion'}
|
|
940
|
-
</button>
|
|
941
|
-
)}
|
|
942
|
-
|
|
943
|
-
{contextReady && <span style={{ color: '#22c55e' }}>Context expansion ready</span>}
|
|
944
|
-
{contextError && <span style={{ color: '#f85149' }}>Context load failed: {contextError}</span>}
|
|
945
|
-
</div>
|
|
946
|
-
|
|
947
|
-
{selectedDiffLoading ? (
|
|
948
|
-
<div style={{ flex: 1, display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#8b949e', fontSize: '13px' }}>
|
|
949
|
-
Loading file diff...
|
|
950
|
-
</div>
|
|
951
|
-
) : selectedDiffError ? (
|
|
952
|
-
<div style={{ flex: 1, display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#f85149', fontSize: '13px', padding: '16px' }}>
|
|
953
|
-
Failed to load file diff: {selectedDiffError}
|
|
954
|
-
</div>
|
|
955
|
-
) : renderedFileDiff ? (
|
|
956
|
-
<div data-diff-scroll-container style={{ flex: 1, overflow: 'auto' }}>
|
|
957
|
-
<FileDiff
|
|
958
|
-
fileDiff={renderedFileDiff}
|
|
959
|
-
options={fileDiffOptions}
|
|
960
|
-
lineAnnotations={lineAnnotations}
|
|
961
|
-
renderAnnotation={renderAnnotation}
|
|
962
|
-
renderHoverUtility={renderHoverUtility}
|
|
963
|
-
/>
|
|
964
|
-
</div>
|
|
965
|
-
) : (
|
|
966
|
-
<div style={{ flex: 1, display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#8b949e' }}>
|
|
967
|
-
Select a file to view its diff.
|
|
968
|
-
</div>
|
|
969
|
-
)}
|
|
970
|
-
</div>
|
|
971
|
-
|
|
972
|
-
{commentForm && (
|
|
973
|
-
<div style={{
|
|
974
|
-
position: 'fixed',
|
|
975
|
-
bottom: 0,
|
|
976
|
-
left: 0,
|
|
977
|
-
right: 0,
|
|
978
|
-
background: '#161b22',
|
|
979
|
-
borderTop: '1px solid #30363d',
|
|
980
|
-
padding: '12px 16px',
|
|
981
|
-
zIndex: 100,
|
|
982
|
-
}}>
|
|
983
|
-
<div style={{ display: 'flex', gap: '8px', alignItems: 'flex-start', maxWidth: '860px', margin: '0 auto' }}>
|
|
984
|
-
<div style={{ flex: 1 }}>
|
|
985
|
-
{commentForm.target.kind === 'hunk' && (
|
|
986
|
-
<div style={{ marginBottom: '6px', fontSize: '12px', color: '#8b949e' }}>
|
|
987
|
-
Commenting on hunk
|
|
988
|
-
</div>
|
|
989
|
-
)}
|
|
990
|
-
{commentForm.target.kind === 'line' && (
|
|
991
|
-
<div style={{ marginBottom: '6px', fontSize: '12px', color: '#8b949e' }}>
|
|
992
|
-
Commenting on line {commentForm.target.startLine}
|
|
993
|
-
{commentForm.target.startLine !== commentForm.target.endLine
|
|
994
|
-
? `-${commentForm.target.endLine}`
|
|
995
|
-
: ''}
|
|
996
|
-
</div>
|
|
997
|
-
)}
|
|
998
|
-
<textarea
|
|
999
|
-
value={commentBody}
|
|
1000
|
-
onChange={(event) => setCommentBody(event.target.value)}
|
|
1001
|
-
placeholder="Add a comment..."
|
|
1002
|
-
rows={3}
|
|
1003
|
-
style={{
|
|
1004
|
-
width: '100%',
|
|
1005
|
-
background: '#0d1117',
|
|
1006
|
-
border: '1px solid #30363d',
|
|
1007
|
-
borderRadius: '6px',
|
|
1008
|
-
color: '#e6edf3',
|
|
1009
|
-
padding: '8px',
|
|
1010
|
-
fontSize: '13px',
|
|
1011
|
-
resize: 'vertical',
|
|
1012
|
-
boxSizing: 'border-box',
|
|
1013
|
-
}}
|
|
1014
|
-
autoFocus
|
|
1015
|
-
onKeyDown={(event) => {
|
|
1016
|
-
if (event.key === 'Escape') {
|
|
1017
|
-
setCommentForm(null);
|
|
1018
|
-
setCommentBody('');
|
|
1019
|
-
}
|
|
1020
|
-
if (event.key === 'Enter' && (event.metaKey || event.ctrlKey)) {
|
|
1021
|
-
void handleSubmitComment().catch(() => {});
|
|
1022
|
-
}
|
|
1023
|
-
}}
|
|
1024
|
-
/>
|
|
1025
|
-
</div>
|
|
1026
|
-
|
|
1027
|
-
<div style={{ display: 'flex', flexDirection: 'column', gap: '6px' }}>
|
|
1028
|
-
<button
|
|
1029
|
-
onClick={() => {
|
|
1030
|
-
void handleSubmitComment().catch(() => {});
|
|
1031
|
-
}}
|
|
1032
|
-
disabled={submitting}
|
|
1033
|
-
style={{
|
|
1034
|
-
padding: '8px 16px',
|
|
1035
|
-
background: '#22c55e',
|
|
1036
|
-
color: '#0d1117',
|
|
1037
|
-
border: 'none',
|
|
1038
|
-
borderRadius: '6px',
|
|
1039
|
-
cursor: submitting ? 'wait' : 'pointer',
|
|
1040
|
-
fontSize: '13px',
|
|
1041
|
-
fontWeight: 500,
|
|
1042
|
-
}}
|
|
1043
|
-
>
|
|
1044
|
-
{submitting ? '...' : 'Submit'}
|
|
1045
|
-
</button>
|
|
1046
|
-
<button
|
|
1047
|
-
onClick={() => {
|
|
1048
|
-
setCommentForm(null);
|
|
1049
|
-
setCommentBody('');
|
|
1050
|
-
}}
|
|
1051
|
-
style={{
|
|
1052
|
-
padding: '8px 16px',
|
|
1053
|
-
background: '#21262d',
|
|
1054
|
-
color: '#8b949e',
|
|
1055
|
-
border: '1px solid #30363d',
|
|
1056
|
-
borderRadius: '6px',
|
|
1057
|
-
cursor: 'pointer',
|
|
1058
|
-
fontSize: '13px',
|
|
1059
|
-
}}
|
|
1060
|
-
>
|
|
1061
|
-
Cancel
|
|
1062
|
-
</button>
|
|
1063
|
-
</div>
|
|
1064
|
-
</div>
|
|
1065
|
-
</div>
|
|
1066
|
-
)}
|
|
1067
|
-
</div>
|
|
1068
|
-
);
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
function fileKey(filePath: string, prevFilePath?: string): string {
|
|
1072
|
-
return `${prevFilePath ?? ''}=>${filePath}`;
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
|
-
function parseSingleFileDiff(diff: string, file: ReviewChangedFile): LoadedFileDiff {
|
|
1076
|
-
const parsed = parsePatchFiles(diff);
|
|
1077
|
-
const parsedFile = parsed.flatMap((patch) => patch.files).find((entry) => {
|
|
1078
|
-
const matchesCurrentOrPreviousName =
|
|
1079
|
-
entry.name === file.filePath ||
|
|
1080
|
-
(file.prevFilePath !== undefined && entry.name === file.prevFilePath);
|
|
1081
|
-
const matchesCurrentOrPreviousPrevName =
|
|
1082
|
-
entry.prevName === file.filePath ||
|
|
1083
|
-
(file.prevFilePath !== undefined && entry.prevName === file.prevFilePath);
|
|
1084
|
-
return matchesCurrentOrPreviousName || matchesCurrentOrPreviousPrevName;
|
|
1085
|
-
});
|
|
1086
|
-
|
|
1087
|
-
if (!parsedFile) {
|
|
1088
|
-
throw new SpacesError('No parseable file diff returned for selected file', 'SYSTEM_ERROR', 2);
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
const hunks: HunkInfo[] = parsedFile.hunks.map((hunk) => {
|
|
1092
|
-
const anchorSide: AnnotationSide = hunk.additionCount > 0 ? 'additions' : 'deletions';
|
|
1093
|
-
const anchorLine = Math.max(1, anchorSide === 'additions' ? hunk.additionStart : hunk.deletionStart);
|
|
1094
|
-
const oldStart = Math.max(1, hunk.deletionStart);
|
|
1095
|
-
const newStart = Math.max(1, hunk.additionStart);
|
|
1096
|
-
const oldEnd = hunk.deletionCount > 0 ? oldStart + hunk.deletionCount - 1 : oldStart - 1;
|
|
1097
|
-
const newEnd = hunk.additionCount > 0 ? newStart + hunk.additionCount - 1 : newStart - 1;
|
|
1098
|
-
|
|
1099
|
-
return {
|
|
1100
|
-
header: formatHunkHeader(hunk),
|
|
1101
|
-
anchorSide,
|
|
1102
|
-
anchorLine,
|
|
1103
|
-
oldStart,
|
|
1104
|
-
oldEnd,
|
|
1105
|
-
newStart,
|
|
1106
|
-
newEnd,
|
|
1107
|
-
};
|
|
1108
|
-
});
|
|
1109
|
-
|
|
1110
|
-
return {
|
|
1111
|
-
fileDiff: parsedFile,
|
|
1112
|
-
hunks,
|
|
1113
|
-
};
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
function formatHunkHeader(hunk: Hunk): string {
|
|
1117
|
-
const specs = (hunk.hunkSpecs ?? '').trim();
|
|
1118
|
-
const context = hunk.hunkContext ?? '';
|
|
1119
|
-
|
|
1120
|
-
if (specs.startsWith('@@')) {
|
|
1121
|
-
return normalizeHunkHeader(specs);
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
if (!specs) {
|
|
1125
|
-
return normalizeHunkHeader(context ? `@@ @@ ${context}` : '@@ @@');
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
return normalizeHunkHeader(`@@ ${specs} @@${context ? ` ${context}` : ''}`);
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
|
-
function expandToAbsoluteLines(lines: string[], start: number, total: number): string[] {
|
|
1132
|
-
if (total <= 0) {
|
|
1133
|
-
return [];
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
// When backend returns full file range, this is effectively identity with a
|
|
1137
|
-
// defensive fallback for non-1 starts.
|
|
1138
|
-
const output = new Array<string>(total).fill('');
|
|
1139
|
-
const offset = Math.max(0, start - 1);
|
|
1140
|
-
for (let index = 0; index < lines.length; index++) {
|
|
1141
|
-
const absoluteIndex = offset + index;
|
|
1142
|
-
if (absoluteIndex >= output.length) {
|
|
1143
|
-
break;
|
|
1144
|
-
}
|
|
1145
|
-
output[absoluteIndex] = lines[index] ?? '';
|
|
1146
|
-
}
|
|
1147
|
-
return output;
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
function actionButtonStyle(active: boolean, color: string, success = false): CSSProperties {
|
|
1151
|
-
return {
|
|
1152
|
-
border: success
|
|
1153
|
-
? `1px solid ${active ? `${color}88` : `${color}66`}`
|
|
1154
|
-
: `1px solid ${active ? `${color}66` : '#30363d'}`,
|
|
1155
|
-
background: success
|
|
1156
|
-
? active
|
|
1157
|
-
? color
|
|
1158
|
-
: `${color}cc`
|
|
1159
|
-
: active
|
|
1160
|
-
? `${color}33`
|
|
1161
|
-
: '#21262d',
|
|
1162
|
-
color: success ? '#0d1117' : active ? color : '#c9d1d9',
|
|
1163
|
-
borderRadius: '4px',
|
|
1164
|
-
fontSize: '11px',
|
|
1165
|
-
padding: '1px 8px',
|
|
1166
|
-
fontWeight: 600,
|
|
1167
|
-
cursor: 'pointer',
|
|
1168
|
-
};
|
|
1169
|
-
}
|
|
1170
|
-
|
|
1171
|
-
function pickPrimaryThread(threads: ReviewThread[]): ReviewThread | undefined {
|
|
1172
|
-
if (threads.length === 0) {
|
|
1173
|
-
return undefined;
|
|
1174
|
-
}
|
|
1175
|
-
const unresolved = threads
|
|
1176
|
-
.filter((thread) => !thread.resolved)
|
|
1177
|
-
.sort((left, right) => Date.parse(right.updatedAt) - Date.parse(left.updatedAt));
|
|
1178
|
-
if (unresolved.length > 0) {
|
|
1179
|
-
return unresolved[0];
|
|
1180
|
-
}
|
|
1181
|
-
return [...threads].sort((left, right) => Date.parse(right.updatedAt) - Date.parse(left.updatedAt))[0];
|
|
1182
|
-
}
|
|
1183
|
-
|
|
1184
|
-
function aggregateHunkDecision(threads: ReviewThread[]): HunkDecision {
|
|
1185
|
-
if (threads.some((thread) => thread.decision === 'rejected')) {
|
|
1186
|
-
return 'rejected';
|
|
1187
|
-
}
|
|
1188
|
-
if (threads.length > 0 && threads.every((thread) => thread.decision === 'approved')) {
|
|
1189
|
-
return 'approved';
|
|
1190
|
-
}
|
|
1191
|
-
return 'pending';
|
|
1192
|
-
}
|