jonsoc 1.1.48 → 1.1.50
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/bin/jonsoc +17 -9
- package/package.json +8 -142
- package/postinstall.mjs +15 -0
- package/AGENTS.md +0 -27
- package/Dockerfile +0 -18
- package/PUBLISHING_GUIDE.md +0 -151
- package/README.md +0 -58
- package/bunfig.toml +0 -7
- package/package.json.placeholder +0 -11
- package/parsers-config.ts +0 -253
- package/script/build.ts +0 -115
- package/script/publish-registries.ts +0 -197
- package/script/publish.ts +0 -110
- package/script/schema.ts +0 -47
- package/script/seed-e2e.ts +0 -50
- package/src/acp/README.md +0 -164
- package/src/acp/agent.ts +0 -1437
- package/src/acp/session.ts +0 -105
- package/src/acp/types.ts +0 -22
- package/src/agent/agent.ts +0 -347
- package/src/agent/generate.txt +0 -75
- package/src/agent/prompt/compaction.txt +0 -12
- package/src/agent/prompt/explore.txt +0 -18
- package/src/agent/prompt/summary.txt +0 -11
- package/src/agent/prompt/title.txt +0 -44
- package/src/auth/index.ts +0 -73
- package/src/brand/index.ts +0 -89
- package/src/bun/index.ts +0 -139
- package/src/bus/bus-event.ts +0 -43
- package/src/bus/global.ts +0 -10
- package/src/bus/index.ts +0 -105
- package/src/cli/bootstrap.ts +0 -17
- package/src/cli/cmd/acp.ts +0 -69
- package/src/cli/cmd/agent.ts +0 -257
- package/src/cli/cmd/auth.ts +0 -405
- package/src/cli/cmd/cmd.ts +0 -7
- package/src/cli/cmd/debug/agent.ts +0 -166
- package/src/cli/cmd/debug/config.ts +0 -16
- package/src/cli/cmd/debug/file.ts +0 -97
- package/src/cli/cmd/debug/index.ts +0 -48
- package/src/cli/cmd/debug/lsp.ts +0 -52
- package/src/cli/cmd/debug/ripgrep.ts +0 -87
- package/src/cli/cmd/debug/scrap.ts +0 -16
- package/src/cli/cmd/debug/skill.ts +0 -16
- package/src/cli/cmd/debug/snapshot.ts +0 -52
- package/src/cli/cmd/export.ts +0 -88
- package/src/cli/cmd/generate.ts +0 -38
- package/src/cli/cmd/github.ts +0 -1548
- package/src/cli/cmd/import.ts +0 -99
- package/src/cli/cmd/mcp.ts +0 -765
- package/src/cli/cmd/models.ts +0 -77
- package/src/cli/cmd/pr.ts +0 -112
- package/src/cli/cmd/run.ts +0 -395
- package/src/cli/cmd/serve.ts +0 -20
- package/src/cli/cmd/session.ts +0 -135
- package/src/cli/cmd/stats.ts +0 -402
- package/src/cli/cmd/tui/app.tsx +0 -923
- package/src/cli/cmd/tui/attach.ts +0 -39
- package/src/cli/cmd/tui/component/border.tsx +0 -21
- package/src/cli/cmd/tui/component/dialog-agent.tsx +0 -31
- package/src/cli/cmd/tui/component/dialog-command.tsx +0 -162
- package/src/cli/cmd/tui/component/dialog-error-log.tsx +0 -155
- package/src/cli/cmd/tui/component/dialog-mcp.tsx +0 -86
- package/src/cli/cmd/tui/component/dialog-model.tsx +0 -234
- package/src/cli/cmd/tui/component/dialog-provider.tsx +0 -256
- package/src/cli/cmd/tui/component/dialog-session-list.tsx +0 -114
- package/src/cli/cmd/tui/component/dialog-session-rename.tsx +0 -31
- package/src/cli/cmd/tui/component/dialog-stash.tsx +0 -87
- package/src/cli/cmd/tui/component/dialog-status.tsx +0 -164
- package/src/cli/cmd/tui/component/dialog-tag.tsx +0 -44
- package/src/cli/cmd/tui/component/dialog-theme-list.tsx +0 -50
- package/src/cli/cmd/tui/component/dynamic-layout.tsx +0 -86
- package/src/cli/cmd/tui/component/inspector-overlay.tsx +0 -247
- package/src/cli/cmd/tui/component/logo.tsx +0 -88
- package/src/cli/cmd/tui/component/prompt/autocomplete.tsx +0 -653
- package/src/cli/cmd/tui/component/prompt/frecency.tsx +0 -89
- package/src/cli/cmd/tui/component/prompt/history.tsx +0 -108
- package/src/cli/cmd/tui/component/prompt/index.tsx +0 -1347
- package/src/cli/cmd/tui/component/prompt/stash.tsx +0 -101
- package/src/cli/cmd/tui/component/textarea-keybindings.ts +0 -73
- package/src/cli/cmd/tui/component/tips.tsx +0 -153
- package/src/cli/cmd/tui/component/todo-item.tsx +0 -32
- package/src/cli/cmd/tui/context/args.tsx +0 -14
- package/src/cli/cmd/tui/context/directory.ts +0 -13
- package/src/cli/cmd/tui/context/error-log.tsx +0 -56
- package/src/cli/cmd/tui/context/exit.tsx +0 -26
- package/src/cli/cmd/tui/context/helper.tsx +0 -25
- package/src/cli/cmd/tui/context/inspector.tsx +0 -57
- package/src/cli/cmd/tui/context/keybind.tsx +0 -108
- package/src/cli/cmd/tui/context/kv.tsx +0 -53
- package/src/cli/cmd/tui/context/layout.tsx +0 -240
- package/src/cli/cmd/tui/context/local.tsx +0 -402
- package/src/cli/cmd/tui/context/prompt.tsx +0 -18
- package/src/cli/cmd/tui/context/route.tsx +0 -51
- package/src/cli/cmd/tui/context/sdk.tsx +0 -94
- package/src/cli/cmd/tui/context/sync.tsx +0 -449
- package/src/cli/cmd/tui/context/theme/aura.json +0 -69
- package/src/cli/cmd/tui/context/theme/ayu.json +0 -80
- package/src/cli/cmd/tui/context/theme/carbonfox.json +0 -248
- package/src/cli/cmd/tui/context/theme/catppuccin-frappe.json +0 -233
- package/src/cli/cmd/tui/context/theme/catppuccin-macchiato.json +0 -233
- package/src/cli/cmd/tui/context/theme/catppuccin.json +0 -112
- package/src/cli/cmd/tui/context/theme/cobalt2.json +0 -228
- package/src/cli/cmd/tui/context/theme/cursor.json +0 -249
- package/src/cli/cmd/tui/context/theme/dracula.json +0 -219
- package/src/cli/cmd/tui/context/theme/everforest.json +0 -241
- package/src/cli/cmd/tui/context/theme/flexoki.json +0 -237
- package/src/cli/cmd/tui/context/theme/github.json +0 -233
- package/src/cli/cmd/tui/context/theme/gruvbox.json +0 -242
- package/src/cli/cmd/tui/context/theme/jonsoc.json +0 -245
- package/src/cli/cmd/tui/context/theme/kanagawa.json +0 -77
- package/src/cli/cmd/tui/context/theme/lucent-orng.json +0 -237
- package/src/cli/cmd/tui/context/theme/material.json +0 -235
- package/src/cli/cmd/tui/context/theme/matrix.json +0 -77
- package/src/cli/cmd/tui/context/theme/mercury.json +0 -252
- package/src/cli/cmd/tui/context/theme/monokai.json +0 -221
- package/src/cli/cmd/tui/context/theme/nightowl.json +0 -221
- package/src/cli/cmd/tui/context/theme/nord.json +0 -223
- package/src/cli/cmd/tui/context/theme/one-dark.json +0 -84
- package/src/cli/cmd/tui/context/theme/orng.json +0 -249
- package/src/cli/cmd/tui/context/theme/osaka-jade.json +0 -93
- package/src/cli/cmd/tui/context/theme/palenight.json +0 -222
- package/src/cli/cmd/tui/context/theme/rosepine.json +0 -234
- package/src/cli/cmd/tui/context/theme/solarized.json +0 -223
- package/src/cli/cmd/tui/context/theme/synthwave84.json +0 -226
- package/src/cli/cmd/tui/context/theme/tokyonight.json +0 -243
- package/src/cli/cmd/tui/context/theme/vercel.json +0 -245
- package/src/cli/cmd/tui/context/theme/vesper.json +0 -218
- package/src/cli/cmd/tui/context/theme/zenburn.json +0 -223
- package/src/cli/cmd/tui/context/theme.tsx +0 -1153
- package/src/cli/cmd/tui/event.ts +0 -48
- package/src/cli/cmd/tui/hooks/use-command-registry.tsx +0 -184
- package/src/cli/cmd/tui/routes/home.tsx +0 -198
- package/src/cli/cmd/tui/routes/session/dialog-fork-from-timeline.tsx +0 -64
- package/src/cli/cmd/tui/routes/session/dialog-message.tsx +0 -109
- package/src/cli/cmd/tui/routes/session/dialog-subagent.tsx +0 -26
- package/src/cli/cmd/tui/routes/session/dialog-timeline.tsx +0 -47
- package/src/cli/cmd/tui/routes/session/footer.tsx +0 -91
- package/src/cli/cmd/tui/routes/session/git-commit.tsx +0 -59
- package/src/cli/cmd/tui/routes/session/git-history.tsx +0 -122
- package/src/cli/cmd/tui/routes/session/header.tsx +0 -185
- package/src/cli/cmd/tui/routes/session/index.tsx +0 -2363
- package/src/cli/cmd/tui/routes/session/navigator-ui.tsx +0 -214
- package/src/cli/cmd/tui/routes/session/navigator.tsx +0 -1124
- package/src/cli/cmd/tui/routes/session/panel-explorer.tsx +0 -553
- package/src/cli/cmd/tui/routes/session/panel-viewer.tsx +0 -386
- package/src/cli/cmd/tui/routes/session/permission.tsx +0 -501
- package/src/cli/cmd/tui/routes/session/question.tsx +0 -507
- package/src/cli/cmd/tui/routes/session/sidebar.tsx +0 -365
- package/src/cli/cmd/tui/routes/session/vcs-diff-viewer.tsx +0 -37
- package/src/cli/cmd/tui/routes/ui-settings.tsx +0 -449
- package/src/cli/cmd/tui/thread.ts +0 -172
- package/src/cli/cmd/tui/ui/dialog-alert.tsx +0 -90
- package/src/cli/cmd/tui/ui/dialog-confirm.tsx +0 -83
- package/src/cli/cmd/tui/ui/dialog-export-options.tsx +0 -204
- package/src/cli/cmd/tui/ui/dialog-help.tsx +0 -38
- package/src/cli/cmd/tui/ui/dialog-prompt.tsx +0 -77
- package/src/cli/cmd/tui/ui/dialog-select.tsx +0 -384
- package/src/cli/cmd/tui/ui/dialog.tsx +0 -170
- package/src/cli/cmd/tui/ui/link.tsx +0 -28
- package/src/cli/cmd/tui/ui/spinner.ts +0 -375
- package/src/cli/cmd/tui/ui/toast.tsx +0 -100
- package/src/cli/cmd/tui/util/clipboard.ts +0 -255
- package/src/cli/cmd/tui/util/editor.ts +0 -32
- package/src/cli/cmd/tui/util/signal.ts +0 -7
- package/src/cli/cmd/tui/util/terminal.ts +0 -114
- package/src/cli/cmd/tui/util/transcript.ts +0 -98
- package/src/cli/cmd/tui/worker.ts +0 -152
- package/src/cli/cmd/uninstall.ts +0 -362
- package/src/cli/cmd/upgrade.ts +0 -73
- package/src/cli/cmd/web.ts +0 -81
- package/src/cli/error.ts +0 -57
- package/src/cli/network.ts +0 -53
- package/src/cli/ui.ts +0 -119
- package/src/cli/upgrade.ts +0 -25
- package/src/command/index.ts +0 -131
- package/src/command/template/initialize.txt +0 -10
- package/src/command/template/review.txt +0 -99
- package/src/config/config.ts +0 -1404
- package/src/config/markdown.ts +0 -93
- package/src/env/index.ts +0 -26
- package/src/file/ignore.ts +0 -83
- package/src/file/index.ts +0 -432
- package/src/file/ripgrep.ts +0 -407
- package/src/file/time.ts +0 -69
- package/src/file/watcher.ts +0 -127
- package/src/flag/flag.ts +0 -80
- package/src/format/formatter.ts +0 -357
- package/src/format/index.ts +0 -137
- package/src/global/index.ts +0 -58
- package/src/id/id.ts +0 -83
- package/src/ide/index.ts +0 -76
- package/src/index.ts +0 -208
- package/src/installation/index.ts +0 -258
- package/src/lsp/client.ts +0 -252
- package/src/lsp/index.ts +0 -485
- package/src/lsp/language.ts +0 -119
- package/src/lsp/server.ts +0 -2046
- package/src/mcp/auth.ts +0 -135
- package/src/mcp/index.ts +0 -934
- package/src/mcp/oauth-callback.ts +0 -200
- package/src/mcp/oauth-provider.ts +0 -155
- package/src/patch/index.ts +0 -680
- package/src/permission/arity.ts +0 -163
- package/src/permission/index.ts +0 -210
- package/src/permission/next.ts +0 -280
- package/src/plugin/codex.ts +0 -500
- package/src/plugin/copilot.ts +0 -283
- package/src/plugin/index.ts +0 -135
- package/src/project/bootstrap.ts +0 -35
- package/src/project/instance.ts +0 -91
- package/src/project/project.ts +0 -371
- package/src/project/state.ts +0 -66
- package/src/project/vcs.ts +0 -151
- package/src/provider/auth.ts +0 -147
- package/src/provider/models-macro.ts +0 -14
- package/src/provider/models.ts +0 -114
- package/src/provider/provider.ts +0 -1220
- package/src/provider/sdk/openai-compatible/src/README.md +0 -5
- package/src/provider/sdk/openai-compatible/src/index.ts +0 -2
- package/src/provider/sdk/openai-compatible/src/openai-compatible-provider.ts +0 -100
- package/src/provider/sdk/openai-compatible/src/responses/convert-to-openai-responses-input.ts +0 -303
- package/src/provider/sdk/openai-compatible/src/responses/map-openai-responses-finish-reason.ts +0 -22
- package/src/provider/sdk/openai-compatible/src/responses/openai-config.ts +0 -18
- package/src/provider/sdk/openai-compatible/src/responses/openai-error.ts +0 -22
- package/src/provider/sdk/openai-compatible/src/responses/openai-responses-api-types.ts +0 -207
- package/src/provider/sdk/openai-compatible/src/responses/openai-responses-language-model.ts +0 -1732
- package/src/provider/sdk/openai-compatible/src/responses/openai-responses-prepare-tools.ts +0 -177
- package/src/provider/sdk/openai-compatible/src/responses/openai-responses-settings.ts +0 -1
- package/src/provider/sdk/openai-compatible/src/responses/tool/code-interpreter.ts +0 -88
- package/src/provider/sdk/openai-compatible/src/responses/tool/file-search.ts +0 -128
- package/src/provider/sdk/openai-compatible/src/responses/tool/image-generation.ts +0 -115
- package/src/provider/sdk/openai-compatible/src/responses/tool/local-shell.ts +0 -65
- package/src/provider/sdk/openai-compatible/src/responses/tool/web-search-preview.ts +0 -104
- package/src/provider/sdk/openai-compatible/src/responses/tool/web-search.ts +0 -103
- package/src/provider/transform.ts +0 -742
- package/src/pty/index.ts +0 -241
- package/src/question/index.ts +0 -176
- package/src/scheduler/index.ts +0 -61
- package/src/server/error.ts +0 -36
- package/src/server/event.ts +0 -7
- package/src/server/mdns.ts +0 -59
- package/src/server/routes/config.ts +0 -92
- package/src/server/routes/experimental.ts +0 -208
- package/src/server/routes/file.ts +0 -227
- package/src/server/routes/global.ts +0 -135
- package/src/server/routes/mcp.ts +0 -225
- package/src/server/routes/permission.ts +0 -68
- package/src/server/routes/project.ts +0 -82
- package/src/server/routes/provider.ts +0 -165
- package/src/server/routes/pty.ts +0 -169
- package/src/server/routes/question.ts +0 -98
- package/src/server/routes/session.ts +0 -939
- package/src/server/routes/tui.ts +0 -379
- package/src/server/server.ts +0 -663
- package/src/session/compaction.ts +0 -225
- package/src/session/index.ts +0 -498
- package/src/session/llm.ts +0 -288
- package/src/session/message-v2.ts +0 -740
- package/src/session/message.ts +0 -189
- package/src/session/processor.ts +0 -406
- package/src/session/prompt/anthropic-20250930.txt +0 -168
- package/src/session/prompt/anthropic.txt +0 -172
- package/src/session/prompt/anthropic_spoof.txt +0 -1
- package/src/session/prompt/beast.txt +0 -149
- package/src/session/prompt/build-switch.txt +0 -5
- package/src/session/prompt/codex_header.txt +0 -81
- package/src/session/prompt/copilot-gpt-5.txt +0 -145
- package/src/session/prompt/gemini.txt +0 -157
- package/src/session/prompt/max-steps.txt +0 -16
- package/src/session/prompt/plan-reminder-anthropic.txt +0 -67
- package/src/session/prompt/plan.txt +0 -26
- package/src/session/prompt/qwen.txt +0 -111
- package/src/session/prompt.ts +0 -1815
- package/src/session/retry.ts +0 -90
- package/src/session/revert.ts +0 -121
- package/src/session/status.ts +0 -76
- package/src/session/summary.ts +0 -150
- package/src/session/system.ts +0 -156
- package/src/session/todo.ts +0 -37
- package/src/share/share-next.ts +0 -204
- package/src/share/share.ts +0 -95
- package/src/shell/shell.ts +0 -67
- package/src/skill/index.ts +0 -1
- package/src/skill/skill.ts +0 -135
- package/src/snapshot/index.ts +0 -236
- package/src/storage/storage.ts +0 -227
- package/src/tool/apply_patch.ts +0 -279
- package/src/tool/apply_patch.txt +0 -33
- package/src/tool/bash.ts +0 -258
- package/src/tool/bash.txt +0 -115
- package/src/tool/batch.ts +0 -175
- package/src/tool/batch.txt +0 -24
- package/src/tool/codesearch.ts +0 -132
- package/src/tool/codesearch.txt +0 -12
- package/src/tool/edit.ts +0 -645
- package/src/tool/edit.txt +0 -10
- package/src/tool/external-directory.ts +0 -32
- package/src/tool/glob.ts +0 -77
- package/src/tool/glob.txt +0 -6
- package/src/tool/grep.ts +0 -154
- package/src/tool/grep.txt +0 -8
- package/src/tool/invalid.ts +0 -17
- package/src/tool/ls.ts +0 -121
- package/src/tool/ls.txt +0 -1
- package/src/tool/lsp.ts +0 -96
- package/src/tool/lsp.txt +0 -19
- package/src/tool/multiedit.ts +0 -46
- package/src/tool/multiedit.txt +0 -41
- package/src/tool/plan-enter.txt +0 -14
- package/src/tool/plan-exit.txt +0 -13
- package/src/tool/plan.ts +0 -130
- package/src/tool/question.ts +0 -33
- package/src/tool/question.txt +0 -10
- package/src/tool/read.ts +0 -202
- package/src/tool/read.txt +0 -12
- package/src/tool/registry.ts +0 -162
- package/src/tool/skill.ts +0 -82
- package/src/tool/task.ts +0 -188
- package/src/tool/task.txt +0 -60
- package/src/tool/todo.ts +0 -53
- package/src/tool/todoread.txt +0 -14
- package/src/tool/todowrite.txt +0 -167
- package/src/tool/tool.ts +0 -88
- package/src/tool/truncation.ts +0 -106
- package/src/tool/webfetch.ts +0 -182
- package/src/tool/webfetch.txt +0 -13
- package/src/tool/websearch.ts +0 -150
- package/src/tool/websearch.txt +0 -14
- package/src/tool/write.ts +0 -80
- package/src/tool/write.txt +0 -8
- package/src/util/archive.ts +0 -16
- package/src/util/color.ts +0 -19
- package/src/util/context.ts +0 -25
- package/src/util/defer.ts +0 -12
- package/src/util/eventloop.ts +0 -20
- package/src/util/filesystem.ts +0 -93
- package/src/util/fn.ts +0 -11
- package/src/util/format.ts +0 -20
- package/src/util/iife.ts +0 -3
- package/src/util/keybind.ts +0 -103
- package/src/util/lazy.ts +0 -18
- package/src/util/locale.ts +0 -81
- package/src/util/lock.ts +0 -98
- package/src/util/log.ts +0 -180
- package/src/util/queue.ts +0 -32
- package/src/util/rpc.ts +0 -66
- package/src/util/scrap.ts +0 -10
- package/src/util/signal.ts +0 -12
- package/src/util/timeout.ts +0 -14
- package/src/util/token.ts +0 -7
- package/src/util/wildcard.ts +0 -56
- package/src/worktree/index.ts +0 -524
- package/sst-env.d.ts +0 -9
- package/test/acp/agent-interface.test.ts +0 -51
- package/test/acp/event-subscription.test.ts +0 -436
- package/test/agent/agent.test.ts +0 -638
- package/test/bun.test.ts +0 -53
- package/test/cli/cmd/tui/fileref.test.ts +0 -30
- package/test/cli/github-action.test.ts +0 -129
- package/test/cli/github-remote.test.ts +0 -80
- package/test/cli/tui/navigator_logic.test.ts +0 -99
- package/test/cli/tui/transcript.test.ts +0 -297
- package/test/cli/ui.test.ts +0 -80
- package/test/config/agent-color.test.ts +0 -66
- package/test/config/config.test.ts +0 -1613
- package/test/config/fixtures/empty-frontmatter.md +0 -4
- package/test/config/fixtures/frontmatter.md +0 -28
- package/test/config/fixtures/no-frontmatter.md +0 -1
- package/test/config/markdown.test.ts +0 -192
- package/test/file/ignore.test.ts +0 -10
- package/test/file/path-traversal.test.ts +0 -198
- package/test/fixture/fixture.ts +0 -45
- package/test/fixture/lsp/fake-lsp-server.js +0 -77
- package/test/ide/ide.test.ts +0 -82
- package/test/keybind.test.ts +0 -421
- package/test/lsp/client.test.ts +0 -95
- package/test/mcp/headers.test.ts +0 -153
- package/test/mcp/oauth-browser.test.ts +0 -261
- package/test/patch/patch.test.ts +0 -348
- package/test/permission/arity.test.ts +0 -33
- package/test/permission/next.test.ts +0 -690
- package/test/permission-task.test.ts +0 -319
- package/test/plugin/codex.test.ts +0 -123
- package/test/preload.ts +0 -67
- package/test/project/project.test.ts +0 -120
- package/test/provider/amazon-bedrock.test.ts +0 -268
- package/test/provider/gitlab-duo.test.ts +0 -286
- package/test/provider/provider.test.ts +0 -2149
- package/test/provider/transform.test.ts +0 -1631
- package/test/question/question.test.ts +0 -300
- package/test/scheduler.test.ts +0 -73
- package/test/server/session-list.test.ts +0 -39
- package/test/server/session-select.test.ts +0 -78
- package/test/session/compaction.test.ts +0 -293
- package/test/session/llm.test.ts +0 -90
- package/test/session/message-v2.test.ts +0 -786
- package/test/session/retry.test.ts +0 -131
- package/test/session/revert-compact.test.ts +0 -285
- package/test/session/session.test.ts +0 -71
- package/test/skill/skill.test.ts +0 -185
- package/test/snapshot/snapshot.test.ts +0 -939
- package/test/tool/__snapshots__/tool.test.ts.snap +0 -9
- package/test/tool/apply_patch.test.ts +0 -499
- package/test/tool/bash.test.ts +0 -320
- package/test/tool/external-directory.test.ts +0 -126
- package/test/tool/fixtures/large-image.png +0 -0
- package/test/tool/fixtures/models-api.json +0 -33453
- package/test/tool/grep.test.ts +0 -109
- package/test/tool/question.test.ts +0 -105
- package/test/tool/read.test.ts +0 -332
- package/test/tool/registry.test.ts +0 -76
- package/test/tool/truncation.test.ts +0 -159
- package/test/util/filesystem.test.ts +0 -39
- package/test/util/format.test.ts +0 -59
- package/test/util/iife.test.ts +0 -36
- package/test/util/lazy.test.ts +0 -50
- package/test/util/lock.test.ts +0 -72
- package/test/util/timeout.test.ts +0 -21
- package/test/util/wildcard.test.ts +0 -75
- package/tsconfig.json +0 -16
|
@@ -1,1124 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
batch,
|
|
3
|
-
createEffect,
|
|
4
|
-
createMemo,
|
|
5
|
-
createResource,
|
|
6
|
-
createSignal,
|
|
7
|
-
For,
|
|
8
|
-
Match,
|
|
9
|
-
on,
|
|
10
|
-
onCleanup,
|
|
11
|
-
Show,
|
|
12
|
-
Switch,
|
|
13
|
-
untrack,
|
|
14
|
-
} from "solid-js"
|
|
15
|
-
import { createStore } from "solid-js/store"
|
|
16
|
-
import path from "path"
|
|
17
|
-
import type { ScrollBoxRenderable, TextareaRenderable, InputRenderable, ScrollAcceleration } from "@opentui/core"
|
|
18
|
-
import { TextAttributes } from "@opentui/core"
|
|
19
|
-
import { useKeyboard, useTerminalDimensions } from "@opentui/solid"
|
|
20
|
-
import { selectedForeground, useTheme } from "@tui/context/theme"
|
|
21
|
-
import { useSDK } from "@tui/context/sdk"
|
|
22
|
-
import { useToast } from "@tui/ui/toast"
|
|
23
|
-
import { useDialog } from "@tui/ui/dialog"
|
|
24
|
-
import { DialogAlert } from "@tui/ui/dialog-alert"
|
|
25
|
-
import { DialogPrompt } from "@tui/ui/dialog-prompt"
|
|
26
|
-
import { DialogSelect } from "@tui/ui/dialog-select"
|
|
27
|
-
import { usePromptRef } from "@tui/context/prompt"
|
|
28
|
-
import { useSync } from "@tui/context/sync"
|
|
29
|
-
import { SplitBorder } from "@tui/component/border"
|
|
30
|
-
import { useKV } from "@tui/context/kv"
|
|
31
|
-
import { useErrorLog } from "@tui/context/error-log"
|
|
32
|
-
import { useKeybind } from "@tui/context/keybind"
|
|
33
|
-
import { Filesystem } from "@/util/filesystem"
|
|
34
|
-
import { Locale } from "@/util/locale"
|
|
35
|
-
import { Global } from "@/global"
|
|
36
|
-
import { LANGUAGE_EXTENSIONS } from "@/lsp/language"
|
|
37
|
-
import type { File as FileStatus, FileContent, FileNode, VcsHistoryLine } from "@jonsoc/sdk/v2"
|
|
38
|
-
import { GitCommit } from "./git-commit"
|
|
39
|
-
import { GitHistory } from "./git-history"
|
|
40
|
-
import { VcsDiffViewer } from "./vcs-diff-viewer"
|
|
41
|
-
import { NavigatorBorderChars, Tab, ActionButton, ExplorerRow, GitRow, fileType, BinaryPreview } from "./navigator-ui"
|
|
42
|
-
|
|
43
|
-
type ExplorerEntry = {
|
|
44
|
-
node: FileNode
|
|
45
|
-
depth: number
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
type NavigatorProps = {
|
|
49
|
-
width: number
|
|
50
|
-
onClose: () => void
|
|
51
|
-
open: boolean
|
|
52
|
-
side: "left" | "right"
|
|
53
|
-
wrapMode?: "word" | "none"
|
|
54
|
-
promptRef?: { focused: boolean; focus: () => void } | undefined
|
|
55
|
-
onOpenFile?: (path: string, line?: number) => void
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
type NavigatorTab = "explorer" | "git"
|
|
59
|
-
|
|
60
|
-
const STATUS_LABELS: Record<string, string> = {
|
|
61
|
-
added: "A",
|
|
62
|
-
deleted: "D",
|
|
63
|
-
modified: "M",
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
class CustomSpeedScroll implements ScrollAcceleration {
|
|
67
|
-
constructor(private speed: number) {}
|
|
68
|
-
|
|
69
|
-
tick(_now?: number): number {
|
|
70
|
-
return this.speed
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
reset(): void {}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function Navigator(props: NavigatorProps) {
|
|
77
|
-
const theme = useTheme()
|
|
78
|
-
const sdk = useSDK()
|
|
79
|
-
const toast = useToast()
|
|
80
|
-
const dialog = useDialog()
|
|
81
|
-
const promptRef = usePromptRef()
|
|
82
|
-
const sync = useSync()
|
|
83
|
-
const kv = useKV()
|
|
84
|
-
const errorLog = useErrorLog()
|
|
85
|
-
const keybind = useKeybind()
|
|
86
|
-
const term = useTerminalDimensions()
|
|
87
|
-
const [loaded, setLoaded] = createSignal(false)
|
|
88
|
-
const [tab, setTab] = kv.signal<NavigatorTab>("navigator_tab", "explorer")
|
|
89
|
-
const [selectedExplorer, setSelectedExplorer] = kv.signal("navigator_explorer_index", 0)
|
|
90
|
-
const [selectedGit, setSelectedGit] = kv.signal("navigator_git_index", 0)
|
|
91
|
-
const [activePath, setActivePath] = kv.signal<string | null>("navigator_active_path", null)
|
|
92
|
-
const [listRatio, setListRatio] = kv.signal<number>("navigator_list_ratio", 0.35)
|
|
93
|
-
const [tree, setTree] = createStore<Record<string, FileNode[]>>({})
|
|
94
|
-
const [loading, setLoading] = createStore<Record<string, boolean>>({})
|
|
95
|
-
const [showScrollbar] = kv.signal("scrollbar_enabled", true)
|
|
96
|
-
const readExpanded = () => {
|
|
97
|
-
const stored = kv.get("navigator_expanded")
|
|
98
|
-
if (!stored) return {}
|
|
99
|
-
if (typeof stored !== "object") return {}
|
|
100
|
-
if (Array.isArray(stored)) return {}
|
|
101
|
-
const next: Record<string, boolean> = {}
|
|
102
|
-
for (const [key, value] of Object.entries(stored)) {
|
|
103
|
-
if (typeof value !== "boolean") continue
|
|
104
|
-
next[key] = value
|
|
105
|
-
}
|
|
106
|
-
return next
|
|
107
|
-
}
|
|
108
|
-
const [expanded, setExpanded] = createStore<Record<string, boolean>>(readExpanded())
|
|
109
|
-
const [explorerScroll, setExplorerScroll] = createSignal<ScrollBoxRenderable | undefined>(undefined)
|
|
110
|
-
const [gitScroll, setGitScroll] = createSignal<ScrollBoxRenderable | undefined>(undefined)
|
|
111
|
-
const [commitMessage, setCommitMessage] = createSignal("")
|
|
112
|
-
|
|
113
|
-
const [status, { refetch: refreshStatus }] = createResource(
|
|
114
|
-
() => (loaded() ? "open" : undefined),
|
|
115
|
-
async () => {
|
|
116
|
-
const result = await sdk.client.file.status().catch(() => undefined)
|
|
117
|
-
if (!result?.data) return []
|
|
118
|
-
return result.data
|
|
119
|
-
},
|
|
120
|
-
)
|
|
121
|
-
|
|
122
|
-
const historyLimit = 60
|
|
123
|
-
const [history, { refetch: refreshHistory }] = createResource(
|
|
124
|
-
() => (loaded() ? "open" : undefined),
|
|
125
|
-
async () => {
|
|
126
|
-
const result = await sdk.client.vcs.history({ limit: historyLimit }).catch(() => undefined)
|
|
127
|
-
if (!result?.data) return []
|
|
128
|
-
return result.data
|
|
129
|
-
},
|
|
130
|
-
)
|
|
131
|
-
|
|
132
|
-
const [fileContent, setFileContent] = createSignal<FileContent | undefined>(undefined)
|
|
133
|
-
const [fileLoading, setFileLoading] = createSignal(false)
|
|
134
|
-
const [fileError, setFileError] = createSignal(false)
|
|
135
|
-
const [cache, setCache] = createStore<Record<string, FileContent>>({})
|
|
136
|
-
const [targetLine, setTargetLine] = createSignal<number | undefined>(undefined)
|
|
137
|
-
const [openFileInfo, setOpenFileInfo] = kv.signal<{ path: string; line: number } | undefined>(
|
|
138
|
-
"navigator_open_file",
|
|
139
|
-
undefined,
|
|
140
|
-
)
|
|
141
|
-
|
|
142
|
-
// Editing state - manual save only
|
|
143
|
-
const [isDirty, setIsDirty] = createSignal(false)
|
|
144
|
-
const [saveStatus, setSaveStatus] = createSignal<"idle" | "saving" | "saved" | "error">("idle")
|
|
145
|
-
let editorRef: TextareaRenderable | undefined
|
|
146
|
-
const [currentFilePath, setCurrentFilePath] = createSignal<string | null>(null)
|
|
147
|
-
|
|
148
|
-
const saveFile = async () => {
|
|
149
|
-
const filePath = activePath()
|
|
150
|
-
if (!filePath || !editorRef || !isDirty() || saveStatus() === "saving") return
|
|
151
|
-
|
|
152
|
-
const content = editorRef.plainText
|
|
153
|
-
setSaveStatus("saving")
|
|
154
|
-
try {
|
|
155
|
-
const directory = sync.data.path.directory
|
|
156
|
-
const fullPath = path.isAbsolute(filePath) ? filePath : path.join(directory, filePath)
|
|
157
|
-
|
|
158
|
-
await Bun.write(fullPath, content)
|
|
159
|
-
|
|
160
|
-
setIsDirty(false)
|
|
161
|
-
setSaveStatus("saved")
|
|
162
|
-
// Update cache with new content
|
|
163
|
-
setCache(filePath, { type: "text", content })
|
|
164
|
-
setFileContent({ type: "text", content })
|
|
165
|
-
setTimeout(() => setSaveStatus("idle"), 2000)
|
|
166
|
-
} catch (err: any) {
|
|
167
|
-
const fullMessage = `Failed to save ${filePath}\n\n${err.message || "FileSystem error"}`
|
|
168
|
-
setSaveStatus("error")
|
|
169
|
-
errorLog.add(fullMessage, "Navigator")
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const handleEditorChange = () => {
|
|
174
|
-
setIsDirty(true)
|
|
175
|
-
setSaveStatus("idle")
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
onCleanup(() => {
|
|
179
|
-
if (isDirty()) {
|
|
180
|
-
void saveFile()
|
|
181
|
-
}
|
|
182
|
-
})
|
|
183
|
-
|
|
184
|
-
const listWidth = createMemo(() => {
|
|
185
|
-
if (!props.open) return 0
|
|
186
|
-
const available = Math.max(0, props.width)
|
|
187
|
-
const min = Math.min(20, available)
|
|
188
|
-
const max = Math.max(min, available - 20)
|
|
189
|
-
const width = Math.floor(available * listRatio())
|
|
190
|
-
return Math.min(max, Math.max(min, width))
|
|
191
|
-
})
|
|
192
|
-
const viewerWidth = createMemo(() => (props.open ? Math.max(0, props.width - listWidth()) : 0))
|
|
193
|
-
|
|
194
|
-
const displayRoot = createMemo(() => {
|
|
195
|
-
const directory = sync.data.path.directory || process.cwd()
|
|
196
|
-
const replaced = directory.replace(Global.Path.home, "~")
|
|
197
|
-
return Locale.truncateMiddle(replaced, 36)
|
|
198
|
-
})
|
|
199
|
-
const branch = createMemo(() => sync.data.vcs?.branch)
|
|
200
|
-
|
|
201
|
-
const statusEntries = createMemo(() => status() ?? [])
|
|
202
|
-
const statusMap = createMemo(() => {
|
|
203
|
-
const map = new Map<string, FileStatus>()
|
|
204
|
-
for (const entry of statusEntries()) {
|
|
205
|
-
map.set(entry.path, entry)
|
|
206
|
-
}
|
|
207
|
-
return map
|
|
208
|
-
})
|
|
209
|
-
|
|
210
|
-
const explorerEntries = createMemo(() => {
|
|
211
|
-
const result: ExplorerEntry[] = []
|
|
212
|
-
|
|
213
|
-
const add = (dir: string, depth: number) => {
|
|
214
|
-
const nodes = tree[dir] ?? []
|
|
215
|
-
for (const node of nodes) {
|
|
216
|
-
result.push({ node, depth })
|
|
217
|
-
if (node.type !== "directory") continue
|
|
218
|
-
if (!expanded[node.path]) continue
|
|
219
|
-
add(node.path, depth + 1)
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
add("", 0)
|
|
224
|
-
return result
|
|
225
|
-
})
|
|
226
|
-
|
|
227
|
-
const gitEntries = createMemo(() => {
|
|
228
|
-
const entries = [...statusEntries()]
|
|
229
|
-
const order = {
|
|
230
|
-
added: 0,
|
|
231
|
-
modified: 1,
|
|
232
|
-
deleted: 2,
|
|
233
|
-
}
|
|
234
|
-
return entries.toSorted((a, b) => {
|
|
235
|
-
const orderDiff = order[a.status] - order[b.status]
|
|
236
|
-
if (orderDiff !== 0) return orderDiff
|
|
237
|
-
return a.path.localeCompare(b.path)
|
|
238
|
-
})
|
|
239
|
-
})
|
|
240
|
-
|
|
241
|
-
// Auto-refresh Git status periodically and on save
|
|
242
|
-
createEffect(() => {
|
|
243
|
-
if (tab() !== "git" || !props.open) return
|
|
244
|
-
const id = setInterval(refreshGit, 10000)
|
|
245
|
-
onCleanup(() => clearInterval(id))
|
|
246
|
-
})
|
|
247
|
-
|
|
248
|
-
createEffect(
|
|
249
|
-
on(saveStatus, (status) => {
|
|
250
|
-
if (status === "saved") {
|
|
251
|
-
refreshGit()
|
|
252
|
-
}
|
|
253
|
-
}),
|
|
254
|
-
)
|
|
255
|
-
|
|
256
|
-
const activeStatus = createMemo(() => {
|
|
257
|
-
const file = activePath()
|
|
258
|
-
if (!file) return undefined
|
|
259
|
-
return statusMap().get(file)
|
|
260
|
-
})
|
|
261
|
-
|
|
262
|
-
const viewTitle = createMemo(() => {
|
|
263
|
-
const file = activePath()
|
|
264
|
-
if (!file) return "File Viewer"
|
|
265
|
-
const statusEntry = activeStatus()
|
|
266
|
-
const filename = path.basename(file)
|
|
267
|
-
const dirname = path.dirname(file)
|
|
268
|
-
const displayPath = dirname === "." ? "./ " : `${dirname}/ `
|
|
269
|
-
const prefix = statusEntry ? `${STATUS_LABELS[statusEntry.status]} ` : ""
|
|
270
|
-
return `${prefix}${displayPath}${filename}`
|
|
271
|
-
})
|
|
272
|
-
|
|
273
|
-
const hasExplorerEntries = createMemo(() => explorerEntries().length > 0)
|
|
274
|
-
const hasGitEntries = createMemo(() => gitEntries().length > 0)
|
|
275
|
-
const historyEntries = createMemo(() => history() ?? [])
|
|
276
|
-
const historyHeight = createMemo(() => Math.max(8, Math.floor(term().height * 0.35)))
|
|
277
|
-
|
|
278
|
-
const viewportOptions = createMemo(() => ({
|
|
279
|
-
paddingLeft: 1,
|
|
280
|
-
paddingRight: showScrollbar() ? 2 : 1,
|
|
281
|
-
}))
|
|
282
|
-
const verticalScrollbarOptions = createMemo(() => ({
|
|
283
|
-
paddingLeft: 1,
|
|
284
|
-
visible: showScrollbar(),
|
|
285
|
-
trackOptions: {
|
|
286
|
-
backgroundColor: theme.theme.backgroundElement,
|
|
287
|
-
foregroundColor: theme.theme.border,
|
|
288
|
-
},
|
|
289
|
-
}))
|
|
290
|
-
|
|
291
|
-
createEffect(() => {
|
|
292
|
-
const next: Record<string, boolean> = {}
|
|
293
|
-
for (const [key, value] of Object.entries(expanded)) {
|
|
294
|
-
next[key] = value
|
|
295
|
-
}
|
|
296
|
-
kv.set("navigator_expanded", next)
|
|
297
|
-
})
|
|
298
|
-
|
|
299
|
-
createEffect(() => {
|
|
300
|
-
const scroll = explorerScroll()
|
|
301
|
-
const entry = selectedExplorerEntry()
|
|
302
|
-
if (!scroll || !entry) return
|
|
303
|
-
ensureVisible(scroll, entry.node.path)
|
|
304
|
-
})
|
|
305
|
-
|
|
306
|
-
createEffect(() => {
|
|
307
|
-
const scroll = gitScroll()
|
|
308
|
-
const entry = selectedGitEntry()
|
|
309
|
-
if (!scroll || !entry) return
|
|
310
|
-
ensureVisible(scroll, entry.path)
|
|
311
|
-
})
|
|
312
|
-
|
|
313
|
-
const selectedExplorerEntry = createMemo(() => {
|
|
314
|
-
const list = explorerEntries()
|
|
315
|
-
if (list.length === 0) return undefined
|
|
316
|
-
const index = selectedExplorer()
|
|
317
|
-
if (index < 0) return undefined
|
|
318
|
-
if (index >= list.length) return undefined
|
|
319
|
-
return list[index]
|
|
320
|
-
})
|
|
321
|
-
|
|
322
|
-
const selectedGitEntry = createMemo(() => {
|
|
323
|
-
const list = gitEntries()
|
|
324
|
-
if (list.length === 0) return undefined
|
|
325
|
-
const index = selectedGit()
|
|
326
|
-
if (index < 0) return undefined
|
|
327
|
-
if (index >= list.length) return undefined
|
|
328
|
-
return list[index]
|
|
329
|
-
})
|
|
330
|
-
|
|
331
|
-
const fileData = createMemo(() => fileContent())
|
|
332
|
-
const resizeLeft = createMemo(() => keybind.print("navigator_resize_narrow"))
|
|
333
|
-
const resizeRight = createMemo(() => keybind.print("navigator_resize_wide"))
|
|
334
|
-
const resizeLabel = createMemo(() => {
|
|
335
|
-
if (!resizeLeft() && !resizeRight()) return ""
|
|
336
|
-
return `${resizeLeft() || ""}${resizeLeft() && resizeRight() ? "/" : ""}${resizeRight() || ""} resize`
|
|
337
|
-
})
|
|
338
|
-
|
|
339
|
-
const ensureVisible = (scroll: ScrollBoxRenderable | undefined, id: string) => {
|
|
340
|
-
if (!scroll) return
|
|
341
|
-
const child = scroll.getChildren().find((entry) => entry.id === id)
|
|
342
|
-
if (!child) return
|
|
343
|
-
const y = child.y - scroll.y
|
|
344
|
-
if (y >= scroll.height) scroll.scrollBy(y - scroll.height + 1)
|
|
345
|
-
if (y < 0) scroll.scrollBy(y)
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
const selectExplorerIndex = (index: number) => {
|
|
349
|
-
const list = explorerEntries()
|
|
350
|
-
if (list.length === 0) return
|
|
351
|
-
const next = Math.min(Math.max(index, 0), list.length - 1)
|
|
352
|
-
setSelectedExplorer(() => next)
|
|
353
|
-
const entry = list[next]
|
|
354
|
-
if (!entry) return
|
|
355
|
-
ensureVisible(explorerScroll(), entry.node.path)
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
const selectGitIndex = (index: number) => {
|
|
359
|
-
const list = gitEntries()
|
|
360
|
-
if (list.length === 0) return
|
|
361
|
-
const next = Math.min(Math.max(index, 0), list.length - 1)
|
|
362
|
-
setSelectedGit(() => next)
|
|
363
|
-
const entry = list[next]
|
|
364
|
-
if (!entry) return
|
|
365
|
-
ensureVisible(gitScroll(), entry.path)
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
const loadDirectory = async (dir: string) => {
|
|
369
|
-
if (loading[dir]) return
|
|
370
|
-
setLoading(dir, true)
|
|
371
|
-
const result = await sdk.client.file.list({ path: dir }).catch(() => undefined)
|
|
372
|
-
if (!result?.data) {
|
|
373
|
-
setLoading(dir, false)
|
|
374
|
-
toast.show({ variant: "error", message: `Failed to load ${dir || "project"} files` })
|
|
375
|
-
return
|
|
376
|
-
}
|
|
377
|
-
setTree(dir, result.data)
|
|
378
|
-
setLoading(dir, false)
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
const toggleDirectory = async (node: FileNode) => {
|
|
382
|
-
if (node.type !== "directory") return
|
|
383
|
-
const isExpanded = expanded[node.path] ?? false
|
|
384
|
-
if (isExpanded) {
|
|
385
|
-
setExpanded(node.path, false)
|
|
386
|
-
return
|
|
387
|
-
}
|
|
388
|
-
setExpanded(node.path, true)
|
|
389
|
-
if (tree[node.path]) return
|
|
390
|
-
await loadDirectory(node.path)
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
createEffect(() => {
|
|
394
|
-
if (!loaded()) return
|
|
395
|
-
for (const [key, value] of Object.entries(expanded)) {
|
|
396
|
-
if (!value) continue
|
|
397
|
-
if (!key) continue
|
|
398
|
-
if (tree[key]) continue
|
|
399
|
-
void loadDirectory(key)
|
|
400
|
-
}
|
|
401
|
-
})
|
|
402
|
-
|
|
403
|
-
const openFilePath = async (nextPath: string) => {
|
|
404
|
-
const current = activePath()
|
|
405
|
-
if (current === nextPath) {
|
|
406
|
-
if (loaded()) {
|
|
407
|
-
void loadFile(nextPath, true)
|
|
408
|
-
}
|
|
409
|
-
return
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
if (isDirty()) {
|
|
413
|
-
await saveFile()
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
batch(() => {
|
|
417
|
-
setFileLoading(true)
|
|
418
|
-
setFileError(false)
|
|
419
|
-
setIsDirty(false)
|
|
420
|
-
setSaveStatus("idle")
|
|
421
|
-
setActivePath(() => nextPath)
|
|
422
|
-
setTargetLine(undefined)
|
|
423
|
-
})
|
|
424
|
-
// Notify parent/sync navigation state
|
|
425
|
-
props.onOpenFile?.(nextPath)
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
const openFile = (node: FileNode) => {
|
|
429
|
-
if (node.type !== "file") return
|
|
430
|
-
openFilePath(node.path)
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
const openFileAtLine = async (path: string, line?: number) => {
|
|
434
|
-
const current = activePath()
|
|
435
|
-
if (current !== path) {
|
|
436
|
-
batch(() => {
|
|
437
|
-
// Set loading state FIRST to prevent "No content" flash
|
|
438
|
-
setFileLoading(true)
|
|
439
|
-
setFileError(false)
|
|
440
|
-
setIsDirty(false)
|
|
441
|
-
setSaveStatus("idle")
|
|
442
|
-
setActivePath(() => path)
|
|
443
|
-
})
|
|
444
|
-
// Notify parent/sync navigation state - this will update openFileInfo via KV
|
|
445
|
-
props.onOpenFile?.(path, line)
|
|
446
|
-
// loadFile will be triggered by the effect on activePath
|
|
447
|
-
} else if (loaded()) {
|
|
448
|
-
// Force reload if path is the same
|
|
449
|
-
void loadFile(path, true)
|
|
450
|
-
}
|
|
451
|
-
if (line && line > 0) {
|
|
452
|
-
setTargetLine(line)
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
const handleExplorerSelect = async () => {
|
|
457
|
-
const entry = selectedExplorerEntry()
|
|
458
|
-
if (!entry) return
|
|
459
|
-
if (entry.node.type === "directory") {
|
|
460
|
-
await toggleDirectory(entry.node)
|
|
461
|
-
return
|
|
462
|
-
}
|
|
463
|
-
openFile(entry.node)
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
const handleGitSelect = () => {
|
|
467
|
-
const entry = selectedGitEntry()
|
|
468
|
-
if (!entry) return
|
|
469
|
-
openFilePath(entry.path)
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
const [currentLoadFile, setCurrentLoadFile] = createSignal<string | undefined>(undefined)
|
|
473
|
-
const [loadNonce, setLoadNonce] = createSignal(0)
|
|
474
|
-
|
|
475
|
-
const loadFile = async (file: string, force = false) => {
|
|
476
|
-
// Check loading state and path in a single untracked lookup to avoid loops
|
|
477
|
-
const alreadyLoading = untrack(() => fileLoading() && currentLoadFile() === file)
|
|
478
|
-
if (alreadyLoading) return
|
|
479
|
-
|
|
480
|
-
const nonce = loadNonce() + 1
|
|
481
|
-
|
|
482
|
-
batch(() => {
|
|
483
|
-
setLoadNonce(nonce)
|
|
484
|
-
setCurrentLoadFile(() => file)
|
|
485
|
-
|
|
486
|
-
// Clear previous content and state immediately before loading
|
|
487
|
-
setFileContent(undefined)
|
|
488
|
-
setFileLoading(true)
|
|
489
|
-
setFileError(false)
|
|
490
|
-
setIsDirty(false)
|
|
491
|
-
setSaveStatus("idle")
|
|
492
|
-
})
|
|
493
|
-
|
|
494
|
-
if (!force) {
|
|
495
|
-
const cached = cache[file]
|
|
496
|
-
if (cached) {
|
|
497
|
-
if (loadNonce() !== nonce) return
|
|
498
|
-
batch(() => {
|
|
499
|
-
setFileContent(cached)
|
|
500
|
-
setFileLoading(false)
|
|
501
|
-
setFileError(false)
|
|
502
|
-
setCurrentLoadFile(() => undefined)
|
|
503
|
-
})
|
|
504
|
-
return
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
const result = await sdk.client.file.read({ path: file }).catch(() => undefined)
|
|
509
|
-
if (loadNonce() !== nonce) return
|
|
510
|
-
|
|
511
|
-
batch(() => {
|
|
512
|
-
if (!result?.data) {
|
|
513
|
-
setFileContent(undefined)
|
|
514
|
-
setFileLoading(false)
|
|
515
|
-
setFileError(true)
|
|
516
|
-
setCurrentLoadFile(() => undefined)
|
|
517
|
-
return
|
|
518
|
-
}
|
|
519
|
-
setCache(file, result.data)
|
|
520
|
-
setFileContent(result.data)
|
|
521
|
-
setFileLoading(false)
|
|
522
|
-
setCurrentLoadFile(() => undefined)
|
|
523
|
-
})
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
const adjustListWidth = (delta: number) => {
|
|
527
|
-
setListRatio((prev) => {
|
|
528
|
-
const base = typeof prev === "function" ? prev(0.35) : prev
|
|
529
|
-
const next = Math.min(0.6, Math.max(0.2, base + delta))
|
|
530
|
-
return next
|
|
531
|
-
})
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
const runPrompt = (input: string, mode?: "normal" | "shell") => {
|
|
535
|
-
const ref = promptRef.current
|
|
536
|
-
if (!ref) return
|
|
537
|
-
ref.set({
|
|
538
|
-
input,
|
|
539
|
-
mode,
|
|
540
|
-
parts: [],
|
|
541
|
-
})
|
|
542
|
-
ref.focus()
|
|
543
|
-
ref.submit()
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
const runCommand = async (command: string) => {
|
|
547
|
-
if (isDirty()) await saveFile()
|
|
548
|
-
runPrompt(`/${command}`)
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
const runShell = async (command: string) => {
|
|
552
|
-
if (isDirty()) await saveFile()
|
|
553
|
-
runPrompt(command, "shell")
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
const refreshGit = () => {
|
|
557
|
-
refreshStatus()
|
|
558
|
-
refreshHistory()
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
const handleCommit = async () => {
|
|
562
|
-
const msg = commitMessage().trim()
|
|
563
|
-
if (!msg) return
|
|
564
|
-
if (isDirty()) await saveFile()
|
|
565
|
-
|
|
566
|
-
const directory = sync.data.path.directory
|
|
567
|
-
try {
|
|
568
|
-
const proc = Bun.spawn({
|
|
569
|
-
cmd: ["git", "add", "."],
|
|
570
|
-
cwd: directory,
|
|
571
|
-
stdout: "pipe",
|
|
572
|
-
stderr: "pipe",
|
|
573
|
-
})
|
|
574
|
-
await proc.exited
|
|
575
|
-
|
|
576
|
-
const commitProc = Bun.spawn({
|
|
577
|
-
cmd: ["git", "commit", "-m", msg],
|
|
578
|
-
cwd: directory,
|
|
579
|
-
stdout: "pipe",
|
|
580
|
-
stderr: "pipe",
|
|
581
|
-
})
|
|
582
|
-
const exitCode = await commitProc.exited
|
|
583
|
-
|
|
584
|
-
if (exitCode === 0) {
|
|
585
|
-
toast.show({ variant: "success", message: "Changes committed" })
|
|
586
|
-
refreshGit()
|
|
587
|
-
} else {
|
|
588
|
-
const stderr = await new Response(commitProc.stderr).text()
|
|
589
|
-
toast.show({ variant: "error", message: `Commit failed: ${stderr}` })
|
|
590
|
-
}
|
|
591
|
-
} catch (err: any) {
|
|
592
|
-
toast.show({ variant: "error", message: `Commit failed: ${err.message}` })
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
setCommitMessage("")
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
const openBranchSwitcher = async () => {
|
|
599
|
-
const list = await fetch(`${sdk.url}/vcs/branches`)
|
|
600
|
-
.then((r) => r.json())
|
|
601
|
-
.catch(() => [])
|
|
602
|
-
if (!list || !Array.isArray(list)) return
|
|
603
|
-
|
|
604
|
-
const current = branch()
|
|
605
|
-
dialog.replace(() => (
|
|
606
|
-
<DialogSelect
|
|
607
|
-
title="Switch branch"
|
|
608
|
-
options={[
|
|
609
|
-
{ title: "+ New branch...", value: "__new__" },
|
|
610
|
-
...list.map((b: string) => ({
|
|
611
|
-
title: b,
|
|
612
|
-
value: b,
|
|
613
|
-
})),
|
|
614
|
-
]}
|
|
615
|
-
current={current}
|
|
616
|
-
onSelect={async (opt) => {
|
|
617
|
-
if (opt.value === "__new__") {
|
|
618
|
-
dialog.replace(() => (
|
|
619
|
-
<DialogPrompt
|
|
620
|
-
title="Create branch"
|
|
621
|
-
placeholder="branch-name"
|
|
622
|
-
onConfirm={async (name) => {
|
|
623
|
-
dialog.clear()
|
|
624
|
-
const trimmed = name.trim()
|
|
625
|
-
if (!trimmed) return
|
|
626
|
-
await runShell(`git checkout -b ${trimmed}`)
|
|
627
|
-
refreshGit()
|
|
628
|
-
}}
|
|
629
|
-
onCancel={() => openBranchSwitcher()}
|
|
630
|
-
/>
|
|
631
|
-
))
|
|
632
|
-
return
|
|
633
|
-
}
|
|
634
|
-
dialog.clear()
|
|
635
|
-
await fetch(`${sdk.url}/vcs/checkout`, {
|
|
636
|
-
method: "POST",
|
|
637
|
-
headers: { "Content-Type": "application/json" },
|
|
638
|
-
body: JSON.stringify({ branch: opt.value }),
|
|
639
|
-
})
|
|
640
|
-
refreshGit()
|
|
641
|
-
}}
|
|
642
|
-
/>
|
|
643
|
-
))
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
const openMergeDialog = () => {
|
|
647
|
-
dialog.replace(() => (
|
|
648
|
-
<DialogPrompt
|
|
649
|
-
title="Merge branch"
|
|
650
|
-
placeholder="Branch name (e.g. main)"
|
|
651
|
-
onConfirm={(value) => {
|
|
652
|
-
dialog.clear()
|
|
653
|
-
const name = value.trim()
|
|
654
|
-
if (!name) return
|
|
655
|
-
runShell(`git merge ${name}`)
|
|
656
|
-
}}
|
|
657
|
-
onCancel={() => dialog.clear()}
|
|
658
|
-
/>
|
|
659
|
-
))
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
useKeyboard((evt) => {
|
|
663
|
-
if (!props.open) return
|
|
664
|
-
if (dialog.stack.length > 0) return
|
|
665
|
-
if (keybind.match("navigator_resize_narrow", evt)) {
|
|
666
|
-
evt.preventDefault()
|
|
667
|
-
adjustListWidth(-0.05)
|
|
668
|
-
return
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
if (keybind.match("navigator_resize_wide", evt)) {
|
|
672
|
-
evt.preventDefault()
|
|
673
|
-
adjustListWidth(0.05)
|
|
674
|
-
return
|
|
675
|
-
}
|
|
676
|
-
if (promptRef.current?.focused) return
|
|
677
|
-
if (evt.name === "escape") {
|
|
678
|
-
evt.preventDefault()
|
|
679
|
-
return
|
|
680
|
-
}
|
|
681
|
-
if (evt.name === "tab") {
|
|
682
|
-
evt.preventDefault()
|
|
683
|
-
setTab((value) => (value === "explorer" ? "git" : "explorer"))
|
|
684
|
-
return
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
if (tab() === "explorer") {
|
|
688
|
-
if (evt.name === "up") {
|
|
689
|
-
selectExplorerIndex(selectedExplorer() - 1)
|
|
690
|
-
return
|
|
691
|
-
}
|
|
692
|
-
if (evt.name === "down") {
|
|
693
|
-
selectExplorerIndex(selectedExplorer() + 1)
|
|
694
|
-
return
|
|
695
|
-
}
|
|
696
|
-
if (evt.name === "home") {
|
|
697
|
-
selectExplorerIndex(0)
|
|
698
|
-
return
|
|
699
|
-
}
|
|
700
|
-
if (evt.name === "end") {
|
|
701
|
-
selectExplorerIndex(explorerEntries().length - 1)
|
|
702
|
-
return
|
|
703
|
-
}
|
|
704
|
-
if (evt.name === "left") {
|
|
705
|
-
const entry = selectedExplorerEntry()
|
|
706
|
-
if (!entry) return
|
|
707
|
-
if (entry.node.type !== "directory") return
|
|
708
|
-
if (!expanded[entry.node.path]) return
|
|
709
|
-
setExpanded(entry.node.path, false)
|
|
710
|
-
return
|
|
711
|
-
}
|
|
712
|
-
if (evt.name === "right") {
|
|
713
|
-
handleExplorerSelect()
|
|
714
|
-
return
|
|
715
|
-
}
|
|
716
|
-
if (evt.name === "return") {
|
|
717
|
-
handleExplorerSelect()
|
|
718
|
-
return
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
if (tab() === "git") {
|
|
723
|
-
if (evt.name === "up") {
|
|
724
|
-
selectGitIndex(selectedGit() - 1)
|
|
725
|
-
return
|
|
726
|
-
}
|
|
727
|
-
if (evt.name === "down") {
|
|
728
|
-
selectGitIndex(selectedGit() + 1)
|
|
729
|
-
return
|
|
730
|
-
}
|
|
731
|
-
if (evt.name === "home") {
|
|
732
|
-
selectGitIndex(0)
|
|
733
|
-
return
|
|
734
|
-
}
|
|
735
|
-
if (evt.name === "end") {
|
|
736
|
-
selectGitIndex(gitEntries().length - 1)
|
|
737
|
-
return
|
|
738
|
-
}
|
|
739
|
-
if (evt.name === "return") {
|
|
740
|
-
handleGitSelect()
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
})
|
|
744
|
-
|
|
745
|
-
// Auto-save when closing the navigator
|
|
746
|
-
createEffect(() => {
|
|
747
|
-
if (!props.open && isDirty()) {
|
|
748
|
-
void saveFile()
|
|
749
|
-
}
|
|
750
|
-
})
|
|
751
|
-
|
|
752
|
-
createEffect(() => {
|
|
753
|
-
const list = explorerEntries()
|
|
754
|
-
if (list.length === 0) return
|
|
755
|
-
const current = selectedExplorer()
|
|
756
|
-
if (current < list.length) return
|
|
757
|
-
// Only update if out of bounds
|
|
758
|
-
setSelectedExplorer(() => list.length - 1)
|
|
759
|
-
})
|
|
760
|
-
|
|
761
|
-
// Sync selectedExplorer with activePath so the selected file is highlighted in explorer
|
|
762
|
-
createEffect(() => {
|
|
763
|
-
const path = activePath()
|
|
764
|
-
if (!path) return
|
|
765
|
-
const list = explorerEntries()
|
|
766
|
-
const index = list.findIndex((entry) => entry.node.path === path)
|
|
767
|
-
if (index === -1) return
|
|
768
|
-
// Only update if different to avoid cycle
|
|
769
|
-
if (selectedExplorer() === index) return
|
|
770
|
-
setSelectedExplorer(() => index)
|
|
771
|
-
})
|
|
772
|
-
|
|
773
|
-
createEffect(() => {
|
|
774
|
-
if (loaded()) return
|
|
775
|
-
setLoaded(true)
|
|
776
|
-
loadDirectory("")
|
|
777
|
-
})
|
|
778
|
-
|
|
779
|
-
createEffect(() => {
|
|
780
|
-
const file = activePath()
|
|
781
|
-
const fileInfo = openFileInfo()
|
|
782
|
-
const isLoaded = loaded()
|
|
783
|
-
|
|
784
|
-
if (!isLoaded) return
|
|
785
|
-
|
|
786
|
-
if (!file) {
|
|
787
|
-
untrack(() => {
|
|
788
|
-
setFileContent(undefined)
|
|
789
|
-
setFileLoading(false)
|
|
790
|
-
setFileError(false)
|
|
791
|
-
// Clear editor when no file is selected
|
|
792
|
-
if (editorRef) {
|
|
793
|
-
editorRef.setText("")
|
|
794
|
-
}
|
|
795
|
-
})
|
|
796
|
-
return
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
// Wrap state updates and loading logic in untrack to prevent recursive loops
|
|
800
|
-
// We only want this effect to trigger on activePath, openFileInfo, or loaded changes.
|
|
801
|
-
untrack(() => {
|
|
802
|
-
// Skip if already loading this file
|
|
803
|
-
if (fileLoading() && currentLoadFile() === file) return
|
|
804
|
-
|
|
805
|
-
if (fileInfo?.path === file) {
|
|
806
|
-
setTargetLine(() => fileInfo.line)
|
|
807
|
-
// Clear navigation request to avoid re-triggering this repeatedly if it fails
|
|
808
|
-
setOpenFileInfo(() => undefined)
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
void loadFile(file)
|
|
812
|
-
})
|
|
813
|
-
})
|
|
814
|
-
|
|
815
|
-
createEffect(() => {
|
|
816
|
-
const data = fileData()
|
|
817
|
-
if (!data) return
|
|
818
|
-
if (data.encoding === "base64") return
|
|
819
|
-
// Clear targetLine after file data loads
|
|
820
|
-
if (targetLine()) {
|
|
821
|
-
setTargetLine(undefined)
|
|
822
|
-
}
|
|
823
|
-
})
|
|
824
|
-
|
|
825
|
-
// Initialize edit content when file data loads - only if file changed
|
|
826
|
-
createEffect(
|
|
827
|
-
on(fileData, (data) => {
|
|
828
|
-
const path = activePath()
|
|
829
|
-
if (!data || data.encoding === "base64" || !path) return
|
|
830
|
-
setCurrentFilePath(() => path)
|
|
831
|
-
setIsDirty(false)
|
|
832
|
-
setSaveStatus("idle")
|
|
833
|
-
if (editorRef && editorRef.plainText !== data.content) {
|
|
834
|
-
editorRef.setText(data.content ?? "")
|
|
835
|
-
}
|
|
836
|
-
}),
|
|
837
|
-
)
|
|
838
|
-
|
|
839
|
-
// Compute viewer state as a discriminated union for exclusive rendering
|
|
840
|
-
const viewerState = createMemo(() => {
|
|
841
|
-
const path = activePath()
|
|
842
|
-
if (!path) return { type: "empty" as const }
|
|
843
|
-
if (fileLoading()) return { type: "loading" as const }
|
|
844
|
-
if (fileError()) return { type: "error" as const }
|
|
845
|
-
const data = fileData()
|
|
846
|
-
if (!data) return { type: "no-content" as const }
|
|
847
|
-
if (data.encoding === "base64") return { type: "binary" as const, data }
|
|
848
|
-
return { type: "text" as const, data }
|
|
849
|
-
})
|
|
850
|
-
|
|
851
|
-
// Focus editor when clicking on the editor area
|
|
852
|
-
const focusEditor = () => {
|
|
853
|
-
if (viewerState().type === "text") {
|
|
854
|
-
setTimeout(() => editorRef?.focus(), 0)
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
const fileViewer = () => (
|
|
859
|
-
<scrollbox
|
|
860
|
-
flexGrow={1}
|
|
861
|
-
height="100%"
|
|
862
|
-
paddingTop={1}
|
|
863
|
-
viewportOptions={viewportOptions()}
|
|
864
|
-
verticalScrollbarOptions={verticalScrollbarOptions()}
|
|
865
|
-
scrollAcceleration={new CustomSpeedScroll(3)}
|
|
866
|
-
>
|
|
867
|
-
<Switch>
|
|
868
|
-
<Match when={viewerState().type === "empty"}>
|
|
869
|
-
<text fg={theme.theme.textMuted}>Select a file to edit</text>
|
|
870
|
-
</Match>
|
|
871
|
-
<Match when={viewerState().type === "loading"}>
|
|
872
|
-
<text fg={theme.theme.textMuted}>Loading...</text>
|
|
873
|
-
</Match>
|
|
874
|
-
<Match when={viewerState().type === "error"}>
|
|
875
|
-
<text fg={theme.theme.textMuted}>Unable to read file</text>
|
|
876
|
-
</Match>
|
|
877
|
-
<Match when={viewerState().type === "no-content"}>
|
|
878
|
-
<text fg={theme.theme.textMuted}>No content</text>
|
|
879
|
-
</Match>
|
|
880
|
-
<Match when={viewerState().type === "binary"}>
|
|
881
|
-
<BinaryPreview content={(viewerState() as { type: "binary"; data: FileContent }).data} />
|
|
882
|
-
</Match>
|
|
883
|
-
<Match when={viewerState().type === "text"}>
|
|
884
|
-
<box flexDirection="column" flexGrow={1} onMouseUp={focusEditor}>
|
|
885
|
-
<line_number
|
|
886
|
-
fg={theme.theme.textMuted}
|
|
887
|
-
bg={theme.theme.background}
|
|
888
|
-
paddingRight={1}
|
|
889
|
-
minWidth={3}
|
|
890
|
-
showLineNumbers={true}
|
|
891
|
-
flexGrow={1}
|
|
892
|
-
>
|
|
893
|
-
<textarea
|
|
894
|
-
ref={(r: TextareaRenderable) => {
|
|
895
|
-
editorRef = r
|
|
896
|
-
// Set initial content when ref is assigned
|
|
897
|
-
const state = viewerState()
|
|
898
|
-
if (state.type === "text" && state.data.content !== undefined && r.plainText !== state.data.content) {
|
|
899
|
-
r.setText(state.data.content ?? "")
|
|
900
|
-
}
|
|
901
|
-
}}
|
|
902
|
-
textColor={theme.theme.text}
|
|
903
|
-
focusedTextColor={theme.theme.text}
|
|
904
|
-
cursorColor={theme.theme.text}
|
|
905
|
-
focusedBackgroundColor={theme.theme.background}
|
|
906
|
-
minHeight={10}
|
|
907
|
-
flexGrow={1}
|
|
908
|
-
wrapMode={props.wrapMode ?? "none"}
|
|
909
|
-
syntaxStyle={theme.syntax()}
|
|
910
|
-
onContentChange={handleEditorChange}
|
|
911
|
-
onKeyDown={(e: { name: string; ctrl?: boolean; meta?: boolean; preventDefault: () => void }) => {
|
|
912
|
-
// Ctrl+S / Cmd+S to save
|
|
913
|
-
if ((e.ctrl || e.meta) && e.name === "s") {
|
|
914
|
-
e.preventDefault()
|
|
915
|
-
saveFile()
|
|
916
|
-
}
|
|
917
|
-
// Escape to blur
|
|
918
|
-
if (e.name === "escape") {
|
|
919
|
-
editorRef?.blur()
|
|
920
|
-
}
|
|
921
|
-
}}
|
|
922
|
-
/>
|
|
923
|
-
</line_number>
|
|
924
|
-
<Show when={fileData()?.diff}>
|
|
925
|
-
<VcsDiffViewer
|
|
926
|
-
diff={() => fileData()!.diff!}
|
|
927
|
-
fileType={fileType(activePath())}
|
|
928
|
-
wrapMode={props.wrapMode ?? "none"}
|
|
929
|
-
/>
|
|
930
|
-
</Show>
|
|
931
|
-
</box>
|
|
932
|
-
</Match>
|
|
933
|
-
</Switch>
|
|
934
|
-
</scrollbox>
|
|
935
|
-
)
|
|
936
|
-
|
|
937
|
-
const historyPanel = () => (
|
|
938
|
-
<GitHistory
|
|
939
|
-
branch={branch}
|
|
940
|
-
historyEntries={historyEntries}
|
|
941
|
-
historyHeight={historyHeight}
|
|
942
|
-
onBranchSwitcher={openBranchSwitcher}
|
|
943
|
-
viewportOptions={viewportOptions()}
|
|
944
|
-
verticalScrollbarOptions={verticalScrollbarOptions()}
|
|
945
|
-
/>
|
|
946
|
-
)
|
|
947
|
-
|
|
948
|
-
const edgeBorder = createMemo<("left" | "right")[]>(() => (props.side === "left" ? ["left"] : ["right"]))
|
|
949
|
-
|
|
950
|
-
const handleNavigatorClick = () => {
|
|
951
|
-
if (props.promptRef?.focused) return
|
|
952
|
-
props.promptRef?.focus()
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
return (
|
|
956
|
-
<box
|
|
957
|
-
width={props.open ? props.width : 0}
|
|
958
|
-
height="100%"
|
|
959
|
-
flexDirection="column"
|
|
960
|
-
backgroundColor={theme.theme.background}
|
|
961
|
-
border={props.open ? edgeBorder() : undefined}
|
|
962
|
-
customBorderChars={props.open ? NavigatorBorderChars : undefined}
|
|
963
|
-
borderColor={theme.theme.border}
|
|
964
|
-
visible={props.open}
|
|
965
|
-
onMouseUp={handleNavigatorClick}
|
|
966
|
-
>
|
|
967
|
-
<box
|
|
968
|
-
paddingLeft={2}
|
|
969
|
-
paddingRight={2}
|
|
970
|
-
paddingTop={1}
|
|
971
|
-
paddingBottom={1}
|
|
972
|
-
flexDirection="row"
|
|
973
|
-
justifyContent="space-between"
|
|
974
|
-
border={["bottom"]}
|
|
975
|
-
borderColor={theme.theme.border}
|
|
976
|
-
customBorderChars={NavigatorBorderChars}
|
|
977
|
-
>
|
|
978
|
-
<box flexDirection="column">
|
|
979
|
-
<text fg={theme.theme.text}>
|
|
980
|
-
<b>Navigator</b>
|
|
981
|
-
</text>
|
|
982
|
-
<text fg={theme.theme.textMuted}>{displayRoot()}</text>
|
|
983
|
-
</box>
|
|
984
|
-
<box onMouseUp={props.onClose} paddingLeft={1} paddingRight={1} backgroundColor={theme.theme.backgroundElement}>
|
|
985
|
-
<text fg={theme.theme.text}>Close</text>
|
|
986
|
-
</box>
|
|
987
|
-
</box>
|
|
988
|
-
<box flexGrow={1} flexDirection="row">
|
|
989
|
-
<box
|
|
990
|
-
width={listWidth()}
|
|
991
|
-
border={["right"]}
|
|
992
|
-
customBorderChars={NavigatorBorderChars}
|
|
993
|
-
borderColor={theme.theme.border}
|
|
994
|
-
flexDirection="column"
|
|
995
|
-
backgroundColor={theme.theme.background}
|
|
996
|
-
>
|
|
997
|
-
<box
|
|
998
|
-
backgroundColor={theme.theme.background}
|
|
999
|
-
flexDirection="row"
|
|
1000
|
-
justifyContent="center"
|
|
1001
|
-
paddingTop={0}
|
|
1002
|
-
paddingBottom={1}
|
|
1003
|
-
flexShrink={0}
|
|
1004
|
-
>
|
|
1005
|
-
<Tab label="Explorer" active={tab() === "explorer"} onSelect={() => setTab(() => "explorer")} />
|
|
1006
|
-
<Tab label="Git" active={tab() === "git"} onSelect={() => setTab(() => "git")} />
|
|
1007
|
-
</box>
|
|
1008
|
-
|
|
1009
|
-
<Switch>
|
|
1010
|
-
<Match when={tab() === "git"}>
|
|
1011
|
-
<GitCommit commitMessage={commitMessage} setCommitMessage={setCommitMessage} onCommit={handleCommit} />
|
|
1012
|
-
<Show
|
|
1013
|
-
when={hasGitEntries()}
|
|
1014
|
-
fallback={
|
|
1015
|
-
<box paddingLeft={2} paddingRight={2} paddingTop={1} flexGrow={1}>
|
|
1016
|
-
<text fg={theme.theme.textMuted}>No git changes</text>
|
|
1017
|
-
</box>
|
|
1018
|
-
}
|
|
1019
|
-
>
|
|
1020
|
-
<scrollbox
|
|
1021
|
-
flexGrow={1}
|
|
1022
|
-
height="100%"
|
|
1023
|
-
ref={(el) => setGitScroll(el)}
|
|
1024
|
-
viewportOptions={viewportOptions()}
|
|
1025
|
-
verticalScrollbarOptions={verticalScrollbarOptions()}
|
|
1026
|
-
scrollAcceleration={new CustomSpeedScroll(3)}
|
|
1027
|
-
>
|
|
1028
|
-
<For each={gitEntries()}>
|
|
1029
|
-
{(entry, index) => (
|
|
1030
|
-
<GitRow
|
|
1031
|
-
entry={entry}
|
|
1032
|
-
width={listWidth()}
|
|
1033
|
-
active={index() === selectedGit()}
|
|
1034
|
-
onSelect={() => {
|
|
1035
|
-
setSelectedGit(() => index())
|
|
1036
|
-
openFilePath(entry.path)
|
|
1037
|
-
}}
|
|
1038
|
-
/>
|
|
1039
|
-
)}
|
|
1040
|
-
</For>
|
|
1041
|
-
</scrollbox>
|
|
1042
|
-
</Show>
|
|
1043
|
-
{historyPanel()}
|
|
1044
|
-
</Match>
|
|
1045
|
-
<Match when={true}>
|
|
1046
|
-
<Show
|
|
1047
|
-
when={hasExplorerEntries()}
|
|
1048
|
-
fallback={
|
|
1049
|
-
<box paddingLeft={2} paddingRight={2} paddingTop={1}>
|
|
1050
|
-
<text fg={theme.theme.textMuted}>{loading[""] ? "Loading files..." : "No files found"}</text>
|
|
1051
|
-
</box>
|
|
1052
|
-
}
|
|
1053
|
-
>
|
|
1054
|
-
<scrollbox
|
|
1055
|
-
flexGrow={1}
|
|
1056
|
-
height="100%"
|
|
1057
|
-
ref={(el) => setExplorerScroll(el)}
|
|
1058
|
-
viewportOptions={viewportOptions()}
|
|
1059
|
-
verticalScrollbarOptions={verticalScrollbarOptions()}
|
|
1060
|
-
scrollAcceleration={new CustomSpeedScroll(3)}
|
|
1061
|
-
>
|
|
1062
|
-
<For each={explorerEntries()}>
|
|
1063
|
-
{(entry, index) => (
|
|
1064
|
-
<ExplorerRow
|
|
1065
|
-
entry={entry}
|
|
1066
|
-
width={listWidth()}
|
|
1067
|
-
active={index() === selectedExplorer()}
|
|
1068
|
-
status={statusMap().get(entry.node.path)}
|
|
1069
|
-
expanded={expanded[entry.node.path] ?? false}
|
|
1070
|
-
onSelect={() => {
|
|
1071
|
-
setSelectedExplorer(() => index())
|
|
1072
|
-
if (entry.node.type === "directory") {
|
|
1073
|
-
toggleDirectory(entry.node)
|
|
1074
|
-
return
|
|
1075
|
-
}
|
|
1076
|
-
openFile(entry.node)
|
|
1077
|
-
}}
|
|
1078
|
-
/>
|
|
1079
|
-
)}
|
|
1080
|
-
</For>
|
|
1081
|
-
</scrollbox>
|
|
1082
|
-
</Show>
|
|
1083
|
-
</Match>
|
|
1084
|
-
</Switch>
|
|
1085
|
-
</box>
|
|
1086
|
-
<box
|
|
1087
|
-
width={viewerWidth()}
|
|
1088
|
-
flexDirection="column"
|
|
1089
|
-
paddingLeft={2}
|
|
1090
|
-
paddingRight={2}
|
|
1091
|
-
paddingTop={1}
|
|
1092
|
-
paddingBottom={1}
|
|
1093
|
-
>
|
|
1094
|
-
<box justifyContent="center" paddingTop={1} paddingBottom={1} flexShrink={0}>
|
|
1095
|
-
<text fg={theme.theme.text}>
|
|
1096
|
-
<b>{viewTitle()}</b>
|
|
1097
|
-
</text>
|
|
1098
|
-
</box>
|
|
1099
|
-
{fileViewer()}
|
|
1100
|
-
</box>
|
|
1101
|
-
</box>
|
|
1102
|
-
<box
|
|
1103
|
-
paddingLeft={2}
|
|
1104
|
-
paddingRight={2}
|
|
1105
|
-
paddingTop={1}
|
|
1106
|
-
paddingBottom={1}
|
|
1107
|
-
flexDirection="row"
|
|
1108
|
-
justifyContent="space-between"
|
|
1109
|
-
>
|
|
1110
|
-
<text fg={theme.theme.textMuted}>
|
|
1111
|
-
{(() => {
|
|
1112
|
-
const status = saveStatus()
|
|
1113
|
-
if (status === "saving") return "Saving..."
|
|
1114
|
-
if (status === "saved") return "Saved"
|
|
1115
|
-
if (status === "error") return "Save failed"
|
|
1116
|
-
if (isDirty()) return "Unsaved changes"
|
|
1117
|
-
return "Click to edit"
|
|
1118
|
-
})()}
|
|
1119
|
-
</text>
|
|
1120
|
-
<text fg={theme.theme.textMuted}>{resizeLabel() ? `${resizeLabel()} - ` : ""}Esc: chat</text>
|
|
1121
|
-
</box>
|
|
1122
|
-
</box>
|
|
1123
|
-
)
|
|
1124
|
-
}
|