@zyro-sec/tui 1.0.2 → 1.0.3
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/AGENTS.md +6 -6
- package/bunfig.toml +4 -4
- package/package.json +11 -11
- package/src/app.tsx +1632 -1632
- package/src/attention-sounds.bun.ts +8 -8
- package/src/attention-sounds.node.ts +16 -16
- package/src/attention.ts +189 -189
- package/src/audio.d.ts +9 -9
- package/src/audio.ts +49 -49
- package/src/clipboard.ts +68 -68
- package/src/component/background-image.tsx +26 -26
- package/src/component/command-palette.tsx +74 -74
- package/src/component/devtools-bar.tsx +611 -611
- package/src/component/dialog-agent.tsx +33 -33
- package/src/component/dialog-background.tsx +102 -102
- package/src/component/dialog-config.tsx +494 -494
- package/src/component/dialog-debug.tsx +90 -90
- package/src/component/dialog-error-details.tsx +130 -130
- package/src/component/dialog-experiments.tsx +101 -101
- package/src/component/dialog-go-upsell.tsx +448 -448
- package/src/component/dialog-highlights.tsx +88 -88
- package/src/component/dialog-image-preview.tsx +85 -85
- package/src/component/dialog-install-mcp.tsx +25 -3
- package/src/component/dialog-integration.tsx +1332 -1332
- package/src/component/dialog-mcp.tsx +184 -184
- package/src/component/dialog-model-free.tsx +79 -79
- package/src/component/dialog-model.tsx +238 -238
- package/src/component/dialog-open.tsx +509 -509
- package/src/component/dialog-pair.tsx +123 -123
- package/src/component/dialog-session-list.tsx +328 -328
- package/src/component/dialog-session-rename.tsx +37 -37
- package/src/component/dialog-shell-output.tsx +194 -194
- package/src/component/dialog-skill.tsx +93 -93
- package/src/component/dialog-speed.tsx +48 -48
- package/src/component/dialog-stash.tsx +90 -90
- package/src/component/dialog-status.tsx +50 -50
- package/src/component/dialog-theme-list.tsx +56 -56
- package/src/component/dialog-update.tsx +144 -144
- package/src/component/dialog-variant.tsx +43 -43
- package/src/component/dialog-workspace-file-changes.tsx +187 -187
- package/src/component/dialog-workspaces.tsx +413 -413
- package/src/component/dialog-worktree-name.tsx +40 -40
- package/src/component/error-component.tsx +258 -258
- package/src/component/fade-in-text.tsx +113 -113
- package/src/component/go-upsell-art.ts +338 -338
- package/src/component/logo.tsx +79 -79
- package/src/component/masked-text.ts +59 -59
- package/src/component/media-source.ts +43 -43
- package/src/component/migration-overlay.tsx +73 -73
- package/src/component/model-options.tsx +121 -121
- package/src/component/one-cell-spinner.tsx +75 -75
- package/src/component/panel-host.tsx +64 -64
- package/src/component/patch-diff.tsx +211 -211
- package/src/component/plugin-route-missing.tsx +21 -21
- package/src/component/prompt/autocomplete.tsx +1005 -1005
- package/src/component/prompt/draft-stash.ts +47 -47
- package/src/component/prompt/index.tsx +2080 -2080
- package/src/component/prompt/local-attachment.ts +188 -188
- package/src/component/prompt/metadata.tsx +193 -193
- package/src/component/prompt/move.tsx +181 -181
- package/src/component/reconnecting.tsx +40 -40
- package/src/component/retry-provider.tsx +202 -202
- package/src/component/session-frame.tsx +408 -408
- package/src/component/session-tabs-rail.tsx +94 -94
- package/src/component/session-tabs.tsx +1789 -1789
- package/src/component/shimmer-text.tsx +64 -64
- package/src/component/spinner-frames.ts +1 -1
- package/src/component/spinner-renderable.ts +126 -126
- package/src/component/spinner.tsx +50 -50
- package/src/component/startup-loading.tsx +63 -63
- package/src/component/tab-pulse.tsx +819 -819
- package/src/component/terminal-pane.tsx +377 -377
- package/src/component/theme-error-toast.tsx +20 -20
- package/src/component/title-shimmer.tsx +272 -272
- package/src/component/todo-item.tsx +27 -27
- package/src/component/usage.tsx +329 -329
- package/src/component/use-connected.tsx +14 -14
- package/src/config/index.tsx +438 -438
- package/src/config/keybind.ts +367 -367
- package/src/config/new-session-location.ts +16 -16
- package/src/config/v1/index.tsx +149 -149
- package/src/config/v1/keybind.ts +463 -463
- package/src/context/args.tsx +31 -31
- package/src/context/attention.tsx +23 -23
- package/src/context/client-mcp.tsx +119 -119
- package/src/context/client.tsx +76 -76
- package/src/context/clipboard.tsx +19 -19
- package/src/context/data.tsx +69 -69
- package/src/context/editor.ts +408 -408
- package/src/context/epilogue.tsx +14 -14
- package/src/context/event.ts +32 -32
- package/src/context/exit.tsx +8 -8
- package/src/context/helper.tsx +26 -26
- package/src/context/interactivity.tsx +20 -20
- package/src/context/keymap.tsx +515 -515
- package/src/context/local.tsx +723 -723
- package/src/context/location.tsx +80 -80
- package/src/context/log.tsx +24 -24
- package/src/context/panel.tsx +59 -59
- package/src/context/path-format.tsx +12 -12
- package/src/context/permission.tsx +18 -18
- package/src/context/program-status.ts +94 -94
- package/src/context/prompt.tsx +18 -18
- package/src/context/route.tsx +73 -73
- package/src/context/runtime.tsx +98 -98
- package/src/context/session-tabs-model.ts +263 -263
- package/src/context/session-tabs.tsx +508 -508
- package/src/context/session-terminals.tsx +136 -136
- package/src/context/storage.tsx +150 -150
- package/src/context/theme.tsx +447 -447
- package/src/context/thinking.ts +20 -20
- package/src/context/update-notification.tsx +158 -158
- package/src/devtools/index.ts +41 -41
- package/src/editor-zed-sqlite.bun.ts +1 -1
- package/src/editor-zed-sqlite.node.ts +21 -21
- package/src/editor-zed.ts +277 -277
- package/src/editor.ts +86 -86
- package/src/feature-plugins/home/footer.tsx +116 -116
- package/src/feature-plugins/prompt/btw.tsx +190 -190
- package/src/feature-plugins/prompt/footer.tsx +163 -163
- package/src/feature-plugins/prompt/goal.tsx +211 -211
- package/src/feature-plugins/sidebar/context.tsx +52 -52
- package/src/feature-plugins/sidebar/footer.tsx +126 -126
- package/src/feature-plugins/sidebar/limit.tsx +47 -47
- package/src/feature-plugins/sidebar/mcp.tsx +103 -103
- package/src/feature-plugins/sidebar/todo.tsx +58 -58
- package/src/feature-plugins/system/diff-viewer-file-menu.tsx +87 -87
- package/src/feature-plugins/system/diff-viewer-file-tree-utils.ts +174 -174
- package/src/feature-plugins/system/diff-viewer-file-tree.tsx +274 -274
- package/src/feature-plugins/system/diff-viewer-image.tsx +96 -96
- package/src/feature-plugins/system/diff-viewer.tsx +1380 -1380
- package/src/feature-plugins/system/notifications.ts +102 -102
- package/src/feature-plugins/system/plugins.tsx +356 -356
- package/src/feature-plugins/system/stats-data.ts +18 -18
- package/src/feature-plugins/system/stats.tsx +217 -217
- package/src/feature-plugins/system/storybook/footer.tsx +51 -51
- package/src/feature-plugins/system/storybook/highlights.tsx +71 -71
- package/src/feature-plugins/system/storybook/index.tsx +153 -153
- package/src/feature-plugins/system/storybook/link-clicks.tsx +125 -125
- package/src/feature-plugins/system/storybook/merman-layouts.tsx +200 -200
- package/src/feature-plugins/system/storybook/one-cell-spinner.fixtures.ts +144 -144
- package/src/feature-plugins/system/storybook/one-cell-spinner.tsx +293 -293
- package/src/feature-plugins/system/storybook/session-location-missing.tsx +80 -80
- package/src/feature-plugins/system/storybook/session-tabs.tsx +571 -571
- package/src/feature-plugins/system/storybook/subcell-spinner.fixtures.ts +115 -115
- package/src/feature-plugins/system/storybook/todo.tsx +166 -166
- package/src/index.tsx +2 -2
- package/src/logo.ts +21 -21
- package/src/mini/catalog.shared.ts +116 -116
- package/src/mini/demo.ts +1086 -1086
- package/src/mini/entry.body.ts +244 -244
- package/src/mini/footer.command.tsx +1205 -1205
- package/src/mini/footer.form.tsx +647 -647
- package/src/mini/footer.menu.tsx +313 -313
- package/src/mini/footer.permission.tsx +562 -562
- package/src/mini/footer.prompt.tsx +1533 -1533
- package/src/mini/footer.subagent.tsx +268 -268
- package/src/mini/footer.ts +1193 -1193
- package/src/mini/footer.view.tsx +1022 -1022
- package/src/mini/footer.width.ts +118 -118
- package/src/mini/form.shared.ts +241 -241
- package/src/mini/index.ts +7 -7
- package/src/mini/mono.ts +277 -277
- package/src/mini/permission.shared.ts +199 -199
- package/src/mini/prompt.editor.ts +74 -74
- package/src/mini/prompt.shared.ts +192 -192
- package/src/mini/runtime.boot.ts +98 -98
- package/src/mini/runtime.lifecycle.ts +393 -393
- package/src/mini/runtime.queue.ts +320 -320
- package/src/mini/runtime.ts +1117 -1117
- package/src/mini/scrollback.shared.ts +82 -82
- package/src/mini/scrollback.surface.ts +548 -548
- package/src/mini/scrollback.writer.tsx +380 -380
- package/src/mini/session-data.ts +13 -13
- package/src/mini/session.shared.ts +113 -113
- package/src/mini/splash.ts +307 -307
- package/src/mini/stream-v2.fragment.ts +83 -83
- package/src/mini/stream-v2.image.ts +38 -38
- package/src/mini/stream-v2.subagent.ts +1130 -1130
- package/src/mini/stream-v2.transport.ts +1916 -1916
- package/src/mini/stream.ts +152 -152
- package/src/mini/theme.ts +328 -328
- package/src/mini/tool.public.ts +3 -3
- package/src/mini/tool.ts +1394 -1394
- package/src/mini/turn-summary.ts +21 -21
- package/src/mini/types.ts +482 -482
- package/src/mini/variant.shared.ts +58 -58
- package/src/mini/verbosity.ts +84 -84
- package/src/model-preference.ts +206 -206
- package/src/parsers-config.ts +386 -386
- package/src/plugin/api.tsx +486 -486
- package/src/plugin/builtins.ts +35 -35
- package/src/plugin/context.tsx +757 -757
- package/src/plugin/discovery.ts +67 -67
- package/src/plugin/markdown.ts +18 -18
- package/src/plugin/render.tsx +116 -116
- package/src/plugin/runtime-plugin-support.bun.ts +11 -11
- package/src/plugin/runtime-plugin-support.node.ts +1 -1
- package/src/plugin/source.ts +1 -1
- package/src/plugin/structure.ts +159 -159
- package/src/plugin/watch.ts +113 -113
- package/src/prompt/attachment.ts +97 -97
- package/src/prompt/codec.ts +61 -61
- package/src/prompt/content.ts +22 -22
- package/src/prompt/directory-completion.ts +97 -97
- package/src/prompt/directory-recents.ts +36 -36
- package/src/prompt/display.ts +41 -41
- package/src/prompt/frecency.tsx +80 -80
- package/src/prompt/history.tsx +175 -175
- package/src/prompt/mention.ts +173 -173
- package/src/prompt/parse.ts +25 -25
- package/src/prompt/part.ts +35 -35
- package/src/prompt/restore.ts +39 -39
- package/src/prompt/stash.tsx +93 -93
- package/src/prompt/traits.ts +29 -29
- package/src/routes/home.tsx +180 -180
- package/src/routes/session/activity-summary.ts +101 -101
- package/src/routes/session/anchor-view.tsx +53 -53
- package/src/routes/session/anchors.ts +85 -85
- package/src/routes/session/composer/context.ts +24 -24
- package/src/routes/session/composer/index.tsx +143 -143
- package/src/routes/session/composer/scripts-tab.tsx +166 -166
- package/src/routes/session/composer/shell-tab.tsx +149 -149
- package/src/routes/session/composer/subagents-tab.tsx +264 -264
- package/src/routes/session/composer/tabs.ts +91 -91
- package/src/routes/session/composer/terminals-tab.tsx +114 -114
- package/src/routes/session/dialog-execute.tsx +276 -276
- package/src/routes/session/dialog-fork.tsx +87 -87
- package/src/routes/session/dialog-message.tsx +89 -89
- package/src/routes/session/dialog-timeline.tsx +43 -43
- package/src/routes/session/form.tsx +1177 -1177
- package/src/routes/session/group-view.tsx +407 -407
- package/src/routes/session/grouping/session.ts +184 -184
- package/src/routes/session/grouping/tree.ts +111 -111
- package/src/routes/session/history.ts +59 -59
- package/src/routes/session/index.tsx +3922 -3922
- package/src/routes/session/location-missing.tsx +81 -81
- package/src/routes/session/message-navigation.ts +48 -48
- package/src/routes/session/message-parts.tsx +322 -322
- package/src/routes/session/mount-budget.ts +38 -38
- package/src/routes/session/permission.tsx +622 -622
- package/src/routes/session/render-context.tsx +44 -44
- package/src/routes/session/rows.ts +493 -493
- package/src/routes/session/sidebar.tsx +80 -80
- package/src/routes/session/thinking-syntax.ts +8 -8
- package/src/runtime.tsx +1 -1
- package/src/simulation/semantics.ts +12 -12
- package/src/theme/assets/aura.json +69 -69
- package/src/theme/assets/ayu.json +80 -80
- package/src/theme/assets/carbonfox.json +248 -248
- package/src/theme/assets/catppuccin-frappe.json +230 -230
- package/src/theme/assets/catppuccin-macchiato.json +230 -230
- package/src/theme/assets/catppuccin.json +112 -112
- package/src/theme/assets/cobalt2.json +225 -225
- package/src/theme/assets/cursor.json +249 -249
- package/src/theme/assets/dracula.json +219 -219
- package/src/theme/assets/everforest.json +241 -241
- package/src/theme/assets/flexoki.json +237 -237
- package/src/theme/assets/github.json +233 -233
- package/src/theme/assets/gruvbox.json +242 -242
- package/src/theme/assets/kanagawa.json +77 -77
- package/src/theme/assets/lucent-orng.json +234 -234
- package/src/theme/assets/material.json +235 -235
- package/src/theme/assets/matrix.json +77 -77
- package/src/theme/assets/mercury.json +252 -252
- package/src/theme/assets/monokai.json +221 -221
- package/src/theme/assets/nightowl.json +221 -221
- package/src/theme/assets/nord.json +223 -223
- package/src/theme/assets/one-dark.json +84 -84
- package/src/theme/assets/opencode.json +245 -245
- package/src/theme/assets/orng.json +249 -249
- package/src/theme/assets/osaka-jade.json +93 -93
- package/src/theme/assets/palenight.json +222 -222
- package/src/theme/assets/rosepine.json +234 -234
- package/src/theme/assets/solarized.json +223 -223
- package/src/theme/assets/synthwave84.json +226 -226
- package/src/theme/assets/tokyonight.json +243 -243
- package/src/theme/assets/v2/opencode-classic.json +387 -387
- package/src/theme/assets/v2/opencode.json +395 -395
- package/src/theme/assets/vercel.json +245 -245
- package/src/theme/assets/vesper.json +218 -218
- package/src/theme/assets/zenburn.json +223 -223
- package/src/theme/color.ts +48 -48
- package/src/theme/component.ts +51 -51
- package/src/theme/discovery.ts +21 -21
- package/src/theme/index.ts +109 -109
- package/src/theme/resolve.ts +53 -53
- package/src/theme/system.ts +144 -144
- package/src/theme/v1.ts +70 -70
- package/src/ui/animation.ts +235 -235
- package/src/ui/border.ts +21 -21
- package/src/ui/dialog-alert.tsx +51 -51
- package/src/ui/dialog-confirm.tsx +62 -62
- package/src/ui/dialog-export-options.tsx +316 -316
- package/src/ui/dialog-export-result.tsx +84 -84
- package/src/ui/dialog-help.tsx +40 -40
- package/src/ui/dialog-prompt.tsx +180 -180
- package/src/ui/dialog-select.tsx +1006 -1006
- package/src/ui/dialog.tsx +560 -560
- package/src/ui/file-path.tsx +112 -112
- package/src/ui/layout.ts +26 -26
- package/src/ui/link.tsx +51 -51
- package/src/ui/one-cell-motion.ts +111 -111
- package/src/ui/pane-resize-handle.tsx +33 -33
- package/src/ui/pane-resize.ts +76 -76
- package/src/ui/select-controller.ts +45 -45
- package/src/ui/session-link.ts +92 -92
- package/src/ui/spinner.ts +368 -368
- package/src/ui/subcell.ts +37 -37
- package/src/ui/toast.tsx +222 -222
- package/src/ui/working-directory-actions.tsx +66 -66
- package/src/util/collapse-tool-output.ts +95 -95
- package/src/util/config-directories.ts +53 -53
- package/src/util/connected-provider.ts +15 -15
- package/src/util/delayed-presence.ts +34 -34
- package/src/util/diff.ts +84 -84
- package/src/util/error-details.ts +21 -21
- package/src/util/error.ts +141 -141
- package/src/util/filetype.ts +135 -135
- package/src/util/form.ts +146 -146
- package/src/util/highlights.ts +51 -51
- package/src/util/locale.ts +81 -81
- package/src/util/marquee.ts +51 -51
- package/src/util/media.ts +43 -43
- package/src/util/model.ts +33 -33
- package/src/util/path-format.ts +37 -37
- package/src/util/path.ts +12 -12
- package/src/util/permission.ts +188 -188
- package/src/util/persistence.ts +42 -42
- package/src/util/presentation.ts +42 -42
- package/src/util/project.ts +7 -7
- package/src/util/record.ts +3 -3
- package/src/util/renderer.ts +15 -15
- package/src/util/scroll.ts +29 -29
- package/src/util/selection.ts +103 -103
- package/src/util/session.ts +103 -103
- package/src/util/signal.ts +49 -49
- package/src/util/single-flight.ts +12 -12
- package/src/util/string-width.bun.ts +1 -1
- package/src/util/string-width.node.ts +26 -26
- package/src/util/string-width.ts +1 -1
- package/src/util/system.ts +23 -23
- package/src/util/todo.ts +43 -43
- package/src/util/tool-display.ts +70 -70
- package/src/util/usage-limits.ts +152 -152
- package/src/util/watch.ts +24 -24
- package/test/app-lifecycle.test.tsx +2962 -2962
- package/test/clear-session.test.tsx +67 -67
- package/test/cli/tui/__snapshots__/inline-tool-wrap-snapshot.test.tsx.snap +22 -22
- package/test/cli/tui/command-palette.test.tsx +86 -86
- package/test/cli/tui/composer-keymap.test.tsx +346 -346
- package/test/cli/tui/data.test.tsx +3669 -3669
- package/test/cli/tui/dialog-integration.test.tsx +588 -588
- package/test/cli/tui/dialog-mcp.test.tsx +197 -197
- package/test/cli/tui/dialog-open.test.tsx +1037 -1037
- package/test/cli/tui/dialog-prompt.test.tsx +253 -253
- package/test/cli/tui/dialog-select.test.tsx +740 -740
- package/test/cli/tui/dialog-session-list.test.tsx +130 -130
- package/test/cli/tui/diff-viewer-file-tree.test.tsx +256 -256
- package/test/cli/tui/diff-viewer-image.test.tsx +172 -172
- package/test/cli/tui/diff-viewer.test.tsx +2510 -2510
- package/test/cli/tui/form.test.tsx +950 -950
- package/test/cli/tui/group-view.test.tsx +352 -352
- package/test/cli/tui/inline-tool-wrap-snapshot.test.tsx +248 -248
- package/test/cli/tui/input-scope.test.tsx +282 -282
- package/test/cli/tui/keymap-arguments.test.tsx +45 -45
- package/test/cli/tui/plugins-dialog.test.tsx +217 -217
- package/test/cli/tui/prompt-interrupt-status.test.tsx +25 -25
- package/test/cli/tui/prompt-move.test.tsx +446 -446
- package/test/cli/tui/reasoning-body.test.tsx +80 -80
- package/test/cli/tui/theme-mode.test.tsx +179 -179
- package/test/cli/tui/toast.test.tsx +117 -117
- package/test/cli/tui/use-event.test.tsx +295 -295
- package/test/client-mcp.test.tsx +226 -226
- package/test/command-selection.test.tsx +123 -123
- package/test/compact-admission.test.tsx +251 -251
- package/test/completion-notices.test.tsx +197 -197
- package/test/component/animation-ticks.test.tsx +212 -212
- package/test/component/dialog-error-details.test.tsx +110 -110
- package/test/component/dialog-export-options.test.tsx +68 -68
- package/test/component/dialog-highlights.test.tsx +73 -73
- package/test/component/dialog-model.test.tsx +145 -145
- package/test/component/dialog-shell-output.test.tsx +255 -255
- package/test/component/dialog-speed.test.tsx +114 -114
- package/test/component/dialog-update.test.tsx +111 -111
- package/test/component/dialog-variant.test.tsx +24 -24
- package/test/component/go-upsell-art.test.tsx +110 -110
- package/test/component/retry-provider.test.tsx +288 -288
- package/test/component/session-tabs-marquee.test.tsx +100 -100
- package/test/component/session-tabs-mouse.test.tsx +216 -216
- package/test/component/session-tabs-rail.test.tsx +120 -120
- package/test/component/session-tabs-status.test.tsx +345 -345
- package/test/component/shimmer-text.test.tsx +37 -37
- package/test/component/spinner-renderable.test.tsx +133 -133
- package/test/component/tab-pulse.test.tsx +196 -196
- package/test/config-v2.test.tsx +335 -335
- package/test/config.test.tsx +184 -184
- package/test/context/local-selection.test.tsx +204 -204
- package/test/context/session-tabs.test.tsx +864 -864
- package/test/context/theme.test.tsx +183 -183
- package/test/copy-session-id.test.tsx +79 -79
- package/test/feature-plugins/goal.test.tsx +126 -126
- package/test/feature-plugins/prompt-footer.test.tsx +303 -303
- package/test/feature-plugins/sidebar-context.test.tsx +70 -70
- package/test/feature-plugins/sidebar-footer.test.tsx +139 -139
- package/test/fixture/animation-ticks.ts +19 -19
- package/test/fixture/app.ts +95 -95
- package/test/fixture/diff-image.ts +7 -7
- package/test/fixture/fixture.ts +27 -27
- package/test/fixture/frame.ts +25 -25
- package/test/fixture/local.tsx +158 -158
- package/test/fixture/plugin/client-reads/tui.tsx +9 -9
- package/test/fixture/plugin/dialog-throw/tui.tsx +11 -11
- package/test/fixture/plugin/native-resources/tui.tsx +26 -26
- package/test/fixture/plugin/setup-keymap/tui.tsx +72 -72
- package/test/fixture/plugin/slot-string/tui.tsx +10 -10
- package/test/fixture/tui-client.ts +186 -186
- package/test/fixture/tui-environment.tsx +47 -47
- package/test/fixture/tui-runtime.ts +21 -21
- package/test/interactivity.test.tsx +46 -46
- package/test/keymap-scope.test.tsx +271 -271
- package/test/keymap.test.tsx +244 -244
- package/test/markdown-streaming.test.tsx +49 -49
- package/test/mini/blocker.responsive.test.tsx +732 -732
- package/test/mini/fixture/catalog.ts +63 -63
- package/test/mini/fixture/footer-api.ts +69 -69
- package/test/mini/fixture/tool-part.ts +20 -20
- package/test/mini/footer-keymap.test.tsx +141 -141
- package/test/mini/footer.responsive.test.tsx +438 -438
- package/test/mini/footer.view.test.tsx +2627 -2627
- package/test/new-session-id.test.tsx +102 -102
- package/test/plugin-keymap.test.tsx +143 -143
- package/test/plugin-markdown.test.tsx +120 -120
- package/test/plugin-model.test.tsx +46 -46
- package/test/plugin-native-resources.test.tsx +11 -11
- package/test/plugin-select.test.tsx +391 -391
- package/test/plugin-slot-output.test.tsx +23 -23
- package/test/plugin-toast.test.tsx +62 -62
- package/test/preload.ts +17 -17
- package/test/prompt/history-composer.test.tsx +52 -52
- package/test/prompt/history-provider.test.tsx +108 -108
- package/test/prompt-cursor.test.tsx +27 -27
- package/test/prompt-offset.test.tsx +58 -58
- package/test/prompt-paste.test.tsx +127 -127
- package/test/prompt-shell-failure.test.tsx +76 -76
- package/test/routes/composer-tabs.test.tsx +97 -97
- package/test/runtime.test.tsx +37 -37
- package/test/session-activity-anchor.test.tsx +180 -180
- package/test/session-backfill-disclosure.test.tsx +89 -89
- package/test/session-dialog-resync.test.tsx +122 -122
- package/test/session-fork-pending.test.tsx +60 -60
- package/test/session-group-navigation.test.tsx +252 -252
- package/test/session-history-interactions.test.tsx +305 -305
- package/test/session-history-reveal.test.tsx +108 -108
- package/test/session-home.test.tsx +401 -401
- package/test/session-interrupt-undo.test.tsx +98 -98
- package/test/session-media-refs.test.tsx +360 -360
- package/test/session-mount-budget.test.tsx +137 -137
- package/test/session-panel.test.tsx +721 -721
- package/test/session-shell-output.test.tsx +114 -114
- package/test/session-shell-stopped.test.tsx +107 -107
- package/test/session-subagent-navigation.test.tsx +44 -44
- package/test/session-submit-scroll.test.tsx +85 -85
- package/test/session-terminal-availability.test.tsx +80 -80
- package/test/session-wheel-focus.test.tsx +176 -176
- package/test/stats.view.test.tsx +94 -94
- package/test/theme/v2/types.typecheck.ts +57 -57
- package/test/ui/dialog-layout.test.tsx +56 -56
- package/test/ui/link.test.tsx +60 -60
- package/test/ui/pane-resize-handle.test.tsx +134 -134
- package/test/ui/session-link.test.tsx +325 -325
- package/test/usage-limits.test.tsx +162 -162
- package/test/util/selection-copy-on-select.test.tsx +64 -64
- package/tsconfig.json +13 -13
- package/test/cli/cmd/tui/integration-options.test.ts +0 -98
- package/test/cli/cmd/tui/model-options.test.ts +0 -105
- package/test/cli/cmd/tui/notifications.test.ts +0 -356
- package/test/cli/tui/anchors.test.ts +0 -77
- package/test/cli/tui/collapse-tool-output.test.ts +0 -14
- package/test/cli/tui/group-boundary.test.ts +0 -63
- package/test/cli/tui/grouping-tree.test.ts +0 -82
- package/test/cli/tui/message-navigation.test.ts +0 -164
- package/test/cli/tui/mount-budget.test.ts +0 -74
- package/test/cli/tui/permission.test.ts +0 -7
- package/test/cli/tui/script-changes.test.ts +0 -41
- package/test/cli/tui/session-grouping.test.ts +0 -21
- package/test/cli/tui/session-history.test.ts +0 -124
- package/test/cli/tui/session-rows.test.ts +0 -616
- package/test/cli/tui/session-verbosity.test.ts +0 -307
- package/test/cli/tui/thinking.test.ts +0 -36
- package/test/clipboard.test.ts +0 -148
- package/test/component/terminal-pane-theme.test.ts +0 -68
- package/test/context/local.test.ts +0 -15
- package/test/context/program-status.test.ts +0 -73
- package/test/context/session-retention.test.ts +0 -234
- package/test/context/session-tabs-model.test.ts +0 -341
- package/test/context/storage.test.ts +0 -37
- package/test/editor.test.ts +0 -69
- package/test/feature-plugins/diff-viewer-file-tree-utils.test.ts +0 -234
- package/test/feature-plugins/home-footer.test.ts +0 -13
- package/test/highlights.test.ts +0 -43
- package/test/keybind.test.ts +0 -7
- package/test/mini/catalog.shared.test.ts +0 -76
- package/test/mini/entry.body.test.ts +0 -622
- package/test/mini/footer.menu.test.ts +0 -43
- package/test/mini/footer.test.ts +0 -446
- package/test/mini/footer.width.test.ts +0 -120
- package/test/mini/form.shared.test.ts +0 -66
- package/test/mini/permission.shared.test.ts +0 -195
- package/test/mini/prompt.editor.test.ts +0 -118
- package/test/mini/prompt.shared.test.ts +0 -104
- package/test/mini/runtime.boot.test.ts +0 -118
- package/test/mini/runtime.queue.test.ts +0 -443
- package/test/mini/runtime.test.ts +0 -591
- package/test/mini/scrollback.image.test.ts +0 -213
- package/test/mini/scrollback.surface.test.ts +0 -1078
- package/test/mini/session.shared.test.ts +0 -267
- package/test/mini/splash.test.ts +0 -196
- package/test/mini/stream-v2.transport.test.ts +0 -4705
- package/test/mini/stream.test.ts +0 -52
- package/test/mini/theme.test.ts +0 -438
- package/test/mini/tool.test.ts +0 -134
- package/test/mini/variant.shared.test.ts +0 -58
- package/test/mini/verbosity.test.ts +0 -53
- package/test/model-preference.test.ts +0 -70
- package/test/new-session-location.test.ts +0 -30
- package/test/panel.test.ts +0 -71
- package/test/plugin-discovery.test.ts +0 -18
- package/test/plugin-source.test.ts +0 -871
- package/test/prompt/attachment.test.ts +0 -138
- package/test/prompt/autocomplete.test.ts +0 -218
- package/test/prompt/codec.test.ts +0 -136
- package/test/prompt/display.test.ts +0 -72
- package/test/prompt/draft-stash.test.ts +0 -42
- package/test/prompt/history.test.ts +0 -94
- package/test/prompt/jsonl.test.ts +0 -24
- package/test/prompt/local-attachment.test.ts +0 -244
- package/test/prompt/mention.test.ts +0 -119
- package/test/prompt/parse.test.ts +0 -46
- package/test/prompt/part.test.ts +0 -40
- package/test/prompt/persistence.test.ts +0 -23
- package/test/prompt/traits.test.ts +0 -25
- package/test/simulation/semantics.test.ts +0 -23
- package/test/stats.test.ts +0 -33
- package/test/theme/v2/component.test.ts +0 -87
- package/test/theme/v2/resolve.test.ts +0 -424
- package/test/theme/v2/select.test.ts +0 -25
- package/test/theme/v2/v1-migrate.test.ts +0 -397
- package/test/theme.test.ts +0 -150
- package/test/ui/file-path.test.ts +0 -61
- package/test/ui/layout.test.ts +0 -31
- package/test/ui/pane-resize.test.ts +0 -258
- package/test/ui/select-controller.test.ts +0 -44
- package/test/util/added-patch.test.ts +0 -44
- package/test/util/connected-provider.test.ts +0 -59
- package/test/util/delayed-presence.test.ts +0 -114
- package/test/util/error-details.test.ts +0 -26
- package/test/util/error.test.ts +0 -36
- package/test/util/filetype.test.ts +0 -23
- package/test/util/form.test.ts +0 -110
- package/test/util/locale.test.ts +0 -32
- package/test/util/marquee.test.ts +0 -45
- package/test/util/media.test.ts +0 -54
- package/test/util/model.test.ts +0 -70
- package/test/util/path-format.test.ts +0 -15
- package/test/util/permission.test.ts +0 -23
- package/test/util/presentation.test.ts +0 -30
- package/test/util/renderer.test.ts +0 -42
- package/test/util/selection-keys.test.ts +0 -172
- package/test/util/selection.test.ts +0 -115
- package/test/util/session.test.ts +0 -70
- package/test/util/tool-display.test.ts +0 -65
- package/test/util/usage-limits.test.ts +0 -154
|
@@ -1,1789 +1,1789 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BoxRenderable,
|
|
3
|
-
CliRenderEvents,
|
|
4
|
-
RGBA,
|
|
5
|
-
ScrollBoxRenderable,
|
|
6
|
-
TextAttributes,
|
|
7
|
-
type MouseEvent,
|
|
8
|
-
type TimerHandle,
|
|
9
|
-
} from "@opentui/core"
|
|
10
|
-
import {
|
|
11
|
-
For,
|
|
12
|
-
Index,
|
|
13
|
-
Match,
|
|
14
|
-
Show,
|
|
15
|
-
Switch,
|
|
16
|
-
createComputed,
|
|
17
|
-
createEffect,
|
|
18
|
-
createMemo,
|
|
19
|
-
createSignal,
|
|
20
|
-
onCleanup,
|
|
21
|
-
untrack,
|
|
22
|
-
} from "solid-js"
|
|
23
|
-
import { onAnimationTick, Portal, useRenderer, useTerminalDimensions } from "@opentui/solid"
|
|
24
|
-
import { useConfig } from "../config"
|
|
25
|
-
import { useSessionTabs } from "../context/session-tabs"
|
|
26
|
-
import { useData } from "../context/data"
|
|
27
|
-
import { useClipboard } from "../context/clipboard"
|
|
28
|
-
import { useTheme } from "../context/theme"
|
|
29
|
-
import {
|
|
30
|
-
adaptiveSessionTabLayout,
|
|
31
|
-
moveSessionTab,
|
|
32
|
-
NEW_SESSION_TAB_TITLE,
|
|
33
|
-
sessionTabComplete,
|
|
34
|
-
sessionTabDetail,
|
|
35
|
-
sessionTabNumberLabel,
|
|
36
|
-
seedSessionTabMotion,
|
|
37
|
-
sessionTabOverflowWidth,
|
|
38
|
-
type SessionTab,
|
|
39
|
-
type SessionTabUnread,
|
|
40
|
-
} from "../context/session-tabs-model"
|
|
41
|
-
import { createAnimatable, spring, tween } from "../ui/animation"
|
|
42
|
-
import { Locale } from "../util/locale"
|
|
43
|
-
import { TabPulse, unreadGlowIntensity } from "./tab-pulse"
|
|
44
|
-
import { tint } from "../theme/color"
|
|
45
|
-
import { SESSION_SIDEBAR_WIDTH, SESSION_TABS_COMPACT_BREAKPOINT } from "../ui/layout"
|
|
46
|
-
import { projectName } from "../util/project"
|
|
47
|
-
import { stringWidth } from "../util/string-width"
|
|
48
|
-
import { marqueeCycleWidth, marqueeOverflows, marqueeTextParts } from "../util/marquee"
|
|
49
|
-
import { useDialog } from "../ui/dialog"
|
|
50
|
-
import { useToast } from "../ui/toast"
|
|
51
|
-
import { DialogSessionRename } from "./dialog-session-rename"
|
|
52
|
-
import { Keymap } from "../context/keymap"
|
|
53
|
-
import "./spinner-renderable"
|
|
54
|
-
import { SPINNER_FRAMES } from "./spinner-frames"
|
|
55
|
-
import { SessionTabsRailControls, SessionTabHalfRow } from "./session-tabs-rail"
|
|
56
|
-
import "./title-shimmer"
|
|
57
|
-
|
|
58
|
-
export const TAB_SPINNERS = {
|
|
59
|
-
dots: { frames: SPINNER_FRAMES, interval: 80 },
|
|
60
|
-
arcs: { frames: ["◜", "◝", "◞", "◟"], interval: 120 },
|
|
61
|
-
quadrants: { frames: ["◴", "◷", "◶", "◵"], interval: 120 },
|
|
62
|
-
line: { frames: ["|", "/", "-", "\\"], interval: 120 },
|
|
63
|
-
}
|
|
64
|
-
export type TabSpinner = keyof typeof TAB_SPINNERS
|
|
65
|
-
|
|
66
|
-
export const TAB_UNREAD_MARKERS = {
|
|
67
|
-
"small-dot": "•",
|
|
68
|
-
dot: "●",
|
|
69
|
-
square: "▪",
|
|
70
|
-
"large-square": "■",
|
|
71
|
-
}
|
|
72
|
-
export type TabUnreadMarker = keyof typeof TAB_UNREAD_MARKERS
|
|
73
|
-
|
|
74
|
-
// A long title fades out over its last cells instead of cutting hard.
|
|
75
|
-
const FADE_WIDTH = 4
|
|
76
|
-
// The add button renders as " + " at the end of the strip, so the tab layout leaves it room.
|
|
77
|
-
const ADD_TAB_WIDTH = 3
|
|
78
|
-
const MARQUEE_DELAY = 600
|
|
79
|
-
const MARQUEE_INTERVAL = 80
|
|
80
|
-
const CONTEXT_MENU_WIDTH = 20
|
|
81
|
-
const MIDDLE_MOUSE_BUTTON = 1
|
|
82
|
-
const RIGHT_MOUSE_BUTTON = 2
|
|
83
|
-
const MOUSE_CLOSE_HOLD_MS = 5_000
|
|
84
|
-
|
|
85
|
-
type MouseCloseHold = {
|
|
86
|
-
items: string[]
|
|
87
|
-
ids: string[]
|
|
88
|
-
widths: number[]
|
|
89
|
-
closed: string
|
|
90
|
-
target: string
|
|
91
|
-
x: number
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
type TabContextMenuState = {
|
|
95
|
-
x: number
|
|
96
|
-
y: number
|
|
97
|
-
sessionID?: string
|
|
98
|
-
title?: string
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
type ContextController = ReturnType<typeof useSessionTabs>
|
|
102
|
-
export type SessionTabsStatus = Omit<ReturnType<ContextController["status"]>, "unread"> & {
|
|
103
|
-
unread: SessionTabUnread | undefined
|
|
104
|
-
}
|
|
105
|
-
export const EMPTY_SESSION_TAB_STATUS: SessionTabsStatus = {
|
|
106
|
-
unread: undefined,
|
|
107
|
-
promptPulse: 0,
|
|
108
|
-
attention: false,
|
|
109
|
-
busy: false,
|
|
110
|
-
renaming: false,
|
|
111
|
-
}
|
|
112
|
-
export type SessionTabsController = Pick<ContextController, "tabs" | "current" | "select" | "close" | "move"> & {
|
|
113
|
-
newTab?: () => boolean
|
|
114
|
-
add?: () => void
|
|
115
|
-
recentlyClosed?: ContextController["recentlyClosed"]
|
|
116
|
-
reopen?: ContextController["reopen"]
|
|
117
|
-
detail?: (sessionID: string) => string | undefined
|
|
118
|
-
rename?: (sessionID: string) => void
|
|
119
|
-
search?: () => void
|
|
120
|
-
status(sessionID: string): SessionTabsStatus
|
|
121
|
-
}
|
|
122
|
-
const NEW_SESSION_TAB: SessionTab = { sessionID: "new", title: NEW_SESSION_TAB_TITLE }
|
|
123
|
-
const glowTextColor = (base: RGBA, glow: RGBA, index: number, width: number, level = 1) =>
|
|
124
|
-
tint(base, glow, 0.12 * unreadGlowIntensity(index, width) * level)
|
|
125
|
-
|
|
126
|
-
function tabFeedbackColor(status: SessionTabsStatus, theme: ReturnType<typeof useTheme>) {
|
|
127
|
-
if (status.attention) return theme.hue.accent[200]
|
|
128
|
-
if (status.unread === "error") return theme.text.feedback.error.base
|
|
129
|
-
return undefined
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function TabIndicator(props: {
|
|
133
|
-
status: SessionTabsStatus
|
|
134
|
-
label: string
|
|
135
|
-
idleLabel?: string
|
|
136
|
-
width: number
|
|
137
|
-
centered?: boolean
|
|
138
|
-
color: RGBA
|
|
139
|
-
unreadColor: RGBA
|
|
140
|
-
backgroundColor: RGBA
|
|
141
|
-
flashColor: RGBA
|
|
142
|
-
animations: boolean
|
|
143
|
-
numbers: boolean
|
|
144
|
-
selected?: boolean
|
|
145
|
-
spinner?: TabSpinner
|
|
146
|
-
unreadMarker?: TabUnreadMarker
|
|
147
|
-
attributes?: number
|
|
148
|
-
}) {
|
|
149
|
-
const runs = () => props.status.busy && !props.status.attention
|
|
150
|
-
const pending = createMemo(() => props.status.busy || Boolean(props.status.attention))
|
|
151
|
-
const unread = createMemo(() => Boolean(props.status.unread) && !pending())
|
|
152
|
-
const unreadColor = createMemo<RGBA>((previous) => (unread() ? props.unreadColor : previous), props.unreadColor)
|
|
153
|
-
const fade = createAnimatable(
|
|
154
|
-
{ opacity: unread() ? 1 : 0 },
|
|
155
|
-
{ enabled: () => props.animations, transition: tween({ duration: 0.18 }) },
|
|
156
|
-
)
|
|
157
|
-
createComputed(() => {
|
|
158
|
-
if (unread()) return fade.jump({ opacity: 1 })
|
|
159
|
-
if (pending()) return fade.jump({ opacity: 0 })
|
|
160
|
-
fade.animate({ opacity: 0 })
|
|
161
|
-
})
|
|
162
|
-
const fading = () => !props.status.unread && fade.value().opacity > 0
|
|
163
|
-
const color = () => {
|
|
164
|
-
if (props.numbers || props.selected) return props.color
|
|
165
|
-
if (unread()) return props.unreadColor
|
|
166
|
-
if (!fading()) return props.color
|
|
167
|
-
const opacity = fade.value().opacity
|
|
168
|
-
// Brighten during the first fifth, then dissolve into the tab background.
|
|
169
|
-
const flash = Math.max(0, 1 - Math.abs(opacity - 0.8) / 0.2)
|
|
170
|
-
return tint(props.backgroundColor, tint(unreadColor(), props.flashColor, flash * 0.3), Math.min(1, opacity / 0.8))
|
|
171
|
-
}
|
|
172
|
-
const spinner = () => TAB_SPINNERS[props.spinner ?? "dots"]
|
|
173
|
-
const label = () => {
|
|
174
|
-
if (props.numbers) return props.label
|
|
175
|
-
if (props.status.attention === "permission") return "!"
|
|
176
|
-
if (props.status.attention === "question") return "?"
|
|
177
|
-
if (runs()) return spinner().frames[0]
|
|
178
|
-
if (props.label === "+") return "+"
|
|
179
|
-
if (props.status.unread || fading()) return TAB_UNREAD_MARKERS[props.unreadMarker ?? "small-dot"]
|
|
180
|
-
return props.idleLabel ?? ""
|
|
181
|
-
}
|
|
182
|
-
return (
|
|
183
|
-
<box
|
|
184
|
-
width={props.width + (props.centered ? 0 : 1)}
|
|
185
|
-
height={props.centered ? 1 : undefined}
|
|
186
|
-
flexShrink={0}
|
|
187
|
-
flexDirection="row"
|
|
188
|
-
justifyContent={props.centered ? "center" : "flex-end"}
|
|
189
|
-
paddingRight={props.centered ? 0 : 1}
|
|
190
|
-
>
|
|
191
|
-
<Show
|
|
192
|
-
when={runs() && props.animations && !props.numbers}
|
|
193
|
-
fallback={
|
|
194
|
-
<text fg={color()} selectable={false} attributes={props.attributes}>
|
|
195
|
-
{label()}
|
|
196
|
-
</text>
|
|
197
|
-
}
|
|
198
|
-
>
|
|
199
|
-
<spinner frames={spinner().frames} interval={spinner().interval} color={props.color} />
|
|
200
|
-
</Show>
|
|
201
|
-
</box>
|
|
202
|
-
)
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
function createGlowLevel(dimmed: () => boolean, animations: () => boolean) {
|
|
206
|
-
const motion = createAnimatable(
|
|
207
|
-
{ level: dimmed() ? 0.7 : 1 },
|
|
208
|
-
{ enabled: animations, transition: tween({ duration: 0.2 }) },
|
|
209
|
-
)
|
|
210
|
-
createEffect(() => motion.animate({ level: dimmed() ? 0.7 : 1 }))
|
|
211
|
-
return () => motion.value().level
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
function createNumberIgnition(runs: () => boolean, prompt: () => number, animations: () => boolean) {
|
|
215
|
-
const ignition = createAnimatable({ level: 0 }, { enabled: animations, transition: tween({ duration: 0.7 }) })
|
|
216
|
-
let wasRunning = runs()
|
|
217
|
-
let promptPulse = prompt()
|
|
218
|
-
createEffect(() => {
|
|
219
|
-
const running = runs()
|
|
220
|
-
const nextPromptPulse = prompt()
|
|
221
|
-
if (running !== wasRunning || nextPromptPulse !== promptPulse) {
|
|
222
|
-
ignition.jump({ level: 0.85 })
|
|
223
|
-
ignition.animate({ level: 0 })
|
|
224
|
-
}
|
|
225
|
-
wasRunning = running
|
|
226
|
-
promptPulse = nextPromptPulse
|
|
227
|
-
})
|
|
228
|
-
return ignition
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
function fadeTitleColor(color: RGBA, background: RGBA, index: number, length: number, leading: number) {
|
|
232
|
-
const fade = (position: number) => (position <= 0 ? 0 : 0.2 + 0.72 * ((position - 1) / Math.max(1, FADE_WIDTH - 1)))
|
|
233
|
-
const start = index < FADE_WIDTH ? FADE_WIDTH - index : 0
|
|
234
|
-
const end = index - (length - FADE_WIDTH) + 1
|
|
235
|
-
const opacity = Math.max(fade(start) * leading, fade(end))
|
|
236
|
-
return opacity === 0 ? color : tint(color, background, opacity)
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
function heldSessionTabLayout(hold: MouseCloseHold, tabs: readonly SessionTab[]) {
|
|
240
|
-
const ids = tabs.map((tab) => tab.sessionID)
|
|
241
|
-
const expected = hold.items.filter((id) => id !== hold.closed)
|
|
242
|
-
const unchanged = ids.length === hold.items.length && ids.every((id, index) => id === hold.items[index])
|
|
243
|
-
const removed = ids.length === expected.length && ids.every((id, index) => id === expected[index])
|
|
244
|
-
if (!unchanged && !removed) return undefined
|
|
245
|
-
|
|
246
|
-
const visibleIDs = hold.ids.filter((id) => ids.includes(id))
|
|
247
|
-
if (removed && !visibleIDs.includes(hold.target)) {
|
|
248
|
-
visibleIDs.push(hold.target)
|
|
249
|
-
visibleIDs.sort((a, b) => ids.indexOf(a) - ids.indexOf(b))
|
|
250
|
-
}
|
|
251
|
-
const positions = visibleIDs.map((id) => ids.indexOf(id))
|
|
252
|
-
const start = positions[0]
|
|
253
|
-
if (start === undefined || positions.some((position, index) => position !== start + index)) return undefined
|
|
254
|
-
const visible = visibleIDs.flatMap((id) => tabs.find((tab) => tab.sessionID === id) ?? [])
|
|
255
|
-
if (visible.length !== visibleIDs.length) return undefined
|
|
256
|
-
|
|
257
|
-
const widths = visibleIDs.map((id) => hold.widths[hold.ids.indexOf(id)] ?? 1)
|
|
258
|
-
if (removed) {
|
|
259
|
-
const index = visibleIDs.indexOf(hold.target)
|
|
260
|
-
if (index === -1) return undefined
|
|
261
|
-
const leading = start > 0 ? sessionTabOverflowWidth(start) : 0
|
|
262
|
-
const preceding = widths.slice(0, index).reduce((sum, width) => sum + width, 0)
|
|
263
|
-
// The close glyph sits one cell in from the right edge: x = tab start + width - 2.
|
|
264
|
-
const width = hold.x - leading - preceding + 2
|
|
265
|
-
if (width < 1) return undefined
|
|
266
|
-
widths[index] = width
|
|
267
|
-
}
|
|
268
|
-
return {
|
|
269
|
-
tabs: visible,
|
|
270
|
-
widths,
|
|
271
|
-
before: start,
|
|
272
|
-
after: tabs.length - start - visible.length,
|
|
273
|
-
start,
|
|
274
|
-
total: widths.reduce((sum, width) => sum + width, 0),
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
export function createMarquee(animations: () => boolean) {
|
|
279
|
-
const [offset, setOffset] = createSignal(0)
|
|
280
|
-
const [active, setActive] = createSignal<string>()
|
|
281
|
-
const [scrolling, setScrolling] = createSignal(false)
|
|
282
|
-
const leading = createAnimatable({ opacity: 0 }, { enabled: animations, transition: tween({ duration: 0.25 }) })
|
|
283
|
-
const clock = useRenderer().clock
|
|
284
|
-
let delay: TimerHandle | undefined
|
|
285
|
-
let cycleWidth = 0
|
|
286
|
-
|
|
287
|
-
const clear = () => {
|
|
288
|
-
if (delay !== undefined) clock.clearTimeout(delay)
|
|
289
|
-
delay = undefined
|
|
290
|
-
setScrolling(false)
|
|
291
|
-
}
|
|
292
|
-
// Not bound to a node's draw; reset() and unmount end the scroll.
|
|
293
|
-
onAnimationTick(
|
|
294
|
-
() => (scrolling() ? 1000 / MARQUEE_INTERVAL : undefined),
|
|
295
|
-
(_deltaTime, ticks) => {
|
|
296
|
-
if (offset() + ticks < cycleWidth) return setOffset(offset() + ticks)
|
|
297
|
-
clear()
|
|
298
|
-
leading.animate({ opacity: 0 })
|
|
299
|
-
setOffset(0)
|
|
300
|
-
},
|
|
301
|
-
)
|
|
302
|
-
const enter = (sessionID: string, title: string, width: number) => {
|
|
303
|
-
if (!marqueeOverflows(title, width)) {
|
|
304
|
-
reset()
|
|
305
|
-
return
|
|
306
|
-
}
|
|
307
|
-
if (active() === sessionID) return
|
|
308
|
-
clear()
|
|
309
|
-
cycleWidth = marqueeCycleWidth(title)
|
|
310
|
-
setActive(sessionID)
|
|
311
|
-
setOffset(0)
|
|
312
|
-
leading.jump({ opacity: 0 })
|
|
313
|
-
delay = clock.setTimeout(() => {
|
|
314
|
-
setOffset(1)
|
|
315
|
-
leading.animate({ opacity: 1 })
|
|
316
|
-
setScrolling(true)
|
|
317
|
-
}, MARQUEE_DELAY)
|
|
318
|
-
}
|
|
319
|
-
const leave = (sessionID: string) => {
|
|
320
|
-
if (active() !== sessionID) return
|
|
321
|
-
reset()
|
|
322
|
-
}
|
|
323
|
-
const reset = () => {
|
|
324
|
-
clear()
|
|
325
|
-
setActive(undefined)
|
|
326
|
-
setOffset(0)
|
|
327
|
-
leading.jump({ opacity: 0 })
|
|
328
|
-
}
|
|
329
|
-
onCleanup(clear)
|
|
330
|
-
|
|
331
|
-
return { offset, active, enter, leave, reset, leading: () => leading.value().opacity }
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
export function createTabMarquee(animations: () => boolean) {
|
|
335
|
-
const [hovered, setHovered] = createSignal<string>()
|
|
336
|
-
const marquee = createMarquee(animations)
|
|
337
|
-
let hoverClear: ReturnType<typeof setTimeout> | undefined
|
|
338
|
-
|
|
339
|
-
const enter = (sessionID: string, title: string, width: number) => {
|
|
340
|
-
if (hoverClear) clearTimeout(hoverClear)
|
|
341
|
-
setHovered(sessionID)
|
|
342
|
-
marquee.enter(sessionID, title, width)
|
|
343
|
-
}
|
|
344
|
-
const leave = (sessionID: string) => {
|
|
345
|
-
if (hoverClear) clearTimeout(hoverClear)
|
|
346
|
-
hoverClear = setTimeout(() => {
|
|
347
|
-
if (hovered() !== sessionID) return
|
|
348
|
-
setHovered(undefined)
|
|
349
|
-
marquee.leave(sessionID)
|
|
350
|
-
})
|
|
351
|
-
}
|
|
352
|
-
const leaveHovered = () => {
|
|
353
|
-
const sessionID = hovered()
|
|
354
|
-
if (sessionID) leave(sessionID)
|
|
355
|
-
}
|
|
356
|
-
const reset = () => {
|
|
357
|
-
if (hoverClear) clearTimeout(hoverClear)
|
|
358
|
-
hoverClear = undefined
|
|
359
|
-
setHovered(undefined)
|
|
360
|
-
marquee.reset()
|
|
361
|
-
}
|
|
362
|
-
onCleanup(() => {
|
|
363
|
-
if (hoverClear) clearTimeout(hoverClear)
|
|
364
|
-
})
|
|
365
|
-
|
|
366
|
-
return { ...marquee, hovered, enter, leave, leaveHovered, reset }
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
function TabContextMenu(props: { state: TabContextMenuState; tabs: SessionTabsController; onClose: () => void }) {
|
|
370
|
-
const dimensions = useTerminalDimensions()
|
|
371
|
-
const theme = useTheme()
|
|
372
|
-
const background = () => theme.background.raised.base
|
|
373
|
-
const actionHovered = () => theme.background.raised.high
|
|
374
|
-
const dialog = useDialog()
|
|
375
|
-
const clipboard = useClipboard()
|
|
376
|
-
const toast = useToast()
|
|
377
|
-
onCleanup(Keymap.use().mode.push("menu"))
|
|
378
|
-
Keymap.createLayer(() => ({
|
|
379
|
-
mode: "menu",
|
|
380
|
-
commands: [{ bind: "escape,ctrl+c", title: "Close tab menu", group: "Tabs", run: props.onClose }],
|
|
381
|
-
}))
|
|
382
|
-
const actions = createMemo<Array<{ title: string; run?: () => void }>>(() => {
|
|
383
|
-
const sessionID = props.state.sessionID
|
|
384
|
-
const title = props.state.title
|
|
385
|
-
const closed = (props.tabs.recentlyClosed?.() ?? []).slice(0, 10)
|
|
386
|
-
return [
|
|
387
|
-
...(sessionID && props.tabs.add ? [{ title: NEW_SESSION_TAB_TITLE, run: () => props.tabs.add?.() }] : []),
|
|
388
|
-
...(sessionID
|
|
389
|
-
? [
|
|
390
|
-
{
|
|
391
|
-
title: "Rename",
|
|
392
|
-
run: () =>
|
|
393
|
-
props.tabs.rename ? props.tabs.rename(sessionID) : DialogSessionRename.show(dialog, sessionID, title),
|
|
394
|
-
},
|
|
395
|
-
{
|
|
396
|
-
title: "Copy session ID",
|
|
397
|
-
run: () =>
|
|
398
|
-
void clipboard
|
|
399
|
-
.write(sessionID)
|
|
400
|
-
.then(() => toast.show({ message: "Session ID copied to clipboard", variant: "info" }))
|
|
401
|
-
.catch(toast.error),
|
|
402
|
-
},
|
|
403
|
-
{ title: "Close", run: () => props.tabs.close(sessionID) },
|
|
404
|
-
]
|
|
405
|
-
: []),
|
|
406
|
-
...(!sessionID && props.tabs.reopen
|
|
407
|
-
? [
|
|
408
|
-
{ title: "Recently closed tabs" },
|
|
409
|
-
...closed.map((tab) => ({
|
|
410
|
-
title: tab.title || "Untitled session",
|
|
411
|
-
run: () => props.tabs.reopen?.(tab.sessionID),
|
|
412
|
-
})),
|
|
413
|
-
...(closed.length === 0 ? [{ title: "No recently closed tabs" }] : []),
|
|
414
|
-
]
|
|
415
|
-
: []),
|
|
416
|
-
]
|
|
417
|
-
})
|
|
418
|
-
const [selected, setSelected] = createSignal<number>()
|
|
419
|
-
const width = () =>
|
|
420
|
-
Math.min(
|
|
421
|
-
dimensions().width,
|
|
422
|
-
Math.max(CONTEXT_MENU_WIDTH, ...actions().map((action) => Math.min(50, stringWidth(action.title) + 2))),
|
|
423
|
-
)
|
|
424
|
-
const height = () => Math.min(actions().length, dimensions().height)
|
|
425
|
-
const top = () => Math.max(0, Math.min(props.state.y + 1, dimensions().height - height()))
|
|
426
|
-
const left = () => Math.max(0, Math.min(props.state.x, dimensions().width - width()))
|
|
427
|
-
const run = (index: number) => {
|
|
428
|
-
const action = actions()[index]
|
|
429
|
-
if (!action?.run) return
|
|
430
|
-
props.onClose()
|
|
431
|
-
action.run()
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
return (
|
|
435
|
-
<Portal
|
|
436
|
-
ref={(container) => {
|
|
437
|
-
if (!(container instanceof BoxRenderable)) return
|
|
438
|
-
// Portal's wrapper otherwise follows the full-height app in root layout.
|
|
439
|
-
container.position = "absolute"
|
|
440
|
-
container.left = 0
|
|
441
|
-
container.top = 0
|
|
442
|
-
container.zIndex = 2500
|
|
443
|
-
}}
|
|
444
|
-
>
|
|
445
|
-
<box
|
|
446
|
-
position="absolute"
|
|
447
|
-
left={0}
|
|
448
|
-
top={0}
|
|
449
|
-
width={dimensions().width}
|
|
450
|
-
height={dimensions().height}
|
|
451
|
-
zIndex={2500}
|
|
452
|
-
onMouseDown={(event) => {
|
|
453
|
-
props.onClose()
|
|
454
|
-
event.preventDefault()
|
|
455
|
-
event.stopPropagation()
|
|
456
|
-
}}
|
|
457
|
-
>
|
|
458
|
-
<scrollbox
|
|
459
|
-
position="absolute"
|
|
460
|
-
left={left()}
|
|
461
|
-
top={top()}
|
|
462
|
-
height={height()}
|
|
463
|
-
width={width()}
|
|
464
|
-
scrollX={false}
|
|
465
|
-
scrollbarOptions={{ visible: false }}
|
|
466
|
-
backgroundColor={background()}
|
|
467
|
-
onMouseDown={(event) => {
|
|
468
|
-
if (event.button === RIGHT_MOUSE_BUTTON) props.onClose()
|
|
469
|
-
event.preventDefault()
|
|
470
|
-
event.stopPropagation()
|
|
471
|
-
}}
|
|
472
|
-
>
|
|
473
|
-
<For each={actions()}>
|
|
474
|
-
{(action, index) => (
|
|
475
|
-
<box
|
|
476
|
-
width="100%"
|
|
477
|
-
paddingLeft={1}
|
|
478
|
-
paddingRight={1}
|
|
479
|
-
height={1}
|
|
480
|
-
flexShrink={0}
|
|
481
|
-
backgroundColor={action.run && selected() === index() ? actionHovered() : undefined}
|
|
482
|
-
onMouseOver={() => setSelected(action.run ? index() : undefined)}
|
|
483
|
-
onMouseOut={() => setSelected(undefined)}
|
|
484
|
-
onMouseUp={(event) => {
|
|
485
|
-
event.preventDefault()
|
|
486
|
-
event.stopPropagation()
|
|
487
|
-
if (event.button === RIGHT_MOUSE_BUTTON) return
|
|
488
|
-
run(index())
|
|
489
|
-
}}
|
|
490
|
-
>
|
|
491
|
-
<text fg={action.run ? theme.text.base : theme.text.muted} selectable={false} truncate>
|
|
492
|
-
{action.title}
|
|
493
|
-
</text>
|
|
494
|
-
</box>
|
|
495
|
-
)}
|
|
496
|
-
</For>
|
|
497
|
-
</scrollbox>
|
|
498
|
-
</box>
|
|
499
|
-
</Portal>
|
|
500
|
-
)
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
export function SessionTabs(
|
|
504
|
-
props: {
|
|
505
|
-
controller?: SessionTabsController
|
|
506
|
-
animations?: boolean
|
|
507
|
-
spinner?: TabSpinner
|
|
508
|
-
unreadMarker?: TabUnreadMarker
|
|
509
|
-
indicators?: "status" | "numbers"
|
|
510
|
-
orientation?: "horizontal" | "vertical"
|
|
511
|
-
width?: number
|
|
512
|
-
} = {},
|
|
513
|
-
) {
|
|
514
|
-
const config = useConfig().data
|
|
515
|
-
|
|
516
|
-
return (
|
|
517
|
-
<Switch>
|
|
518
|
-
<Match when={props.orientation === "vertical"}>
|
|
519
|
-
<VerticalSessionTabs
|
|
520
|
-
controller={props.controller}
|
|
521
|
-
animations={props.animations}
|
|
522
|
-
spinner={props.spinner}
|
|
523
|
-
unreadMarker={props.unreadMarker}
|
|
524
|
-
numbers={(props.indicators ?? config.tabs.indicators) === "numbers"}
|
|
525
|
-
width={props.width}
|
|
526
|
-
/>
|
|
527
|
-
</Match>
|
|
528
|
-
<Match when={true}>
|
|
529
|
-
<HorizontalSessionTabs
|
|
530
|
-
controller={props.controller}
|
|
531
|
-
animations={props.animations}
|
|
532
|
-
spinner={props.spinner}
|
|
533
|
-
unreadMarker={props.unreadMarker}
|
|
534
|
-
numbers={(props.indicators ?? config.tabs.indicators) === "numbers"}
|
|
535
|
-
/>
|
|
536
|
-
</Match>
|
|
537
|
-
</Switch>
|
|
538
|
-
)
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
function VerticalSessionTabs(props: {
|
|
542
|
-
controller?: SessionTabsController
|
|
543
|
-
animations?: boolean
|
|
544
|
-
numbers: boolean
|
|
545
|
-
spinner?: TabSpinner
|
|
546
|
-
unreadMarker?: TabUnreadMarker
|
|
547
|
-
width?: number
|
|
548
|
-
}) {
|
|
549
|
-
const tabs: SessionTabsController = props.controller ?? useSessionTabs()
|
|
550
|
-
const data = props.controller ? undefined : useData()
|
|
551
|
-
const dimensions = useTerminalDimensions()
|
|
552
|
-
const renderer = useRenderer()
|
|
553
|
-
const theme = useTheme()
|
|
554
|
-
const background = () => theme.background.raised.base
|
|
555
|
-
const actionSelected = () => theme.background.action.primary.selected
|
|
556
|
-
const actionHovered = () => theme.background.raised.high
|
|
557
|
-
const base = useTheme()
|
|
558
|
-
const config = useConfig().data
|
|
559
|
-
const animations = () => props.animations ?? config.animations ?? true
|
|
560
|
-
const width = () => props.width ?? SESSION_SIDEBAR_WIDTH
|
|
561
|
-
const compact = createMemo(() => width() < SESSION_TABS_COMPACT_BREAKPOINT)
|
|
562
|
-
const tooltipWidth = () => Math.min(54, dimensions().width - width())
|
|
563
|
-
const stride = () => (compact() ? 2 : 3)
|
|
564
|
-
const unreadColor = () => theme.hue.accent[200]
|
|
565
|
-
const activeNumber = () => theme.hue.interactive[200]
|
|
566
|
-
const idleNumber = () => tint(theme.text.formfield.base, background(), 0.55)
|
|
567
|
-
const separatorUpperPulseColor = createMemo(() => tint(background(), theme.text.base, 0.04))
|
|
568
|
-
const separatorLowerPulseColor = createMemo(() => tint(background(), theme.text.base, 0.05))
|
|
569
|
-
const [addHovered, setAddHovered] = createSignal(false)
|
|
570
|
-
const marquee = createTabMarquee(animations)
|
|
571
|
-
const hovered = marquee.hovered
|
|
572
|
-
createEffect(() => {
|
|
573
|
-
compact()
|
|
574
|
-
untrack(marquee.reset)
|
|
575
|
-
})
|
|
576
|
-
const [hoverY, setHoverY] = createSignal(0)
|
|
577
|
-
const [scrollTop, setScrollTop] = createSignal(0)
|
|
578
|
-
const detail = (sessionID: string) => {
|
|
579
|
-
const fixture = tabs.detail?.(sessionID)
|
|
580
|
-
if (fixture !== undefined) return fixture
|
|
581
|
-
const session = data?.session.get(sessionID)
|
|
582
|
-
const project = session ? data?.project.get(session.projectID) : undefined
|
|
583
|
-
const vcs = session ? data?.location.vcs.info(session.location) : undefined
|
|
584
|
-
const location = session ? data?.location.info(session.location) : undefined
|
|
585
|
-
return sessionTabDetail(
|
|
586
|
-
projectName(project, session?.location.directory) ?? "",
|
|
587
|
-
vcs?.branch.current,
|
|
588
|
-
vcs?.branch.default,
|
|
589
|
-
!!location && location.project.directory !== location.project.canonical,
|
|
590
|
-
)
|
|
591
|
-
}
|
|
592
|
-
// OpenTUI captures the first drag target, which may differ from the tab pressed on a fast move.
|
|
593
|
-
const [dragging, setDragging] = createSignal<string>()
|
|
594
|
-
const [preview, setPreview] = createSignal<{ sessionID: string; index: number }>()
|
|
595
|
-
const [contextMenu, setContextMenu] = createSignal<TabContextMenuState>()
|
|
596
|
-
const newTab = () => tabs.newTab?.() ?? false
|
|
597
|
-
const activeID = createMemo(() => (newTab() ? undefined : tabs.current()))
|
|
598
|
-
const ordered = createMemo(() => {
|
|
599
|
-
const pending = preview()
|
|
600
|
-
if (!pending) return tabs.tabs()
|
|
601
|
-
return moveSessionTab(tabs.tabs(), pending.sessionID, pending.index)
|
|
602
|
-
})
|
|
603
|
-
const items = ordered
|
|
604
|
-
const highlightColor = createMemo(() => tint(background(), actionHovered(), actionHovered().a))
|
|
605
|
-
const highlighted = (sessionID: string | undefined) =>
|
|
606
|
-
sessionID !== undefined && (activeID() === sessionID || hovered() === sessionID || dragging() === sessionID)
|
|
607
|
-
const addHighlighted = () => newTab() || addHovered()
|
|
608
|
-
const belowHighlighted = createMemo(() => {
|
|
609
|
-
const tab = items()[Math.floor(scrollTop() / stride())]
|
|
610
|
-
return tab ? highlighted(tab.sessionID) : addHighlighted()
|
|
611
|
-
})
|
|
612
|
-
createEffect(() => {
|
|
613
|
-
const active = marquee.active()
|
|
614
|
-
if (active && !items().some((tab) => tab.sessionID === active)) marquee.reset()
|
|
615
|
-
})
|
|
616
|
-
const statuses = createMemo(
|
|
617
|
-
() =>
|
|
618
|
-
new Map(
|
|
619
|
-
items().map((tab) => {
|
|
620
|
-
const status = tabs.status(tab.sessionID)
|
|
621
|
-
return [
|
|
622
|
-
tab.sessionID,
|
|
623
|
-
{
|
|
624
|
-
...status,
|
|
625
|
-
complete: sessionTabComplete(status.unread, status.busy),
|
|
626
|
-
runs: status.busy && !status.attention,
|
|
627
|
-
glows: Boolean(
|
|
628
|
-
status.attention || (tab.sessionID !== activeID() && !status.busy && status.unread !== undefined),
|
|
629
|
-
),
|
|
630
|
-
},
|
|
631
|
-
] as const
|
|
632
|
-
}),
|
|
633
|
-
),
|
|
634
|
-
)
|
|
635
|
-
const itemStatus = (tab: SessionTab) => statuses().get(tab.sessionID)!
|
|
636
|
-
let rail: { screenX: number; screenY: number } | undefined
|
|
637
|
-
let scroll: ScrollBoxRenderable | undefined
|
|
638
|
-
const updateScroll = () => setScrollTop(scroll?.scrollTop ?? 0)
|
|
639
|
-
onCleanup(() => scroll?.verticalScrollBar.off("change", updateScroll))
|
|
640
|
-
let didDrag = false
|
|
641
|
-
let addPressed = false
|
|
642
|
-
// A captured drag ends with a synthetic up on its drop target; do not turn that into a click.
|
|
643
|
-
let suppressClick = false
|
|
644
|
-
|
|
645
|
-
createEffect(() => {
|
|
646
|
-
const pending = preview()
|
|
647
|
-
if (!pending || dragging()) return
|
|
648
|
-
const index = tabs.tabs().findIndex((tab) => tab.sessionID === pending.sessionID)
|
|
649
|
-
if (index === -1 || index === Math.min(pending.index, tabs.tabs().length - 1)) setPreview(undefined)
|
|
650
|
-
})
|
|
651
|
-
|
|
652
|
-
createEffect(() => {
|
|
653
|
-
if (!scroll) return
|
|
654
|
-
dimensions()
|
|
655
|
-
const index = newTab() ? items().length : items().findIndex((tab) => tab.sessionID === activeID())
|
|
656
|
-
if (index === -1) return
|
|
657
|
-
const top = index * stride()
|
|
658
|
-
const height = compact() ? 3 : newTab() ? 1 : 2
|
|
659
|
-
// Scroll after layout: newly opened tabs do not contribute to the scroll range yet.
|
|
660
|
-
const reveal = () => {
|
|
661
|
-
if (!scroll) return
|
|
662
|
-
if (top < scroll.scrollTop) return scroll.scrollTo(top)
|
|
663
|
-
if (top + height > scroll.scrollTop + scroll.viewport.height) {
|
|
664
|
-
scroll.scrollTo(top + height - scroll.viewport.height)
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
renderer.once(CliRenderEvents.FRAME, reveal)
|
|
668
|
-
renderer.requestRender()
|
|
669
|
-
onCleanup(() => renderer.off(CliRenderEvents.FRAME, reveal))
|
|
670
|
-
})
|
|
671
|
-
|
|
672
|
-
const release = () => {
|
|
673
|
-
const source = dragging()
|
|
674
|
-
if (!source) return
|
|
675
|
-
if (didDrag) suppressClick = true
|
|
676
|
-
setDragging(undefined)
|
|
677
|
-
const pending = preview()
|
|
678
|
-
if (pending?.sessionID === source) tabs.move(pending.sessionID, pending.index)
|
|
679
|
-
tabs.select(source)
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
const drag = (event: MouseEvent) => {
|
|
683
|
-
if (!rail) return
|
|
684
|
-
const source = dragging()
|
|
685
|
-
if (!source) return
|
|
686
|
-
didDrag = true
|
|
687
|
-
const target = Math.max(
|
|
688
|
-
0,
|
|
689
|
-
Math.min(
|
|
690
|
-
tabs.tabs().length - 1,
|
|
691
|
-
Math.floor(
|
|
692
|
-
(event.y - (scroll?.viewport.screenY ?? rail.screenY + 1) - (compact() ? 1 : 0) + (scroll?.scrollTop ?? 0)) /
|
|
693
|
-
stride(),
|
|
694
|
-
),
|
|
695
|
-
),
|
|
696
|
-
)
|
|
697
|
-
const sourceIndex = items().findIndex((item) => item.sessionID === source)
|
|
698
|
-
if (target !== sourceIndex && preview()?.index !== target) setPreview({ sessionID: source, index: target })
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
return (
|
|
702
|
-
<box
|
|
703
|
-
ref={(element) => (rail = element)}
|
|
704
|
-
width={width()}
|
|
705
|
-
height="100%"
|
|
706
|
-
flexShrink={0}
|
|
707
|
-
flexDirection="column"
|
|
708
|
-
position="relative"
|
|
709
|
-
paddingTop={1}
|
|
710
|
-
backgroundColor={background()}
|
|
711
|
-
onMouseOut={marquee.leaveHovered}
|
|
712
|
-
onMouseUp={(event) => {
|
|
713
|
-
if (event.button === RIGHT_MOUSE_BUTTON) return
|
|
714
|
-
release()
|
|
715
|
-
if (!didDrag) return
|
|
716
|
-
didDrag = false
|
|
717
|
-
queueMicrotask(() => (suppressClick = false))
|
|
718
|
-
}}
|
|
719
|
-
onMouseDrag={drag}
|
|
720
|
-
onMouseDragEnd={release}
|
|
721
|
-
>
|
|
722
|
-
<Show when={compact()}>
|
|
723
|
-
<SessionTabsRailControls width={width()} tabs={tabs} belowHighlighted={belowHighlighted()} />
|
|
724
|
-
</Show>
|
|
725
|
-
<scrollbox
|
|
726
|
-
ref={(element) => {
|
|
727
|
-
scroll = element
|
|
728
|
-
scroll.verticalScrollBar.on("change", updateScroll)
|
|
729
|
-
updateScroll()
|
|
730
|
-
}}
|
|
731
|
-
flexGrow={1}
|
|
732
|
-
minHeight={0}
|
|
733
|
-
backgroundColor={background()}
|
|
734
|
-
scrollbarOptions={{ visible: false }}
|
|
735
|
-
>
|
|
736
|
-
<box flexShrink={0} flexDirection="column" gap={1} paddingY={compact() ? 1 : 0}>
|
|
737
|
-
<For each={items()}>
|
|
738
|
-
{(tab, index) => {
|
|
739
|
-
const selected = () => activeID() === tab.sessionID
|
|
740
|
-
const status = createMemo(() => itemStatus(tab))
|
|
741
|
-
const [sweepLevel, setSweepLevel] = createSignal(0)
|
|
742
|
-
const [closeHovered, setCloseHovered] = createSignal(false)
|
|
743
|
-
const session = createMemo(() => data?.session.get(tab.sessionID))
|
|
744
|
-
const numberWidth = () => Math.max(2, String(items().length).length)
|
|
745
|
-
const prefixWidth = () => numberWidth() + 1
|
|
746
|
-
const restingTitleWidth = () => Math.max(1, width() - prefixWidth() - 1)
|
|
747
|
-
const hoveredTitleWidth = () => Math.max(1, restingTitleWidth() - 1)
|
|
748
|
-
const titleWidth = () => (hovered() === tab.sessionID ? hoveredTitleWidth() : restingTitleWidth())
|
|
749
|
-
const title = () => (props.controller ? undefined : session()?.title) ?? tab.title ?? "Untitled session"
|
|
750
|
-
const scrolling = () => marquee.active() === tab.sessionID
|
|
751
|
-
const visibleTitleParts = createMemo(() =>
|
|
752
|
-
scrolling()
|
|
753
|
-
? marqueeTextParts(title(), titleWidth(), marquee.offset())
|
|
754
|
-
: Locale.graphemes(Locale.takeWidth(title(), titleWidth())).map((value) => ({
|
|
755
|
-
value,
|
|
756
|
-
separator: false,
|
|
757
|
-
})),
|
|
758
|
-
)
|
|
759
|
-
const visibleTitle = createMemo(() =>
|
|
760
|
-
visibleTitleParts()
|
|
761
|
-
.map((part) => part.value)
|
|
762
|
-
.join(""),
|
|
763
|
-
)
|
|
764
|
-
const titleFades = createMemo(() => marqueeOverflows(title(), titleWidth()) && titleWidth() > FADE_WIDTH)
|
|
765
|
-
const tabDetail = createMemo(() => detail(tab.sessionID))
|
|
766
|
-
const visibleDetail = createMemo(() => Locale.takeWidth(tabDetail(), titleWidth()))
|
|
767
|
-
const visibleDetailParts = createMemo(() => Locale.graphemes(visibleDetail()))
|
|
768
|
-
const detailFades = createMemo(
|
|
769
|
-
() => marqueeOverflows(tabDetail(), titleWidth()) && titleWidth() > FADE_WIDTH,
|
|
770
|
-
)
|
|
771
|
-
const tabBackground = createMemo(() => {
|
|
772
|
-
if (selected() && !compact()) return actionSelected()
|
|
773
|
-
if ((compact() && selected()) || hovered() === tab.sessionID || dragging() === tab.sessionID)
|
|
774
|
-
return actionHovered()
|
|
775
|
-
return background()
|
|
776
|
-
})
|
|
777
|
-
const pulseBackground = createMemo(() => tint(background(), tabBackground(), tabBackground().a))
|
|
778
|
-
const runs = () => status().runs
|
|
779
|
-
const numberIgnition = createNumberIgnition(runs, () => status().promptPulse, animations)
|
|
780
|
-
const numberColor = () => {
|
|
781
|
-
const base =
|
|
782
|
-
hovered() === tab.sessionID && !selected()
|
|
783
|
-
? foreground()
|
|
784
|
-
: tint(idleNumber(), tint(theme.text.base, pulseBackground(), 0.25), Number(selected()))
|
|
785
|
-
const color = tabFeedbackColor(status(), theme) ?? tint(base, glowHue(), numberGlow.value().level)
|
|
786
|
-
const runningColor = runs() ? activeNumber() : color
|
|
787
|
-
return sweepLevel() === 0
|
|
788
|
-
? tint(runningColor, theme.text.base, numberIgnition.value().level)
|
|
789
|
-
: tint(runningColor, theme.text.base, Math.max(numberIgnition.value().level, 0.35 * sweepLevel()))
|
|
790
|
-
}
|
|
791
|
-
const foreground = () => {
|
|
792
|
-
if (hovered() === tab.sessionID) return theme.text.base
|
|
793
|
-
return selected() ? theme.text.base : theme.text.muted
|
|
794
|
-
}
|
|
795
|
-
const complete = () => status().complete
|
|
796
|
-
// Latched so a resolving glow fades out in the hue it lit with instead of snapping to the unread color.
|
|
797
|
-
let lastGlowHue: RGBA | undefined
|
|
798
|
-
const glowHue = () => {
|
|
799
|
-
const feedback = tabFeedbackColor(status(), theme)
|
|
800
|
-
if (feedback) return (lastGlowHue = feedback)
|
|
801
|
-
if (status().unread !== undefined) return (lastGlowHue = unreadColor())
|
|
802
|
-
return lastGlowHue ?? unreadColor()
|
|
803
|
-
}
|
|
804
|
-
const pulseColor = createMemo(() => tint(pulseBackground(), theme.text.base, 0.25))
|
|
805
|
-
const flashColor = createMemo(() => tint(pulseBackground(), theme.text.base, 0.7))
|
|
806
|
-
const glowLevel = createGlowLevel(() => selected() && Boolean(status().attention), animations)
|
|
807
|
-
const glowColor = createMemo(() => tint(pulseBackground(), glowHue(), 0.45 * glowLevel()))
|
|
808
|
-
const detailPulseColor = createMemo(() => tint(pulseBackground(), theme.text.base, 0.13))
|
|
809
|
-
const detailFlashColor = createMemo(() => tint(pulseBackground(), theme.text.base, 0.42))
|
|
810
|
-
const detailGlowColor = createMemo(() => tint(pulseBackground(), glowHue(), 0.25 * glowLevel()))
|
|
811
|
-
const detailColor = createMemo(() => tint(theme.text.muted, pulseBackground(), 0.35))
|
|
812
|
-
const detailTextColor = (index: number) =>
|
|
813
|
-
detailFades()
|
|
814
|
-
? fadeTitleColor(detailColor(), pulseBackground(), index, visibleDetailParts().length, 0)
|
|
815
|
-
: detailColor()
|
|
816
|
-
const glows = () => status().glows
|
|
817
|
-
// Text tints ride an eased level so they diffuse away with the background glow instead of snapping.
|
|
818
|
-
const titleGlow = createAnimatable(
|
|
819
|
-
{ level: 0 },
|
|
820
|
-
{ enabled: animations, transition: tween({ duration: 0.4 }) },
|
|
821
|
-
)
|
|
822
|
-
createEffect(() => titleGlow.animate({ level: glows() ? 1 : 0 }))
|
|
823
|
-
const numberGlow = createAnimatable(
|
|
824
|
-
{ level: 0 },
|
|
825
|
-
{ enabled: animations, transition: tween({ duration: 0.4 }) },
|
|
826
|
-
)
|
|
827
|
-
createEffect(() =>
|
|
828
|
-
numberGlow.animate({
|
|
829
|
-
level: status().attention || status().unread === "error" || complete() ? 1 : 0,
|
|
830
|
-
}),
|
|
831
|
-
)
|
|
832
|
-
const previous = createMemo(() => items()[index() - 1])
|
|
833
|
-
const previousStatus = createMemo(() => {
|
|
834
|
-
const tab = previous()
|
|
835
|
-
return tab
|
|
836
|
-
? itemStatus(tab)
|
|
837
|
-
: { ...EMPTY_SESSION_TAB_STATUS, complete: false, runs: false, glows: false }
|
|
838
|
-
})
|
|
839
|
-
const previousGlows = () => previousStatus().glows
|
|
840
|
-
const previousRuns = () => previousStatus().runs
|
|
841
|
-
const previousGlowLevel = createGlowLevel(
|
|
842
|
-
() => previous()?.sessionID === activeID() && Boolean(previousStatus().attention),
|
|
843
|
-
animations,
|
|
844
|
-
)
|
|
845
|
-
let lastPreviousGlowHue: RGBA | undefined
|
|
846
|
-
const previousGlowHue = () => {
|
|
847
|
-
const feedback = tabFeedbackColor(previousStatus(), theme)
|
|
848
|
-
if (feedback) return (lastPreviousGlowHue = feedback)
|
|
849
|
-
if (previousStatus().unread !== undefined) return (lastPreviousGlowHue = unreadColor())
|
|
850
|
-
return lastPreviousGlowHue ?? unreadColor()
|
|
851
|
-
}
|
|
852
|
-
const separatorUpperColor = createMemo(() =>
|
|
853
|
-
tint(background(), previousGlowHue(), 0.1 * previousGlowLevel()),
|
|
854
|
-
)
|
|
855
|
-
const separatorLowerColor = createMemo(() => tint(background(), glowHue(), 0.12 * glowLevel()))
|
|
856
|
-
const titleColor = (index: number, separator: boolean) => {
|
|
857
|
-
const level = titleGlow.value().level
|
|
858
|
-
const color =
|
|
859
|
-
level === 0
|
|
860
|
-
? foreground()
|
|
861
|
-
: glowTextColor(foreground(), glowColor(), 1 + numberWidth() + index, width(), level)
|
|
862
|
-
const faded = titleFades()
|
|
863
|
-
? fadeTitleColor(
|
|
864
|
-
color,
|
|
865
|
-
pulseBackground(),
|
|
866
|
-
index,
|
|
867
|
-
visibleTitleParts().length,
|
|
868
|
-
scrolling() ? marquee.leading() : 0,
|
|
869
|
-
)
|
|
870
|
-
: color
|
|
871
|
-
return separator ? tint(faded, pulseBackground(), 0.55) : faded
|
|
872
|
-
}
|
|
873
|
-
return (
|
|
874
|
-
<box
|
|
875
|
-
height={compact() ? 1 : 2}
|
|
876
|
-
width="100%"
|
|
877
|
-
position="relative"
|
|
878
|
-
flexDirection="column"
|
|
879
|
-
backgroundColor={tabBackground()}
|
|
880
|
-
onMouseOver={(event) => {
|
|
881
|
-
setHoverY(event.y)
|
|
882
|
-
marquee.enter(tab.sessionID, title(), compact() ? Infinity : hoveredTitleWidth())
|
|
883
|
-
}}
|
|
884
|
-
onMouseOut={() => marquee.leave(tab.sessionID)}
|
|
885
|
-
onMouseDown={(event) => {
|
|
886
|
-
if (event.button === MIDDLE_MOUSE_BUTTON) {
|
|
887
|
-
didDrag = false
|
|
888
|
-
setDragging(undefined)
|
|
889
|
-
tabs.close(tab.sessionID)
|
|
890
|
-
event.preventDefault()
|
|
891
|
-
event.stopPropagation()
|
|
892
|
-
return
|
|
893
|
-
}
|
|
894
|
-
if (event.button === RIGHT_MOUSE_BUTTON) {
|
|
895
|
-
didDrag = false
|
|
896
|
-
setDragging(undefined)
|
|
897
|
-
if (!rail) return
|
|
898
|
-
setContextMenu({
|
|
899
|
-
x: event.x,
|
|
900
|
-
y: event.y,
|
|
901
|
-
sessionID: tab.sessionID,
|
|
902
|
-
title: tab.title,
|
|
903
|
-
})
|
|
904
|
-
event.preventDefault()
|
|
905
|
-
event.stopPropagation()
|
|
906
|
-
return
|
|
907
|
-
}
|
|
908
|
-
didDrag = false
|
|
909
|
-
marquee.enter(tab.sessionID, title(), compact() ? Infinity : hoveredTitleWidth())
|
|
910
|
-
setDragging(tab.sessionID)
|
|
911
|
-
}}
|
|
912
|
-
>
|
|
913
|
-
<Show when={compact()}>
|
|
914
|
-
<Show when={highlighted(tab.sessionID)}>
|
|
915
|
-
<SessionTabHalfRow
|
|
916
|
-
top={-1}
|
|
917
|
-
edge="top"
|
|
918
|
-
width={width()}
|
|
919
|
-
color={pulseBackground()}
|
|
920
|
-
background={highlighted(items()[index() - 1]?.sessionID) ? highlightColor() : background()}
|
|
921
|
-
/>
|
|
922
|
-
<SessionTabHalfRow
|
|
923
|
-
top={1}
|
|
924
|
-
edge="bottom"
|
|
925
|
-
width={width()}
|
|
926
|
-
color={pulseBackground()}
|
|
927
|
-
background={
|
|
928
|
-
(
|
|
929
|
-
index() === items().length - 1
|
|
930
|
-
? addHighlighted()
|
|
931
|
-
: highlighted(items()[index() + 1]?.sessionID)
|
|
932
|
-
)
|
|
933
|
-
? highlightColor()
|
|
934
|
-
: background()
|
|
935
|
-
}
|
|
936
|
-
/>
|
|
937
|
-
</Show>
|
|
938
|
-
<box height={1} flexDirection="row" justifyContent="center">
|
|
939
|
-
<TabIndicator
|
|
940
|
-
centered
|
|
941
|
-
selected={selected()}
|
|
942
|
-
width={width()}
|
|
943
|
-
status={status()}
|
|
944
|
-
label={sessionTabNumberLabel(index())}
|
|
945
|
-
idleLabel={Locale.graphemes(title().trimStart())[0] ?? "U"}
|
|
946
|
-
color={
|
|
947
|
-
selected()
|
|
948
|
-
? theme.text.base
|
|
949
|
-
: props.numbers
|
|
950
|
-
? numberColor()
|
|
951
|
-
: (tabFeedbackColor(status(), theme) ?? (runs() ? activeNumber() : foreground()))
|
|
952
|
-
}
|
|
953
|
-
unreadColor={tabFeedbackColor(status(), theme) ?? unreadColor()}
|
|
954
|
-
backgroundColor={pulseBackground()}
|
|
955
|
-
flashColor={theme.text.base}
|
|
956
|
-
animations={animations()}
|
|
957
|
-
numbers={props.numbers}
|
|
958
|
-
spinner={props.spinner}
|
|
959
|
-
unreadMarker={props.unreadMarker}
|
|
960
|
-
attributes={selected() ? TextAttributes.BOLD : undefined}
|
|
961
|
-
/>
|
|
962
|
-
</box>
|
|
963
|
-
</Show>
|
|
964
|
-
<Show when={!compact()}>
|
|
965
|
-
<TabPulse
|
|
966
|
-
top={-1}
|
|
967
|
-
edge="above"
|
|
968
|
-
enabled={animations()}
|
|
969
|
-
active={runs()}
|
|
970
|
-
outerActive={previousRuns()}
|
|
971
|
-
promptPulse={status().promptPulse}
|
|
972
|
-
outerPromptPulse={previousStatus().promptPulse}
|
|
973
|
-
complete={complete() && !status().attention}
|
|
974
|
-
outerComplete={previousStatus().complete && !previousStatus().attention}
|
|
975
|
-
glow={glows()}
|
|
976
|
-
outerGlow={previousGlows()}
|
|
977
|
-
color={separatorLowerPulseColor()}
|
|
978
|
-
outerColor={separatorUpperPulseColor()}
|
|
979
|
-
flashColor={tint(background(), theme.text.base, 0.22)}
|
|
980
|
-
outerFlashColor={tint(background(), theme.text.base, 0.18)}
|
|
981
|
-
flashTail={8}
|
|
982
|
-
glowColor={separatorLowerColor()}
|
|
983
|
-
outerGlowColor={separatorUpperColor()}
|
|
984
|
-
glowTail={8}
|
|
985
|
-
outerGlowTail={5}
|
|
986
|
-
completionColor={separatorLowerColor()}
|
|
987
|
-
outerCompletionColor={separatorUpperColor()}
|
|
988
|
-
backgroundColor={background()}
|
|
989
|
-
/>
|
|
990
|
-
<Show when={index() === items().length - 1}>
|
|
991
|
-
<TabPulse
|
|
992
|
-
top={2}
|
|
993
|
-
edge="below"
|
|
994
|
-
enabled={animations()}
|
|
995
|
-
active={runs()}
|
|
996
|
-
outerActive={false}
|
|
997
|
-
promptPulse={status().promptPulse}
|
|
998
|
-
outerPromptPulse={0}
|
|
999
|
-
complete={complete() && !status().attention}
|
|
1000
|
-
outerComplete={false}
|
|
1001
|
-
glow={glows()}
|
|
1002
|
-
outerGlow={false}
|
|
1003
|
-
color={tint(background(), theme.text.base, 0.04)}
|
|
1004
|
-
outerColor={tint(background(), theme.text.base, 0.006)}
|
|
1005
|
-
flashColor={tint(background(), theme.text.base, 0.18)}
|
|
1006
|
-
flashTail={8}
|
|
1007
|
-
glowColor={tint(background(), glowHue(), 0.1 * glowLevel())}
|
|
1008
|
-
outerGlowColor={background()}
|
|
1009
|
-
glowTail={8}
|
|
1010
|
-
outerGlowTail={5}
|
|
1011
|
-
completionColor={tint(background(), glowHue(), 0.1 * glowLevel())}
|
|
1012
|
-
outerCompletionColor={background()}
|
|
1013
|
-
backgroundColor={background()}
|
|
1014
|
-
/>
|
|
1015
|
-
</Show>
|
|
1016
|
-
<box height={1} width="100%" flexDirection="row" position="relative">
|
|
1017
|
-
<TabPulse
|
|
1018
|
-
enabled={animations()}
|
|
1019
|
-
active={runs()}
|
|
1020
|
-
promptPulse={status().promptPulse}
|
|
1021
|
-
complete={complete() && !status().attention}
|
|
1022
|
-
glow={glows()}
|
|
1023
|
-
color={pulseColor()}
|
|
1024
|
-
glowColor={glowColor()}
|
|
1025
|
-
flashColor={flashColor()}
|
|
1026
|
-
flashTail={8}
|
|
1027
|
-
completionColor={glowColor()}
|
|
1028
|
-
backgroundColor={pulseBackground()}
|
|
1029
|
-
onLevel={setSweepLevel}
|
|
1030
|
-
/>
|
|
1031
|
-
<box zIndex={1} width="100%" flexDirection="row" paddingRight={1}>
|
|
1032
|
-
<TabIndicator
|
|
1033
|
-
status={status()}
|
|
1034
|
-
label={sessionTabNumberLabel(index())}
|
|
1035
|
-
width={numberWidth()}
|
|
1036
|
-
color={numberColor()}
|
|
1037
|
-
unreadColor={tabFeedbackColor(status(), theme) ?? unreadColor()}
|
|
1038
|
-
backgroundColor={pulseBackground()}
|
|
1039
|
-
flashColor={theme.text.base}
|
|
1040
|
-
animations={animations()}
|
|
1041
|
-
numbers={props.numbers}
|
|
1042
|
-
spinner={props.spinner}
|
|
1043
|
-
unreadMarker={props.unreadMarker}
|
|
1044
|
-
attributes={selected() ? TextAttributes.BOLD : undefined}
|
|
1045
|
-
/>
|
|
1046
|
-
<title_shimmer
|
|
1047
|
-
width={titleWidth()}
|
|
1048
|
-
height={1}
|
|
1049
|
-
fg={foreground()}
|
|
1050
|
-
rename={{ pending: status().renaming, title: title() }}
|
|
1051
|
-
enabled={animations()}
|
|
1052
|
-
backdrop={pulseBackground()}
|
|
1053
|
-
wrapMode="none"
|
|
1054
|
-
selectable={false}
|
|
1055
|
-
attributes={
|
|
1056
|
-
status().renaming && !animations()
|
|
1057
|
-
? TextAttributes.DIM
|
|
1058
|
-
: selected()
|
|
1059
|
-
? TextAttributes.BOLD
|
|
1060
|
-
: undefined
|
|
1061
|
-
}
|
|
1062
|
-
>
|
|
1063
|
-
<Show
|
|
1064
|
-
when={scrolling() || titleGlow.value().level > 0 || titleFades()}
|
|
1065
|
-
fallback={visibleTitle()}
|
|
1066
|
-
>
|
|
1067
|
-
<Index each={visibleTitleParts()}>
|
|
1068
|
-
{(part, index) => (
|
|
1069
|
-
<span style={{ fg: titleColor(index, part().separator) }}>{part().value}</span>
|
|
1070
|
-
)}
|
|
1071
|
-
</Index>
|
|
1072
|
-
</Show>
|
|
1073
|
-
</title_shimmer>
|
|
1074
|
-
<text
|
|
1075
|
-
position="absolute"
|
|
1076
|
-
right={1}
|
|
1077
|
-
zIndex={2}
|
|
1078
|
-
width={1}
|
|
1079
|
-
fg={closeHovered() ? theme.text.base : theme.text.muted}
|
|
1080
|
-
selectable={false}
|
|
1081
|
-
onMouseOver={() => setCloseHovered(true)}
|
|
1082
|
-
onMouseOut={() => setCloseHovered(false)}
|
|
1083
|
-
onMouseDown={(event) => {
|
|
1084
|
-
if (event.button === RIGHT_MOUSE_BUTTON || hovered() !== tab.sessionID) return
|
|
1085
|
-
didDrag = false
|
|
1086
|
-
event.stopPropagation()
|
|
1087
|
-
}}
|
|
1088
|
-
onMouseUp={(event) => {
|
|
1089
|
-
if (event.button === RIGHT_MOUSE_BUTTON) return
|
|
1090
|
-
if (suppressClick) return
|
|
1091
|
-
if (hovered() !== tab.sessionID) return
|
|
1092
|
-
event.stopPropagation()
|
|
1093
|
-
tabs.close(tab.sessionID)
|
|
1094
|
-
}}
|
|
1095
|
-
>
|
|
1096
|
-
{hovered() === tab.sessionID ? "✕" : ""}
|
|
1097
|
-
</text>
|
|
1098
|
-
</box>
|
|
1099
|
-
</box>
|
|
1100
|
-
<box height={1} width="100%" position="relative" flexDirection="row">
|
|
1101
|
-
<TabPulse
|
|
1102
|
-
enabled={animations()}
|
|
1103
|
-
active={runs()}
|
|
1104
|
-
promptPulse={status().promptPulse}
|
|
1105
|
-
complete={complete() && !status().attention}
|
|
1106
|
-
glow={glows()}
|
|
1107
|
-
color={detailPulseColor()}
|
|
1108
|
-
glowColor={detailGlowColor()}
|
|
1109
|
-
glowTail={10}
|
|
1110
|
-
flashColor={detailFlashColor()}
|
|
1111
|
-
flashTail={8}
|
|
1112
|
-
completionColor={detailGlowColor()}
|
|
1113
|
-
backgroundColor={pulseBackground()}
|
|
1114
|
-
/>
|
|
1115
|
-
<box zIndex={1} width="100%" flexDirection="row" paddingLeft={prefixWidth()} paddingRight={2}>
|
|
1116
|
-
<text fg={detailColor()} wrapMode="none" selectable={false}>
|
|
1117
|
-
<Show when={detailFades()} fallback={visibleDetail()}>
|
|
1118
|
-
<For each={visibleDetailParts()}>
|
|
1119
|
-
{(character, index) => <span style={{ fg: detailTextColor(index()) }}>{character}</span>}
|
|
1120
|
-
</For>
|
|
1121
|
-
</Show>
|
|
1122
|
-
</text>
|
|
1123
|
-
</box>
|
|
1124
|
-
</box>
|
|
1125
|
-
</Show>
|
|
1126
|
-
</box>
|
|
1127
|
-
)
|
|
1128
|
-
}}
|
|
1129
|
-
</For>
|
|
1130
|
-
{/* One slot with two states: a muted affordance that promotes in place into the
|
|
1131
|
-
active new-session tab, instead of spawning a separate pseudo tab above itself. */}
|
|
1132
|
-
<Show when={tabs.add || newTab()}>
|
|
1133
|
-
<box
|
|
1134
|
-
height={1}
|
|
1135
|
-
width="100%"
|
|
1136
|
-
position="relative"
|
|
1137
|
-
flexDirection="row"
|
|
1138
|
-
paddingLeft={compact() ? 0 : 1}
|
|
1139
|
-
justifyContent={compact() ? "center" : "flex-start"}
|
|
1140
|
-
alignItems="center"
|
|
1141
|
-
backgroundColor={
|
|
1142
|
-
newTab() && !compact()
|
|
1143
|
-
? actionSelected()
|
|
1144
|
-
: addHovered() || (compact() && newTab())
|
|
1145
|
-
? actionHovered()
|
|
1146
|
-
: background()
|
|
1147
|
-
}
|
|
1148
|
-
onMouseOver={() => setAddHovered(true)}
|
|
1149
|
-
onMouseOut={() => setAddHovered(false)}
|
|
1150
|
-
onMouseDown={(event: MouseEvent) => {
|
|
1151
|
-
didDrag = false
|
|
1152
|
-
setDragging(undefined)
|
|
1153
|
-
addPressed = event.button !== RIGHT_MOUSE_BUTTON
|
|
1154
|
-
if (addPressed) return
|
|
1155
|
-
if (!rail) return
|
|
1156
|
-
setContextMenu({ x: event.x, y: event.y })
|
|
1157
|
-
event.preventDefault()
|
|
1158
|
-
event.stopPropagation()
|
|
1159
|
-
}}
|
|
1160
|
-
onMouseUp={(event: MouseEvent) => {
|
|
1161
|
-
if (event.button === RIGHT_MOUSE_BUTTON) return
|
|
1162
|
-
if (suppressClick) return
|
|
1163
|
-
if (!addPressed) return
|
|
1164
|
-
addPressed = false
|
|
1165
|
-
if (!newTab()) tabs.add?.()
|
|
1166
|
-
}}
|
|
1167
|
-
onMouseDragEnd={() => (addPressed = false)}
|
|
1168
|
-
>
|
|
1169
|
-
<Show when={compact() && addHighlighted()}>
|
|
1170
|
-
<SessionTabHalfRow
|
|
1171
|
-
top={-1}
|
|
1172
|
-
edge="top"
|
|
1173
|
-
width={width()}
|
|
1174
|
-
color={highlightColor()}
|
|
1175
|
-
background={highlighted(items().at(-1)?.sessionID) ? highlightColor() : background()}
|
|
1176
|
-
/>
|
|
1177
|
-
<SessionTabHalfRow
|
|
1178
|
-
top={1}
|
|
1179
|
-
edge="bottom"
|
|
1180
|
-
width={width()}
|
|
1181
|
-
color={highlightColor()}
|
|
1182
|
-
background={background()}
|
|
1183
|
-
/>
|
|
1184
|
-
</Show>
|
|
1185
|
-
<text
|
|
1186
|
-
width={compact() ? 1 : 2}
|
|
1187
|
-
fg={newTab() || addHovered() ? theme.text.base : idleNumber()}
|
|
1188
|
-
selectable={false}
|
|
1189
|
-
attributes={newTab() ? TextAttributes.BOLD : undefined}
|
|
1190
|
-
>
|
|
1191
|
-
+
|
|
1192
|
-
</text>
|
|
1193
|
-
<Show when={!compact()}>
|
|
1194
|
-
<text
|
|
1195
|
-
fg={newTab() || addHovered() ? theme.text.base : theme.text.muted}
|
|
1196
|
-
wrapMode="none"
|
|
1197
|
-
selectable={false}
|
|
1198
|
-
attributes={newTab() ? TextAttributes.BOLD : undefined}
|
|
1199
|
-
>
|
|
1200
|
-
{NEW_SESSION_TAB_TITLE}
|
|
1201
|
-
</text>
|
|
1202
|
-
</Show>
|
|
1203
|
-
<Show when={newTab() && !compact()}>
|
|
1204
|
-
<text
|
|
1205
|
-
position="absolute"
|
|
1206
|
-
right={1}
|
|
1207
|
-
zIndex={2}
|
|
1208
|
-
width={1}
|
|
1209
|
-
fg={theme.text.muted}
|
|
1210
|
-
selectable={false}
|
|
1211
|
-
onMouseUp={(event) => {
|
|
1212
|
-
if (event.button === RIGHT_MOUSE_BUTTON) return
|
|
1213
|
-
if (suppressClick) return
|
|
1214
|
-
if (!addHovered()) return
|
|
1215
|
-
event.stopPropagation()
|
|
1216
|
-
tabs.close()
|
|
1217
|
-
}}
|
|
1218
|
-
>
|
|
1219
|
-
{addHovered() ? "×" : ""}
|
|
1220
|
-
</text>
|
|
1221
|
-
</Show>
|
|
1222
|
-
</box>
|
|
1223
|
-
</Show>
|
|
1224
|
-
</box>
|
|
1225
|
-
</scrollbox>
|
|
1226
|
-
<Show when={compact() && !dragging() && !contextMenu() && hovered()}>
|
|
1227
|
-
{(sessionID) => (
|
|
1228
|
-
<box
|
|
1229
|
-
position="absolute"
|
|
1230
|
-
left={width()}
|
|
1231
|
-
top={Math.max(0, Math.min(hoverY() - 1, dimensions().height - 4) - (rail?.screenY ?? 0))}
|
|
1232
|
-
width={tooltipWidth()}
|
|
1233
|
-
height={4}
|
|
1234
|
-
paddingY={1}
|
|
1235
|
-
zIndex={2000}
|
|
1236
|
-
>
|
|
1237
|
-
<SessionTabHalfRow
|
|
1238
|
-
top={0}
|
|
1239
|
-
edge="top"
|
|
1240
|
-
width={tooltipWidth()}
|
|
1241
|
-
color={background()}
|
|
1242
|
-
background={base.background.base}
|
|
1243
|
-
/>
|
|
1244
|
-
<box height={2} paddingX={1} backgroundColor={background()}>
|
|
1245
|
-
<text fg={theme.text.base} wrapMode="none" selectable={false}>
|
|
1246
|
-
{Locale.truncateWidth(
|
|
1247
|
-
data?.session.get(sessionID())?.title ??
|
|
1248
|
-
items().find((tab) => tab.sessionID === sessionID())?.title ??
|
|
1249
|
-
"Untitled session",
|
|
1250
|
-
tooltipWidth() - 2,
|
|
1251
|
-
)}
|
|
1252
|
-
</text>
|
|
1253
|
-
<text fg={theme.text.muted} wrapMode="none" selectable={false}>
|
|
1254
|
-
{Locale.takeWidth(detail(sessionID()), tooltipWidth() - 2)}
|
|
1255
|
-
</text>
|
|
1256
|
-
</box>
|
|
1257
|
-
<SessionTabHalfRow
|
|
1258
|
-
top={3}
|
|
1259
|
-
edge="bottom"
|
|
1260
|
-
width={tooltipWidth()}
|
|
1261
|
-
color={background()}
|
|
1262
|
-
background={base.background.base}
|
|
1263
|
-
/>
|
|
1264
|
-
</box>
|
|
1265
|
-
)}
|
|
1266
|
-
</Show>
|
|
1267
|
-
<Show when={contextMenu()}>
|
|
1268
|
-
{(state) => <TabContextMenu state={state()} tabs={tabs} onClose={() => setContextMenu(undefined)} />}
|
|
1269
|
-
</Show>
|
|
1270
|
-
</box>
|
|
1271
|
-
)
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
function HorizontalSessionTabs(props: {
|
|
1275
|
-
controller?: SessionTabsController
|
|
1276
|
-
animations?: boolean
|
|
1277
|
-
spinner?: TabSpinner
|
|
1278
|
-
unreadMarker?: TabUnreadMarker
|
|
1279
|
-
numbers: boolean
|
|
1280
|
-
}) {
|
|
1281
|
-
const tabs = props.controller ?? useSessionTabs()
|
|
1282
|
-
const data = props.controller ? undefined : useData()
|
|
1283
|
-
const dimensions = useTerminalDimensions()
|
|
1284
|
-
const theme = useTheme()
|
|
1285
|
-
const config = useConfig().data
|
|
1286
|
-
const animations = () => props.animations ?? config.animations ?? true
|
|
1287
|
-
const [addHovered, setAddHovered] = createSignal(false)
|
|
1288
|
-
const marquee = createTabMarquee(animations)
|
|
1289
|
-
const hovered = marquee.hovered
|
|
1290
|
-
// OpenTUI captures the first drag target, which may differ from the tab pressed on a fast move.
|
|
1291
|
-
const [dragging, setDragging] = createSignal<string>()
|
|
1292
|
-
// A drag reorders a local preview and persists one move on release instead of writing
|
|
1293
|
-
// per slot crossing; the preview holds after release until the store reflects the move,
|
|
1294
|
-
// so the strip never flashes the pre-drag order while the write is in flight.
|
|
1295
|
-
const [preview, setPreview] = createSignal<{ sessionID: string; index: number }>()
|
|
1296
|
-
const [contextMenu, setContextMenu] = createSignal<TabContextMenuState>()
|
|
1297
|
-
const [closeHold, setCloseHold] = createSignal<MouseCloseHold>()
|
|
1298
|
-
let strip: { screenX: number; screenY: number; width: number; height: number } | undefined
|
|
1299
|
-
let didDrag = false
|
|
1300
|
-
let addPressed = false
|
|
1301
|
-
let closeHoldTimer: ReturnType<typeof setTimeout> | undefined
|
|
1302
|
-
let releasingCloseHold = false
|
|
1303
|
-
const clearCloseHold = () => {
|
|
1304
|
-
setCloseHold(undefined)
|
|
1305
|
-
if (closeHoldTimer) clearTimeout(closeHoldTimer)
|
|
1306
|
-
closeHoldTimer = undefined
|
|
1307
|
-
}
|
|
1308
|
-
const releaseCloseHold = () => {
|
|
1309
|
-
if (!closeHold()) return
|
|
1310
|
-
releasingCloseHold = true
|
|
1311
|
-
clearCloseHold()
|
|
1312
|
-
}
|
|
1313
|
-
onCleanup(clearCloseHold)
|
|
1314
|
-
// A captured drag ends with a synthetic up on its drop target; do not turn that into a click.
|
|
1315
|
-
let suppressClick = false
|
|
1316
|
-
const unreadColor = () => theme.hue.accent[200]
|
|
1317
|
-
const activeNumber = () => theme.hue.interactive[200]
|
|
1318
|
-
const idleNumber = () => tint(theme.text.formfield.base, theme.background.base, 0.55)
|
|
1319
|
-
const newTab = () => tabs.newTab?.() ?? false
|
|
1320
|
-
const activeID = createMemo(() => (newTab() ? NEW_SESSION_TAB.sessionID : tabs.current()))
|
|
1321
|
-
const ordered = createMemo(() => {
|
|
1322
|
-
const pending = preview()
|
|
1323
|
-
if (!pending) return tabs.tabs()
|
|
1324
|
-
return moveSessionTab(tabs.tabs(), pending.sessionID, pending.index)
|
|
1325
|
-
})
|
|
1326
|
-
// The promoted new-session slot joins the strip as the active tab; the idle plus affordance
|
|
1327
|
-
// and the promoted slot are mutually exclusive states of one control.
|
|
1328
|
-
const items = createMemo(() => (newTab() ? [...ordered(), NEW_SESSION_TAB] : ordered()))
|
|
1329
|
-
const showPlus = () => Boolean(tabs.add) && !newTab()
|
|
1330
|
-
createEffect(() => {
|
|
1331
|
-
const pending = preview()
|
|
1332
|
-
if (!pending || dragging()) return
|
|
1333
|
-
const index = tabs.tabs().findIndex((tab) => tab.sessionID === pending.sessionID)
|
|
1334
|
-
if (index === -1 || index === Math.min(pending.index, tabs.tabs().length - 1)) setPreview(undefined)
|
|
1335
|
-
})
|
|
1336
|
-
const heldLayout = createMemo(() => {
|
|
1337
|
-
const hold = closeHold()
|
|
1338
|
-
return hold ? heldSessionTabLayout(hold, items()) : undefined
|
|
1339
|
-
})
|
|
1340
|
-
const layout = createMemo(
|
|
1341
|
-
(previous: ReturnType<typeof adaptiveSessionTabLayout> | undefined) =>
|
|
1342
|
-
heldLayout() ??
|
|
1343
|
-
adaptiveSessionTabLayout(
|
|
1344
|
-
items(),
|
|
1345
|
-
activeID(),
|
|
1346
|
-
dimensions().width - (showPlus() ? ADD_TAB_WIDTH : 0),
|
|
1347
|
-
previous?.start,
|
|
1348
|
-
),
|
|
1349
|
-
)
|
|
1350
|
-
createEffect(() => {
|
|
1351
|
-
if (closeHold() && !heldLayout()) clearCloseHold()
|
|
1352
|
-
})
|
|
1353
|
-
createEffect(() => {
|
|
1354
|
-
const active = marquee.active()
|
|
1355
|
-
if (active && !layout().tabs.some((tab) => tab.sessionID === active)) marquee.reset()
|
|
1356
|
-
})
|
|
1357
|
-
const statuses = createMemo(
|
|
1358
|
-
() =>
|
|
1359
|
-
new Map(
|
|
1360
|
-
layout().tabs.map((tab) => {
|
|
1361
|
-
const status = tab === NEW_SESSION_TAB ? EMPTY_SESSION_TAB_STATUS : tabs.status(tab.sessionID)
|
|
1362
|
-
return [
|
|
1363
|
-
tab.sessionID,
|
|
1364
|
-
{
|
|
1365
|
-
...status,
|
|
1366
|
-
complete: sessionTabComplete(status.unread, status.busy),
|
|
1367
|
-
},
|
|
1368
|
-
] as const
|
|
1369
|
-
}),
|
|
1370
|
-
),
|
|
1371
|
-
)
|
|
1372
|
-
const targets = createMemo(() => ({
|
|
1373
|
-
widths: layout().widths,
|
|
1374
|
-
selections: layout().tabs.map((tab) => Number(tab.sessionID === activeID())),
|
|
1375
|
-
activities: layout().tabs.map((tab) => Number(statuses().get(tab.sessionID)!.complete)),
|
|
1376
|
-
}))
|
|
1377
|
-
const motion = createAnimatable(targets(), {
|
|
1378
|
-
enabled: animations,
|
|
1379
|
-
transition: spring({ visualDuration: 0.1 }),
|
|
1380
|
-
})
|
|
1381
|
-
const identity = createMemo(() =>
|
|
1382
|
-
layout()
|
|
1383
|
-
.tabs.map((tab) => tab.sessionID)
|
|
1384
|
-
.join(":"),
|
|
1385
|
-
)
|
|
1386
|
-
let signature = ""
|
|
1387
|
-
let total = 0
|
|
1388
|
-
let terminalWidth = dimensions().width
|
|
1389
|
-
|
|
1390
|
-
// createComputed runs before render effects, so seeded widths are visible on the first frame
|
|
1391
|
-
// of a membership change instead of flashing the final layout.
|
|
1392
|
-
createComputed(() => {
|
|
1393
|
-
const next = targets()
|
|
1394
|
-
const nextSignature = identity()
|
|
1395
|
-
const changed = Boolean(signature) && signature !== nextSignature
|
|
1396
|
-
const resized = Boolean(total) && total !== layout().total
|
|
1397
|
-
const terminalResized = terminalWidth !== dimensions().width
|
|
1398
|
-
const previous = signature
|
|
1399
|
-
signature = nextSignature
|
|
1400
|
-
total = layout().total
|
|
1401
|
-
terminalWidth = dimensions().width
|
|
1402
|
-
const releasing = releasingCloseHold
|
|
1403
|
-
releasingCloseHold = false
|
|
1404
|
-
if (terminalResized && closeHold()) {
|
|
1405
|
-
clearCloseHold()
|
|
1406
|
-
return
|
|
1407
|
-
}
|
|
1408
|
-
if (closeHold() && heldLayout()) {
|
|
1409
|
-
const current = untrack(motion.value)
|
|
1410
|
-
const seeded = changed
|
|
1411
|
-
? seedSessionTabMotion(
|
|
1412
|
-
previous.split(":"),
|
|
1413
|
-
layout().tabs.map((tab) => tab.sessionID),
|
|
1414
|
-
current,
|
|
1415
|
-
next,
|
|
1416
|
-
)
|
|
1417
|
-
: current
|
|
1418
|
-
if (!seeded) return motion.jump(next)
|
|
1419
|
-
motion.jump({ ...seeded, widths: next.widths })
|
|
1420
|
-
return motion.animate(next)
|
|
1421
|
-
}
|
|
1422
|
-
if (!changed && !resized) return motion.animate(next)
|
|
1423
|
-
// Identity-stable total changes are terminal resizes and still jump.
|
|
1424
|
-
if (!changed) return releasing ? motion.animate(next) : motion.jump(next)
|
|
1425
|
-
const seeded = seedSessionTabMotion(
|
|
1426
|
-
previous.split(":"),
|
|
1427
|
-
layout().tabs.map((tab) => tab.sessionID),
|
|
1428
|
-
untrack(motion.value),
|
|
1429
|
-
next,
|
|
1430
|
-
)
|
|
1431
|
-
if (!seeded) return motion.jump(next)
|
|
1432
|
-
motion.jump(seeded)
|
|
1433
|
-
motion.animate(next)
|
|
1434
|
-
})
|
|
1435
|
-
|
|
1436
|
-
const activeIndex = createMemo(() => layout().tabs.findIndex((tab) => tab.sessionID === activeID()))
|
|
1437
|
-
const visuals = createMemo(() => {
|
|
1438
|
-
const current = signature === identity() && total === layout().total ? motion.value() : targets()
|
|
1439
|
-
const widths = current.widths.map((width) => Math.max(1, Math.round(width)))
|
|
1440
|
-
const active = activeIndex()
|
|
1441
|
-
const remainder = layout().total - widths.reduce((sum, width) => sum + width, 0)
|
|
1442
|
-
// Absorb only rounding slack; membership animations leave a real gap while widths grow into place.
|
|
1443
|
-
if (active !== -1 && Math.abs(remainder) <= layout().tabs.length) widths[active] += remainder
|
|
1444
|
-
return new Map(
|
|
1445
|
-
layout().tabs.map((tab, index) => [
|
|
1446
|
-
tab.sessionID,
|
|
1447
|
-
{
|
|
1448
|
-
width: widths[index],
|
|
1449
|
-
selection: current.selections[index] ?? Number(tab.sessionID === activeID()),
|
|
1450
|
-
activity: current.activities[index] ?? Number(statuses().get(tab.sessionID)!.complete),
|
|
1451
|
-
},
|
|
1452
|
-
]),
|
|
1453
|
-
)
|
|
1454
|
-
})
|
|
1455
|
-
|
|
1456
|
-
const holdCloseCell = (sessionID: string, x: number) => {
|
|
1457
|
-
if (!strip) return clearCloseHold()
|
|
1458
|
-
const current = layout()
|
|
1459
|
-
const index = current.tabs.findIndex((tab) => tab.sessionID === sessionID)
|
|
1460
|
-
const all = items()
|
|
1461
|
-
const itemIndex = all.findIndex((tab) => tab.sessionID === sessionID)
|
|
1462
|
-
const target = all[itemIndex + 1] ?? all[itemIndex - 1]
|
|
1463
|
-
if (index === -1 || itemIndex === -1 || !target) return clearCloseHold()
|
|
1464
|
-
const ids = current.tabs.map((tab) => tab.sessionID)
|
|
1465
|
-
const values = ids.map((id) => visuals().get(id))
|
|
1466
|
-
if (values.some((value) => !value)) return clearCloseHold()
|
|
1467
|
-
setCloseHold({
|
|
1468
|
-
items: all.map((tab) => tab.sessionID),
|
|
1469
|
-
ids,
|
|
1470
|
-
widths: values.map((value) => value!.width),
|
|
1471
|
-
closed: sessionID,
|
|
1472
|
-
target: target.sessionID,
|
|
1473
|
-
x: x - strip.screenX,
|
|
1474
|
-
})
|
|
1475
|
-
if (closeHoldTimer) clearTimeout(closeHoldTimer)
|
|
1476
|
-
closeHoldTimer = setTimeout(releaseCloseHold, MOUSE_CLOSE_HOLD_MS)
|
|
1477
|
-
}
|
|
1478
|
-
|
|
1479
|
-
// Map an absolute pointer column to the items index of the visible slot beneath it.
|
|
1480
|
-
const slotAt = (x: number) => {
|
|
1481
|
-
if (!strip) return undefined
|
|
1482
|
-
const stripX = x - strip.screenX
|
|
1483
|
-
let edge = layout().before > 0 ? sessionTabOverflowWidth(layout().before) : 0
|
|
1484
|
-
for (const [index, width] of layout().widths.entries()) {
|
|
1485
|
-
edge += width
|
|
1486
|
-
if (stripX < edge) return layout().before + index
|
|
1487
|
-
}
|
|
1488
|
-
return layout().before + layout().widths.length - 1
|
|
1489
|
-
}
|
|
1490
|
-
|
|
1491
|
-
const release = () => {
|
|
1492
|
-
const source = dragging()
|
|
1493
|
-
if (!source) return
|
|
1494
|
-
if (didDrag) suppressClick = true
|
|
1495
|
-
setDragging(undefined)
|
|
1496
|
-
const pending = preview()
|
|
1497
|
-
if (pending?.sessionID === source) tabs.move(pending.sessionID, pending.index)
|
|
1498
|
-
if (source === NEW_SESSION_TAB.sessionID) return
|
|
1499
|
-
tabs.select(source)
|
|
1500
|
-
}
|
|
1501
|
-
|
|
1502
|
-
const drag = (event: MouseEvent) => {
|
|
1503
|
-
const source = dragging()
|
|
1504
|
-
if (!source || source === NEW_SESSION_TAB.sessionID) return
|
|
1505
|
-
didDrag = true
|
|
1506
|
-
const slot = slotAt(event.x)
|
|
1507
|
-
const target = slot === undefined ? undefined : Math.min(slot, tabs.tabs().length - 1)
|
|
1508
|
-
const sourceIndex = items().findIndex((item) => item.sessionID === source)
|
|
1509
|
-
if (target !== undefined && target !== sourceIndex && preview()?.index !== target) {
|
|
1510
|
-
setPreview({ sessionID: source, index: target })
|
|
1511
|
-
}
|
|
1512
|
-
}
|
|
1513
|
-
|
|
1514
|
-
return (
|
|
1515
|
-
<box
|
|
1516
|
-
ref={(element) => (strip = element)}
|
|
1517
|
-
height={1}
|
|
1518
|
-
flexShrink={0}
|
|
1519
|
-
position="relative"
|
|
1520
|
-
flexDirection="row"
|
|
1521
|
-
zIndex={1}
|
|
1522
|
-
onMouseOut={(event) => {
|
|
1523
|
-
marquee.leaveHovered()
|
|
1524
|
-
if (!strip) return
|
|
1525
|
-
if (
|
|
1526
|
-
event.x < strip.screenX ||
|
|
1527
|
-
event.x >= strip.screenX + strip.width ||
|
|
1528
|
-
event.y < strip.screenY ||
|
|
1529
|
-
event.y >= strip.screenY + strip.height
|
|
1530
|
-
)
|
|
1531
|
-
releaseCloseHold()
|
|
1532
|
-
}}
|
|
1533
|
-
onMouseUp={(event) => {
|
|
1534
|
-
if (event.button === RIGHT_MOUSE_BUTTON) return
|
|
1535
|
-
release()
|
|
1536
|
-
if (!didDrag) return
|
|
1537
|
-
didDrag = false
|
|
1538
|
-
queueMicrotask(() => (suppressClick = false))
|
|
1539
|
-
}}
|
|
1540
|
-
onMouseDrag={drag}
|
|
1541
|
-
onMouseDragEnd={release}
|
|
1542
|
-
>
|
|
1543
|
-
<Show when={layout().before > 0}>
|
|
1544
|
-
<text width={sessionTabOverflowWidth(layout().before)} fg={theme.text.muted} selectable={false}>
|
|
1545
|
-
‹{layout().before}
|
|
1546
|
-
</text>
|
|
1547
|
-
</Show>
|
|
1548
|
-
<For each={layout().tabs}>
|
|
1549
|
-
{(tab) => {
|
|
1550
|
-
const selected = () => activeID() === tab.sessionID
|
|
1551
|
-
const status = () => statuses().get(tab.sessionID)!
|
|
1552
|
-
const width = () => visuals().get(tab.sessionID)?.width ?? 1
|
|
1553
|
-
const selection = () => visuals().get(tab.sessionID)?.selection ?? Number(selected())
|
|
1554
|
-
const activity = () => visuals().get(tab.sessionID)?.activity ?? Number(status().complete)
|
|
1555
|
-
const dragged = () => dragging() === tab.sessionID
|
|
1556
|
-
const background = createMemo(() => {
|
|
1557
|
-
const lifted = (hovered() === tab.sessionID || dragged()) && !selected()
|
|
1558
|
-
const base = lifted ? theme.background.action.primary.hovered : theme.background.base
|
|
1559
|
-
// A dragged tab lifts to full selected elevation while it is held.
|
|
1560
|
-
return tint(base, theme.decrease(theme.background.raised.base), dragged() ? 1 : selection())
|
|
1561
|
-
})
|
|
1562
|
-
const pulseColor = () => tint(background(), theme.text.base, 0.45)
|
|
1563
|
-
// The edge flash washes toward a brighter stop on the same background-to-text ramp,
|
|
1564
|
-
// so it reads as a lift of the pulse color rather than a different hue.
|
|
1565
|
-
const flashColor = () => tint(background(), theme.text.base, 0.65)
|
|
1566
|
-
const feedbackColor = () => tabFeedbackColor(status(), theme)
|
|
1567
|
-
const glowLevel = createGlowLevel(() => selected() && Boolean(status().attention), animations)
|
|
1568
|
-
const glowColor = createMemo(() => tint(background(), feedbackColor() ?? unreadColor(), glowLevel()))
|
|
1569
|
-
const glows = () =>
|
|
1570
|
-
Boolean(status().attention || (!selected() && !status().busy && status().unread !== undefined))
|
|
1571
|
-
const title = () => data?.session.get(tab.sessionID)?.title ?? tab.title ?? "Untitled session"
|
|
1572
|
-
const tabNumber = createMemo(() => items().findIndex((item) => item.sessionID === tab.sessionID) + 1)
|
|
1573
|
-
const numberWidth = () => Math.max(2, String(items().length).length)
|
|
1574
|
-
// Hovering reveals the close mark, so the title's right bound shifts left of it.
|
|
1575
|
-
const restingTitleWidth = () => Math.max(1, width() - 1 - numberWidth())
|
|
1576
|
-
const hoveredTitleWidth = () => Math.max(1, restingTitleWidth() - 2)
|
|
1577
|
-
const availableTitleWidth = () => (hovered() === tab.sessionID ? hoveredTitleWidth() : restingTitleWidth())
|
|
1578
|
-
const scrolling = () => marquee.active() === tab.sessionID
|
|
1579
|
-
const visibleTitleParts = createMemo(() =>
|
|
1580
|
-
scrolling()
|
|
1581
|
-
? marqueeTextParts(title(), availableTitleWidth(), marquee.offset())
|
|
1582
|
-
: Locale.graphemes(Locale.takeWidth(title(), availableTitleWidth())).map((value) => ({
|
|
1583
|
-
value,
|
|
1584
|
-
separator: false,
|
|
1585
|
-
})),
|
|
1586
|
-
)
|
|
1587
|
-
const visibleTitle = createMemo(() =>
|
|
1588
|
-
visibleTitleParts()
|
|
1589
|
-
.map((part) => part.value)
|
|
1590
|
-
.join(""),
|
|
1591
|
-
)
|
|
1592
|
-
const titleFades = createMemo(
|
|
1593
|
-
() => marqueeOverflows(title(), availableTitleWidth()) && availableTitleWidth() > FADE_WIDTH,
|
|
1594
|
-
)
|
|
1595
|
-
const runs = () => status().busy && !status().attention
|
|
1596
|
-
const numberIgnition = createNumberIgnition(runs, () => status().promptPulse, animations)
|
|
1597
|
-
const foreground = () => {
|
|
1598
|
-
if (hovered() === tab.sessionID) return theme.text.base
|
|
1599
|
-
return tint(theme.text.muted, theme.text.base, selection())
|
|
1600
|
-
}
|
|
1601
|
-
// Title characters sitting over the glow tinge toward its color, following the same
|
|
1602
|
-
// spatial falloff as the glow itself; characters beyond the tail stay neutral.
|
|
1603
|
-
const characterColor = (index: number, separator: boolean) => {
|
|
1604
|
-
const base = foreground()
|
|
1605
|
-
const color = glows() ? glowTextColor(base, glowColor(), 1 + numberWidth() + index, width()) : base
|
|
1606
|
-
const faded = titleFades()
|
|
1607
|
-
? fadeTitleColor(
|
|
1608
|
-
color,
|
|
1609
|
-
background(),
|
|
1610
|
-
index,
|
|
1611
|
-
visibleTitleParts().length,
|
|
1612
|
-
scrolling() ? marquee.leading() : 0,
|
|
1613
|
-
)
|
|
1614
|
-
: color
|
|
1615
|
-
return separator ? tint(faded, background(), 0.55) : faded
|
|
1616
|
-
}
|
|
1617
|
-
// The running sweep's level under the number cell, reported by the pulse renderable.
|
|
1618
|
-
const [sweepLevel, setSweepLevel] = createSignal(0)
|
|
1619
|
-
const [closeHovered, setCloseHovered] = createSignal(false)
|
|
1620
|
-
const numberColor = () => {
|
|
1621
|
-
const feedback = feedbackColor()
|
|
1622
|
-
const base =
|
|
1623
|
-
hovered() === tab.sessionID && !selected()
|
|
1624
|
-
? foreground()
|
|
1625
|
-
: tint(idleNumber(), tint(theme.text.base, background(), 0.25), selection())
|
|
1626
|
-
const color = runs() ? activeNumber() : (feedback ?? tint(base, unreadColor(), activity()))
|
|
1627
|
-
// The number brightens faintly as the running sweep passes beneath it.
|
|
1628
|
-
return tint(color, theme.text.base, Math.max(numberIgnition.value().level, 0.15 * sweepLevel()))
|
|
1629
|
-
}
|
|
1630
|
-
const bold = () => (selected() || dragged() ? TextAttributes.BOLD : undefined)
|
|
1631
|
-
const closeColor = () => tint(theme.text.muted, theme.text.base, 0.6)
|
|
1632
|
-
return (
|
|
1633
|
-
<box
|
|
1634
|
-
width={width()}
|
|
1635
|
-
position="relative"
|
|
1636
|
-
flexDirection="row"
|
|
1637
|
-
backgroundColor={background()}
|
|
1638
|
-
onMouseOver={() => marquee.enter(tab.sessionID, title(), hoveredTitleWidth())}
|
|
1639
|
-
onMouseOut={() => marquee.leave(tab.sessionID)}
|
|
1640
|
-
onMouseDown={(event) => {
|
|
1641
|
-
if (event.button === MIDDLE_MOUSE_BUTTON) {
|
|
1642
|
-
releaseCloseHold()
|
|
1643
|
-
didDrag = false
|
|
1644
|
-
setDragging(undefined)
|
|
1645
|
-
tabs.close(tab === NEW_SESSION_TAB ? undefined : tab.sessionID)
|
|
1646
|
-
event.preventDefault()
|
|
1647
|
-
event.stopPropagation()
|
|
1648
|
-
return
|
|
1649
|
-
}
|
|
1650
|
-
if (event.button === RIGHT_MOUSE_BUTTON) {
|
|
1651
|
-
releaseCloseHold()
|
|
1652
|
-
didDrag = false
|
|
1653
|
-
setDragging(undefined)
|
|
1654
|
-
setContextMenu({
|
|
1655
|
-
x: event.x,
|
|
1656
|
-
y: event.y,
|
|
1657
|
-
sessionID: tab === NEW_SESSION_TAB ? undefined : tab.sessionID,
|
|
1658
|
-
title: tab === NEW_SESSION_TAB ? undefined : tab.title,
|
|
1659
|
-
})
|
|
1660
|
-
event.preventDefault()
|
|
1661
|
-
event.stopPropagation()
|
|
1662
|
-
return
|
|
1663
|
-
}
|
|
1664
|
-
didDrag = false
|
|
1665
|
-
releaseCloseHold()
|
|
1666
|
-
marquee.enter(tab.sessionID, title(), hoveredTitleWidth())
|
|
1667
|
-
setDragging(tab.sessionID)
|
|
1668
|
-
}}
|
|
1669
|
-
>
|
|
1670
|
-
<TabPulse
|
|
1671
|
-
enabled={animations()}
|
|
1672
|
-
active={status().busy && !status().attention}
|
|
1673
|
-
promptPulse={status().promptPulse}
|
|
1674
|
-
complete={status().complete && !status().attention}
|
|
1675
|
-
glow={glows()}
|
|
1676
|
-
color={pulseColor()}
|
|
1677
|
-
glowColor={glowColor()}
|
|
1678
|
-
flashColor={flashColor()}
|
|
1679
|
-
completionColor={unreadColor()}
|
|
1680
|
-
backgroundColor={background()}
|
|
1681
|
-
onLevel={setSweepLevel}
|
|
1682
|
-
/>
|
|
1683
|
-
<box zIndex={1} width="100%" flexDirection="row">
|
|
1684
|
-
<TabIndicator
|
|
1685
|
-
status={status()}
|
|
1686
|
-
label={tab === NEW_SESSION_TAB ? "+" : sessionTabNumberLabel(tabNumber() - 1)}
|
|
1687
|
-
width={numberWidth()}
|
|
1688
|
-
color={numberColor()}
|
|
1689
|
-
unreadColor={feedbackColor() ?? unreadColor()}
|
|
1690
|
-
backgroundColor={background()}
|
|
1691
|
-
flashColor={theme.text.base}
|
|
1692
|
-
animations={animations()}
|
|
1693
|
-
numbers={props.numbers}
|
|
1694
|
-
spinner={props.spinner}
|
|
1695
|
-
unreadMarker={props.unreadMarker}
|
|
1696
|
-
attributes={bold()}
|
|
1697
|
-
/>
|
|
1698
|
-
<title_shimmer
|
|
1699
|
-
width={availableTitleWidth()}
|
|
1700
|
-
height={1}
|
|
1701
|
-
fg={foreground()}
|
|
1702
|
-
rename={{ pending: status().renaming, title: title() }}
|
|
1703
|
-
enabled={animations()}
|
|
1704
|
-
backdrop={background()}
|
|
1705
|
-
wrapMode="none"
|
|
1706
|
-
selectable={false}
|
|
1707
|
-
attributes={status().renaming && !animations() ? TextAttributes.DIM : bold()}
|
|
1708
|
-
>
|
|
1709
|
-
<Show when={scrolling() || glows() || titleFades()} fallback={visibleTitle()}>
|
|
1710
|
-
<Index each={visibleTitleParts()}>
|
|
1711
|
-
{(part, index) => (
|
|
1712
|
-
<span style={{ fg: characterColor(index, part().separator) }}>{part().value}</span>
|
|
1713
|
-
)}
|
|
1714
|
-
</Index>
|
|
1715
|
-
</Show>
|
|
1716
|
-
</title_shimmer>
|
|
1717
|
-
<text
|
|
1718
|
-
position="absolute"
|
|
1719
|
-
right={1}
|
|
1720
|
-
zIndex={2}
|
|
1721
|
-
width={1}
|
|
1722
|
-
fg={closeHovered() ? theme.text.base : closeColor()}
|
|
1723
|
-
selectable={false}
|
|
1724
|
-
onMouseOver={() => setCloseHovered(true)}
|
|
1725
|
-
onMouseOut={() => setCloseHovered(false)}
|
|
1726
|
-
onMouseDown={(event) => {
|
|
1727
|
-
if (event.button === RIGHT_MOUSE_BUTTON || hovered() !== tab.sessionID) return
|
|
1728
|
-
didDrag = false
|
|
1729
|
-
event.stopPropagation()
|
|
1730
|
-
}}
|
|
1731
|
-
onMouseUp={(event) => {
|
|
1732
|
-
if (event.button === RIGHT_MOUSE_BUTTON) return
|
|
1733
|
-
if (suppressClick) return
|
|
1734
|
-
// The close mark only renders while hovered; without motion events a click can
|
|
1735
|
-
// land here first, and must select the tab instead of closing it invisibly.
|
|
1736
|
-
if (hovered() !== tab.sessionID) return
|
|
1737
|
-
event.stopPropagation()
|
|
1738
|
-
holdCloseCell(tab.sessionID, event.x)
|
|
1739
|
-
tabs.close(tab === NEW_SESSION_TAB ? undefined : tab.sessionID)
|
|
1740
|
-
}}
|
|
1741
|
-
>
|
|
1742
|
-
{hovered() === tab.sessionID ? "✕" : ""}
|
|
1743
|
-
</text>
|
|
1744
|
-
</box>
|
|
1745
|
-
</box>
|
|
1746
|
-
)
|
|
1747
|
-
}}
|
|
1748
|
-
</For>
|
|
1749
|
-
<Show when={layout().after > 0}>
|
|
1750
|
-
<text width={sessionTabOverflowWidth(layout().after)} fg={theme.text.muted} selectable={false}>
|
|
1751
|
-
{" " + layout().after}›
|
|
1752
|
-
</text>
|
|
1753
|
-
</Show>
|
|
1754
|
-
<Show when={showPlus()}>
|
|
1755
|
-
<text
|
|
1756
|
-
width={ADD_TAB_WIDTH}
|
|
1757
|
-
fg={addHovered() ? theme.text.base : theme.text.muted}
|
|
1758
|
-
bg={addHovered() ? theme.background.action.primary.hovered : undefined}
|
|
1759
|
-
selectable={false}
|
|
1760
|
-
onMouseOver={() => setAddHovered(true)}
|
|
1761
|
-
onMouseOut={() => setAddHovered(false)}
|
|
1762
|
-
onMouseDown={(event) => {
|
|
1763
|
-
releaseCloseHold()
|
|
1764
|
-
didDrag = false
|
|
1765
|
-
setDragging(undefined)
|
|
1766
|
-
addPressed = event.button !== RIGHT_MOUSE_BUTTON
|
|
1767
|
-
if (addPressed) return
|
|
1768
|
-
setContextMenu({ x: event.x, y: event.y })
|
|
1769
|
-
event.preventDefault()
|
|
1770
|
-
event.stopPropagation()
|
|
1771
|
-
}}
|
|
1772
|
-
onMouseUp={(event) => {
|
|
1773
|
-
if (event.button === RIGHT_MOUSE_BUTTON) return
|
|
1774
|
-
if (suppressClick) return
|
|
1775
|
-
if (!addPressed) return
|
|
1776
|
-
addPressed = false
|
|
1777
|
-
tabs.add?.()
|
|
1778
|
-
}}
|
|
1779
|
-
onMouseDragEnd={() => (addPressed = false)}
|
|
1780
|
-
>
|
|
1781
|
-
{" + "}
|
|
1782
|
-
</text>
|
|
1783
|
-
</Show>
|
|
1784
|
-
<Show when={contextMenu()}>
|
|
1785
|
-
{(state) => <TabContextMenu state={state()} tabs={tabs} onClose={() => setContextMenu(undefined)} />}
|
|
1786
|
-
</Show>
|
|
1787
|
-
</box>
|
|
1788
|
-
)
|
|
1789
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
BoxRenderable,
|
|
3
|
+
CliRenderEvents,
|
|
4
|
+
RGBA,
|
|
5
|
+
ScrollBoxRenderable,
|
|
6
|
+
TextAttributes,
|
|
7
|
+
type MouseEvent,
|
|
8
|
+
type TimerHandle,
|
|
9
|
+
} from "@opentui/core"
|
|
10
|
+
import {
|
|
11
|
+
For,
|
|
12
|
+
Index,
|
|
13
|
+
Match,
|
|
14
|
+
Show,
|
|
15
|
+
Switch,
|
|
16
|
+
createComputed,
|
|
17
|
+
createEffect,
|
|
18
|
+
createMemo,
|
|
19
|
+
createSignal,
|
|
20
|
+
onCleanup,
|
|
21
|
+
untrack,
|
|
22
|
+
} from "solid-js"
|
|
23
|
+
import { onAnimationTick, Portal, useRenderer, useTerminalDimensions } from "@opentui/solid"
|
|
24
|
+
import { useConfig } from "../config"
|
|
25
|
+
import { useSessionTabs } from "../context/session-tabs"
|
|
26
|
+
import { useData } from "../context/data"
|
|
27
|
+
import { useClipboard } from "../context/clipboard"
|
|
28
|
+
import { useTheme } from "../context/theme"
|
|
29
|
+
import {
|
|
30
|
+
adaptiveSessionTabLayout,
|
|
31
|
+
moveSessionTab,
|
|
32
|
+
NEW_SESSION_TAB_TITLE,
|
|
33
|
+
sessionTabComplete,
|
|
34
|
+
sessionTabDetail,
|
|
35
|
+
sessionTabNumberLabel,
|
|
36
|
+
seedSessionTabMotion,
|
|
37
|
+
sessionTabOverflowWidth,
|
|
38
|
+
type SessionTab,
|
|
39
|
+
type SessionTabUnread,
|
|
40
|
+
} from "../context/session-tabs-model"
|
|
41
|
+
import { createAnimatable, spring, tween } from "../ui/animation"
|
|
42
|
+
import { Locale } from "../util/locale"
|
|
43
|
+
import { TabPulse, unreadGlowIntensity } from "./tab-pulse"
|
|
44
|
+
import { tint } from "../theme/color"
|
|
45
|
+
import { SESSION_SIDEBAR_WIDTH, SESSION_TABS_COMPACT_BREAKPOINT } from "../ui/layout"
|
|
46
|
+
import { projectName } from "../util/project"
|
|
47
|
+
import { stringWidth } from "../util/string-width"
|
|
48
|
+
import { marqueeCycleWidth, marqueeOverflows, marqueeTextParts } from "../util/marquee"
|
|
49
|
+
import { useDialog } from "../ui/dialog"
|
|
50
|
+
import { useToast } from "../ui/toast"
|
|
51
|
+
import { DialogSessionRename } from "./dialog-session-rename"
|
|
52
|
+
import { Keymap } from "../context/keymap"
|
|
53
|
+
import "./spinner-renderable"
|
|
54
|
+
import { SPINNER_FRAMES } from "./spinner-frames"
|
|
55
|
+
import { SessionTabsRailControls, SessionTabHalfRow } from "./session-tabs-rail"
|
|
56
|
+
import "./title-shimmer"
|
|
57
|
+
|
|
58
|
+
export const TAB_SPINNERS = {
|
|
59
|
+
dots: { frames: SPINNER_FRAMES, interval: 80 },
|
|
60
|
+
arcs: { frames: ["◜", "◝", "◞", "◟"], interval: 120 },
|
|
61
|
+
quadrants: { frames: ["◴", "◷", "◶", "◵"], interval: 120 },
|
|
62
|
+
line: { frames: ["|", "/", "-", "\\"], interval: 120 },
|
|
63
|
+
}
|
|
64
|
+
export type TabSpinner = keyof typeof TAB_SPINNERS
|
|
65
|
+
|
|
66
|
+
export const TAB_UNREAD_MARKERS = {
|
|
67
|
+
"small-dot": "•",
|
|
68
|
+
dot: "●",
|
|
69
|
+
square: "▪",
|
|
70
|
+
"large-square": "■",
|
|
71
|
+
}
|
|
72
|
+
export type TabUnreadMarker = keyof typeof TAB_UNREAD_MARKERS
|
|
73
|
+
|
|
74
|
+
// A long title fades out over its last cells instead of cutting hard.
|
|
75
|
+
const FADE_WIDTH = 4
|
|
76
|
+
// The add button renders as " + " at the end of the strip, so the tab layout leaves it room.
|
|
77
|
+
const ADD_TAB_WIDTH = 3
|
|
78
|
+
const MARQUEE_DELAY = 600
|
|
79
|
+
const MARQUEE_INTERVAL = 80
|
|
80
|
+
const CONTEXT_MENU_WIDTH = 20
|
|
81
|
+
const MIDDLE_MOUSE_BUTTON = 1
|
|
82
|
+
const RIGHT_MOUSE_BUTTON = 2
|
|
83
|
+
const MOUSE_CLOSE_HOLD_MS = 5_000
|
|
84
|
+
|
|
85
|
+
type MouseCloseHold = {
|
|
86
|
+
items: string[]
|
|
87
|
+
ids: string[]
|
|
88
|
+
widths: number[]
|
|
89
|
+
closed: string
|
|
90
|
+
target: string
|
|
91
|
+
x: number
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
type TabContextMenuState = {
|
|
95
|
+
x: number
|
|
96
|
+
y: number
|
|
97
|
+
sessionID?: string
|
|
98
|
+
title?: string
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
type ContextController = ReturnType<typeof useSessionTabs>
|
|
102
|
+
export type SessionTabsStatus = Omit<ReturnType<ContextController["status"]>, "unread"> & {
|
|
103
|
+
unread: SessionTabUnread | undefined
|
|
104
|
+
}
|
|
105
|
+
export const EMPTY_SESSION_TAB_STATUS: SessionTabsStatus = {
|
|
106
|
+
unread: undefined,
|
|
107
|
+
promptPulse: 0,
|
|
108
|
+
attention: false,
|
|
109
|
+
busy: false,
|
|
110
|
+
renaming: false,
|
|
111
|
+
}
|
|
112
|
+
export type SessionTabsController = Pick<ContextController, "tabs" | "current" | "select" | "close" | "move"> & {
|
|
113
|
+
newTab?: () => boolean
|
|
114
|
+
add?: () => void
|
|
115
|
+
recentlyClosed?: ContextController["recentlyClosed"]
|
|
116
|
+
reopen?: ContextController["reopen"]
|
|
117
|
+
detail?: (sessionID: string) => string | undefined
|
|
118
|
+
rename?: (sessionID: string) => void
|
|
119
|
+
search?: () => void
|
|
120
|
+
status(sessionID: string): SessionTabsStatus
|
|
121
|
+
}
|
|
122
|
+
const NEW_SESSION_TAB: SessionTab = { sessionID: "new", title: NEW_SESSION_TAB_TITLE }
|
|
123
|
+
const glowTextColor = (base: RGBA, glow: RGBA, index: number, width: number, level = 1) =>
|
|
124
|
+
tint(base, glow, 0.12 * unreadGlowIntensity(index, width) * level)
|
|
125
|
+
|
|
126
|
+
function tabFeedbackColor(status: SessionTabsStatus, theme: ReturnType<typeof useTheme>) {
|
|
127
|
+
if (status.attention) return theme.hue.accent[200]
|
|
128
|
+
if (status.unread === "error") return theme.text.feedback.error.base
|
|
129
|
+
return undefined
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function TabIndicator(props: {
|
|
133
|
+
status: SessionTabsStatus
|
|
134
|
+
label: string
|
|
135
|
+
idleLabel?: string
|
|
136
|
+
width: number
|
|
137
|
+
centered?: boolean
|
|
138
|
+
color: RGBA
|
|
139
|
+
unreadColor: RGBA
|
|
140
|
+
backgroundColor: RGBA
|
|
141
|
+
flashColor: RGBA
|
|
142
|
+
animations: boolean
|
|
143
|
+
numbers: boolean
|
|
144
|
+
selected?: boolean
|
|
145
|
+
spinner?: TabSpinner
|
|
146
|
+
unreadMarker?: TabUnreadMarker
|
|
147
|
+
attributes?: number
|
|
148
|
+
}) {
|
|
149
|
+
const runs = () => props.status.busy && !props.status.attention
|
|
150
|
+
const pending = createMemo(() => props.status.busy || Boolean(props.status.attention))
|
|
151
|
+
const unread = createMemo(() => Boolean(props.status.unread) && !pending())
|
|
152
|
+
const unreadColor = createMemo<RGBA>((previous) => (unread() ? props.unreadColor : previous), props.unreadColor)
|
|
153
|
+
const fade = createAnimatable(
|
|
154
|
+
{ opacity: unread() ? 1 : 0 },
|
|
155
|
+
{ enabled: () => props.animations, transition: tween({ duration: 0.18 }) },
|
|
156
|
+
)
|
|
157
|
+
createComputed(() => {
|
|
158
|
+
if (unread()) return fade.jump({ opacity: 1 })
|
|
159
|
+
if (pending()) return fade.jump({ opacity: 0 })
|
|
160
|
+
fade.animate({ opacity: 0 })
|
|
161
|
+
})
|
|
162
|
+
const fading = () => !props.status.unread && fade.value().opacity > 0
|
|
163
|
+
const color = () => {
|
|
164
|
+
if (props.numbers || props.selected) return props.color
|
|
165
|
+
if (unread()) return props.unreadColor
|
|
166
|
+
if (!fading()) return props.color
|
|
167
|
+
const opacity = fade.value().opacity
|
|
168
|
+
// Brighten during the first fifth, then dissolve into the tab background.
|
|
169
|
+
const flash = Math.max(0, 1 - Math.abs(opacity - 0.8) / 0.2)
|
|
170
|
+
return tint(props.backgroundColor, tint(unreadColor(), props.flashColor, flash * 0.3), Math.min(1, opacity / 0.8))
|
|
171
|
+
}
|
|
172
|
+
const spinner = () => TAB_SPINNERS[props.spinner ?? "dots"]
|
|
173
|
+
const label = () => {
|
|
174
|
+
if (props.numbers) return props.label
|
|
175
|
+
if (props.status.attention === "permission") return "!"
|
|
176
|
+
if (props.status.attention === "question") return "?"
|
|
177
|
+
if (runs()) return spinner().frames[0]
|
|
178
|
+
if (props.label === "+") return "+"
|
|
179
|
+
if (props.status.unread || fading()) return TAB_UNREAD_MARKERS[props.unreadMarker ?? "small-dot"]
|
|
180
|
+
return props.idleLabel ?? ""
|
|
181
|
+
}
|
|
182
|
+
return (
|
|
183
|
+
<box
|
|
184
|
+
width={props.width + (props.centered ? 0 : 1)}
|
|
185
|
+
height={props.centered ? 1 : undefined}
|
|
186
|
+
flexShrink={0}
|
|
187
|
+
flexDirection="row"
|
|
188
|
+
justifyContent={props.centered ? "center" : "flex-end"}
|
|
189
|
+
paddingRight={props.centered ? 0 : 1}
|
|
190
|
+
>
|
|
191
|
+
<Show
|
|
192
|
+
when={runs() && props.animations && !props.numbers}
|
|
193
|
+
fallback={
|
|
194
|
+
<text fg={color()} selectable={false} attributes={props.attributes}>
|
|
195
|
+
{label()}
|
|
196
|
+
</text>
|
|
197
|
+
}
|
|
198
|
+
>
|
|
199
|
+
<spinner frames={spinner().frames} interval={spinner().interval} color={props.color} />
|
|
200
|
+
</Show>
|
|
201
|
+
</box>
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function createGlowLevel(dimmed: () => boolean, animations: () => boolean) {
|
|
206
|
+
const motion = createAnimatable(
|
|
207
|
+
{ level: dimmed() ? 0.7 : 1 },
|
|
208
|
+
{ enabled: animations, transition: tween({ duration: 0.2 }) },
|
|
209
|
+
)
|
|
210
|
+
createEffect(() => motion.animate({ level: dimmed() ? 0.7 : 1 }))
|
|
211
|
+
return () => motion.value().level
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function createNumberIgnition(runs: () => boolean, prompt: () => number, animations: () => boolean) {
|
|
215
|
+
const ignition = createAnimatable({ level: 0 }, { enabled: animations, transition: tween({ duration: 0.7 }) })
|
|
216
|
+
let wasRunning = runs()
|
|
217
|
+
let promptPulse = prompt()
|
|
218
|
+
createEffect(() => {
|
|
219
|
+
const running = runs()
|
|
220
|
+
const nextPromptPulse = prompt()
|
|
221
|
+
if (running !== wasRunning || nextPromptPulse !== promptPulse) {
|
|
222
|
+
ignition.jump({ level: 0.85 })
|
|
223
|
+
ignition.animate({ level: 0 })
|
|
224
|
+
}
|
|
225
|
+
wasRunning = running
|
|
226
|
+
promptPulse = nextPromptPulse
|
|
227
|
+
})
|
|
228
|
+
return ignition
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function fadeTitleColor(color: RGBA, background: RGBA, index: number, length: number, leading: number) {
|
|
232
|
+
const fade = (position: number) => (position <= 0 ? 0 : 0.2 + 0.72 * ((position - 1) / Math.max(1, FADE_WIDTH - 1)))
|
|
233
|
+
const start = index < FADE_WIDTH ? FADE_WIDTH - index : 0
|
|
234
|
+
const end = index - (length - FADE_WIDTH) + 1
|
|
235
|
+
const opacity = Math.max(fade(start) * leading, fade(end))
|
|
236
|
+
return opacity === 0 ? color : tint(color, background, opacity)
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function heldSessionTabLayout(hold: MouseCloseHold, tabs: readonly SessionTab[]) {
|
|
240
|
+
const ids = tabs.map((tab) => tab.sessionID)
|
|
241
|
+
const expected = hold.items.filter((id) => id !== hold.closed)
|
|
242
|
+
const unchanged = ids.length === hold.items.length && ids.every((id, index) => id === hold.items[index])
|
|
243
|
+
const removed = ids.length === expected.length && ids.every((id, index) => id === expected[index])
|
|
244
|
+
if (!unchanged && !removed) return undefined
|
|
245
|
+
|
|
246
|
+
const visibleIDs = hold.ids.filter((id) => ids.includes(id))
|
|
247
|
+
if (removed && !visibleIDs.includes(hold.target)) {
|
|
248
|
+
visibleIDs.push(hold.target)
|
|
249
|
+
visibleIDs.sort((a, b) => ids.indexOf(a) - ids.indexOf(b))
|
|
250
|
+
}
|
|
251
|
+
const positions = visibleIDs.map((id) => ids.indexOf(id))
|
|
252
|
+
const start = positions[0]
|
|
253
|
+
if (start === undefined || positions.some((position, index) => position !== start + index)) return undefined
|
|
254
|
+
const visible = visibleIDs.flatMap((id) => tabs.find((tab) => tab.sessionID === id) ?? [])
|
|
255
|
+
if (visible.length !== visibleIDs.length) return undefined
|
|
256
|
+
|
|
257
|
+
const widths = visibleIDs.map((id) => hold.widths[hold.ids.indexOf(id)] ?? 1)
|
|
258
|
+
if (removed) {
|
|
259
|
+
const index = visibleIDs.indexOf(hold.target)
|
|
260
|
+
if (index === -1) return undefined
|
|
261
|
+
const leading = start > 0 ? sessionTabOverflowWidth(start) : 0
|
|
262
|
+
const preceding = widths.slice(0, index).reduce((sum, width) => sum + width, 0)
|
|
263
|
+
// The close glyph sits one cell in from the right edge: x = tab start + width - 2.
|
|
264
|
+
const width = hold.x - leading - preceding + 2
|
|
265
|
+
if (width < 1) return undefined
|
|
266
|
+
widths[index] = width
|
|
267
|
+
}
|
|
268
|
+
return {
|
|
269
|
+
tabs: visible,
|
|
270
|
+
widths,
|
|
271
|
+
before: start,
|
|
272
|
+
after: tabs.length - start - visible.length,
|
|
273
|
+
start,
|
|
274
|
+
total: widths.reduce((sum, width) => sum + width, 0),
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export function createMarquee(animations: () => boolean) {
|
|
279
|
+
const [offset, setOffset] = createSignal(0)
|
|
280
|
+
const [active, setActive] = createSignal<string>()
|
|
281
|
+
const [scrolling, setScrolling] = createSignal(false)
|
|
282
|
+
const leading = createAnimatable({ opacity: 0 }, { enabled: animations, transition: tween({ duration: 0.25 }) })
|
|
283
|
+
const clock = useRenderer().clock
|
|
284
|
+
let delay: TimerHandle | undefined
|
|
285
|
+
let cycleWidth = 0
|
|
286
|
+
|
|
287
|
+
const clear = () => {
|
|
288
|
+
if (delay !== undefined) clock.clearTimeout(delay)
|
|
289
|
+
delay = undefined
|
|
290
|
+
setScrolling(false)
|
|
291
|
+
}
|
|
292
|
+
// Not bound to a node's draw; reset() and unmount end the scroll.
|
|
293
|
+
onAnimationTick(
|
|
294
|
+
() => (scrolling() ? 1000 / MARQUEE_INTERVAL : undefined),
|
|
295
|
+
(_deltaTime, ticks) => {
|
|
296
|
+
if (offset() + ticks < cycleWidth) return setOffset(offset() + ticks)
|
|
297
|
+
clear()
|
|
298
|
+
leading.animate({ opacity: 0 })
|
|
299
|
+
setOffset(0)
|
|
300
|
+
},
|
|
301
|
+
)
|
|
302
|
+
const enter = (sessionID: string, title: string, width: number) => {
|
|
303
|
+
if (!marqueeOverflows(title, width)) {
|
|
304
|
+
reset()
|
|
305
|
+
return
|
|
306
|
+
}
|
|
307
|
+
if (active() === sessionID) return
|
|
308
|
+
clear()
|
|
309
|
+
cycleWidth = marqueeCycleWidth(title)
|
|
310
|
+
setActive(sessionID)
|
|
311
|
+
setOffset(0)
|
|
312
|
+
leading.jump({ opacity: 0 })
|
|
313
|
+
delay = clock.setTimeout(() => {
|
|
314
|
+
setOffset(1)
|
|
315
|
+
leading.animate({ opacity: 1 })
|
|
316
|
+
setScrolling(true)
|
|
317
|
+
}, MARQUEE_DELAY)
|
|
318
|
+
}
|
|
319
|
+
const leave = (sessionID: string) => {
|
|
320
|
+
if (active() !== sessionID) return
|
|
321
|
+
reset()
|
|
322
|
+
}
|
|
323
|
+
const reset = () => {
|
|
324
|
+
clear()
|
|
325
|
+
setActive(undefined)
|
|
326
|
+
setOffset(0)
|
|
327
|
+
leading.jump({ opacity: 0 })
|
|
328
|
+
}
|
|
329
|
+
onCleanup(clear)
|
|
330
|
+
|
|
331
|
+
return { offset, active, enter, leave, reset, leading: () => leading.value().opacity }
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export function createTabMarquee(animations: () => boolean) {
|
|
335
|
+
const [hovered, setHovered] = createSignal<string>()
|
|
336
|
+
const marquee = createMarquee(animations)
|
|
337
|
+
let hoverClear: ReturnType<typeof setTimeout> | undefined
|
|
338
|
+
|
|
339
|
+
const enter = (sessionID: string, title: string, width: number) => {
|
|
340
|
+
if (hoverClear) clearTimeout(hoverClear)
|
|
341
|
+
setHovered(sessionID)
|
|
342
|
+
marquee.enter(sessionID, title, width)
|
|
343
|
+
}
|
|
344
|
+
const leave = (sessionID: string) => {
|
|
345
|
+
if (hoverClear) clearTimeout(hoverClear)
|
|
346
|
+
hoverClear = setTimeout(() => {
|
|
347
|
+
if (hovered() !== sessionID) return
|
|
348
|
+
setHovered(undefined)
|
|
349
|
+
marquee.leave(sessionID)
|
|
350
|
+
})
|
|
351
|
+
}
|
|
352
|
+
const leaveHovered = () => {
|
|
353
|
+
const sessionID = hovered()
|
|
354
|
+
if (sessionID) leave(sessionID)
|
|
355
|
+
}
|
|
356
|
+
const reset = () => {
|
|
357
|
+
if (hoverClear) clearTimeout(hoverClear)
|
|
358
|
+
hoverClear = undefined
|
|
359
|
+
setHovered(undefined)
|
|
360
|
+
marquee.reset()
|
|
361
|
+
}
|
|
362
|
+
onCleanup(() => {
|
|
363
|
+
if (hoverClear) clearTimeout(hoverClear)
|
|
364
|
+
})
|
|
365
|
+
|
|
366
|
+
return { ...marquee, hovered, enter, leave, leaveHovered, reset }
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function TabContextMenu(props: { state: TabContextMenuState; tabs: SessionTabsController; onClose: () => void }) {
|
|
370
|
+
const dimensions = useTerminalDimensions()
|
|
371
|
+
const theme = useTheme()
|
|
372
|
+
const background = () => theme.background.raised.base
|
|
373
|
+
const actionHovered = () => theme.background.raised.high
|
|
374
|
+
const dialog = useDialog()
|
|
375
|
+
const clipboard = useClipboard()
|
|
376
|
+
const toast = useToast()
|
|
377
|
+
onCleanup(Keymap.use().mode.push("menu"))
|
|
378
|
+
Keymap.createLayer(() => ({
|
|
379
|
+
mode: "menu",
|
|
380
|
+
commands: [{ bind: "escape,ctrl+c", title: "Close tab menu", group: "Tabs", run: props.onClose }],
|
|
381
|
+
}))
|
|
382
|
+
const actions = createMemo<Array<{ title: string; run?: () => void }>>(() => {
|
|
383
|
+
const sessionID = props.state.sessionID
|
|
384
|
+
const title = props.state.title
|
|
385
|
+
const closed = (props.tabs.recentlyClosed?.() ?? []).slice(0, 10)
|
|
386
|
+
return [
|
|
387
|
+
...(sessionID && props.tabs.add ? [{ title: NEW_SESSION_TAB_TITLE, run: () => props.tabs.add?.() }] : []),
|
|
388
|
+
...(sessionID
|
|
389
|
+
? [
|
|
390
|
+
{
|
|
391
|
+
title: "Rename",
|
|
392
|
+
run: () =>
|
|
393
|
+
props.tabs.rename ? props.tabs.rename(sessionID) : DialogSessionRename.show(dialog, sessionID, title),
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
title: "Copy session ID",
|
|
397
|
+
run: () =>
|
|
398
|
+
void clipboard
|
|
399
|
+
.write(sessionID)
|
|
400
|
+
.then(() => toast.show({ message: "Session ID copied to clipboard", variant: "info" }))
|
|
401
|
+
.catch(toast.error),
|
|
402
|
+
},
|
|
403
|
+
{ title: "Close", run: () => props.tabs.close(sessionID) },
|
|
404
|
+
]
|
|
405
|
+
: []),
|
|
406
|
+
...(!sessionID && props.tabs.reopen
|
|
407
|
+
? [
|
|
408
|
+
{ title: "Recently closed tabs" },
|
|
409
|
+
...closed.map((tab) => ({
|
|
410
|
+
title: tab.title || "Untitled session",
|
|
411
|
+
run: () => props.tabs.reopen?.(tab.sessionID),
|
|
412
|
+
})),
|
|
413
|
+
...(closed.length === 0 ? [{ title: "No recently closed tabs" }] : []),
|
|
414
|
+
]
|
|
415
|
+
: []),
|
|
416
|
+
]
|
|
417
|
+
})
|
|
418
|
+
const [selected, setSelected] = createSignal<number>()
|
|
419
|
+
const width = () =>
|
|
420
|
+
Math.min(
|
|
421
|
+
dimensions().width,
|
|
422
|
+
Math.max(CONTEXT_MENU_WIDTH, ...actions().map((action) => Math.min(50, stringWidth(action.title) + 2))),
|
|
423
|
+
)
|
|
424
|
+
const height = () => Math.min(actions().length, dimensions().height)
|
|
425
|
+
const top = () => Math.max(0, Math.min(props.state.y + 1, dimensions().height - height()))
|
|
426
|
+
const left = () => Math.max(0, Math.min(props.state.x, dimensions().width - width()))
|
|
427
|
+
const run = (index: number) => {
|
|
428
|
+
const action = actions()[index]
|
|
429
|
+
if (!action?.run) return
|
|
430
|
+
props.onClose()
|
|
431
|
+
action.run()
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
return (
|
|
435
|
+
<Portal
|
|
436
|
+
ref={(container) => {
|
|
437
|
+
if (!(container instanceof BoxRenderable)) return
|
|
438
|
+
// Portal's wrapper otherwise follows the full-height app in root layout.
|
|
439
|
+
container.position = "absolute"
|
|
440
|
+
container.left = 0
|
|
441
|
+
container.top = 0
|
|
442
|
+
container.zIndex = 2500
|
|
443
|
+
}}
|
|
444
|
+
>
|
|
445
|
+
<box
|
|
446
|
+
position="absolute"
|
|
447
|
+
left={0}
|
|
448
|
+
top={0}
|
|
449
|
+
width={dimensions().width}
|
|
450
|
+
height={dimensions().height}
|
|
451
|
+
zIndex={2500}
|
|
452
|
+
onMouseDown={(event) => {
|
|
453
|
+
props.onClose()
|
|
454
|
+
event.preventDefault()
|
|
455
|
+
event.stopPropagation()
|
|
456
|
+
}}
|
|
457
|
+
>
|
|
458
|
+
<scrollbox
|
|
459
|
+
position="absolute"
|
|
460
|
+
left={left()}
|
|
461
|
+
top={top()}
|
|
462
|
+
height={height()}
|
|
463
|
+
width={width()}
|
|
464
|
+
scrollX={false}
|
|
465
|
+
scrollbarOptions={{ visible: false }}
|
|
466
|
+
backgroundColor={background()}
|
|
467
|
+
onMouseDown={(event) => {
|
|
468
|
+
if (event.button === RIGHT_MOUSE_BUTTON) props.onClose()
|
|
469
|
+
event.preventDefault()
|
|
470
|
+
event.stopPropagation()
|
|
471
|
+
}}
|
|
472
|
+
>
|
|
473
|
+
<For each={actions()}>
|
|
474
|
+
{(action, index) => (
|
|
475
|
+
<box
|
|
476
|
+
width="100%"
|
|
477
|
+
paddingLeft={1}
|
|
478
|
+
paddingRight={1}
|
|
479
|
+
height={1}
|
|
480
|
+
flexShrink={0}
|
|
481
|
+
backgroundColor={action.run && selected() === index() ? actionHovered() : undefined}
|
|
482
|
+
onMouseOver={() => setSelected(action.run ? index() : undefined)}
|
|
483
|
+
onMouseOut={() => setSelected(undefined)}
|
|
484
|
+
onMouseUp={(event) => {
|
|
485
|
+
event.preventDefault()
|
|
486
|
+
event.stopPropagation()
|
|
487
|
+
if (event.button === RIGHT_MOUSE_BUTTON) return
|
|
488
|
+
run(index())
|
|
489
|
+
}}
|
|
490
|
+
>
|
|
491
|
+
<text fg={action.run ? theme.text.base : theme.text.muted} selectable={false} truncate>
|
|
492
|
+
{action.title}
|
|
493
|
+
</text>
|
|
494
|
+
</box>
|
|
495
|
+
)}
|
|
496
|
+
</For>
|
|
497
|
+
</scrollbox>
|
|
498
|
+
</box>
|
|
499
|
+
</Portal>
|
|
500
|
+
)
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
export function SessionTabs(
|
|
504
|
+
props: {
|
|
505
|
+
controller?: SessionTabsController
|
|
506
|
+
animations?: boolean
|
|
507
|
+
spinner?: TabSpinner
|
|
508
|
+
unreadMarker?: TabUnreadMarker
|
|
509
|
+
indicators?: "status" | "numbers"
|
|
510
|
+
orientation?: "horizontal" | "vertical"
|
|
511
|
+
width?: number
|
|
512
|
+
} = {},
|
|
513
|
+
) {
|
|
514
|
+
const config = useConfig().data
|
|
515
|
+
|
|
516
|
+
return (
|
|
517
|
+
<Switch>
|
|
518
|
+
<Match when={props.orientation === "vertical"}>
|
|
519
|
+
<VerticalSessionTabs
|
|
520
|
+
controller={props.controller}
|
|
521
|
+
animations={props.animations}
|
|
522
|
+
spinner={props.spinner}
|
|
523
|
+
unreadMarker={props.unreadMarker}
|
|
524
|
+
numbers={(props.indicators ?? config.tabs.indicators) === "numbers"}
|
|
525
|
+
width={props.width}
|
|
526
|
+
/>
|
|
527
|
+
</Match>
|
|
528
|
+
<Match when={true}>
|
|
529
|
+
<HorizontalSessionTabs
|
|
530
|
+
controller={props.controller}
|
|
531
|
+
animations={props.animations}
|
|
532
|
+
spinner={props.spinner}
|
|
533
|
+
unreadMarker={props.unreadMarker}
|
|
534
|
+
numbers={(props.indicators ?? config.tabs.indicators) === "numbers"}
|
|
535
|
+
/>
|
|
536
|
+
</Match>
|
|
537
|
+
</Switch>
|
|
538
|
+
)
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
function VerticalSessionTabs(props: {
|
|
542
|
+
controller?: SessionTabsController
|
|
543
|
+
animations?: boolean
|
|
544
|
+
numbers: boolean
|
|
545
|
+
spinner?: TabSpinner
|
|
546
|
+
unreadMarker?: TabUnreadMarker
|
|
547
|
+
width?: number
|
|
548
|
+
}) {
|
|
549
|
+
const tabs: SessionTabsController = props.controller ?? useSessionTabs()
|
|
550
|
+
const data = props.controller ? undefined : useData()
|
|
551
|
+
const dimensions = useTerminalDimensions()
|
|
552
|
+
const renderer = useRenderer()
|
|
553
|
+
const theme = useTheme()
|
|
554
|
+
const background = () => theme.background.raised.base
|
|
555
|
+
const actionSelected = () => theme.background.action.primary.selected
|
|
556
|
+
const actionHovered = () => theme.background.raised.high
|
|
557
|
+
const base = useTheme()
|
|
558
|
+
const config = useConfig().data
|
|
559
|
+
const animations = () => props.animations ?? config.animations ?? true
|
|
560
|
+
const width = () => props.width ?? SESSION_SIDEBAR_WIDTH
|
|
561
|
+
const compact = createMemo(() => width() < SESSION_TABS_COMPACT_BREAKPOINT)
|
|
562
|
+
const tooltipWidth = () => Math.min(54, dimensions().width - width())
|
|
563
|
+
const stride = () => (compact() ? 2 : 3)
|
|
564
|
+
const unreadColor = () => theme.hue.accent[200]
|
|
565
|
+
const activeNumber = () => theme.hue.interactive[200]
|
|
566
|
+
const idleNumber = () => tint(theme.text.formfield.base, background(), 0.55)
|
|
567
|
+
const separatorUpperPulseColor = createMemo(() => tint(background(), theme.text.base, 0.04))
|
|
568
|
+
const separatorLowerPulseColor = createMemo(() => tint(background(), theme.text.base, 0.05))
|
|
569
|
+
const [addHovered, setAddHovered] = createSignal(false)
|
|
570
|
+
const marquee = createTabMarquee(animations)
|
|
571
|
+
const hovered = marquee.hovered
|
|
572
|
+
createEffect(() => {
|
|
573
|
+
compact()
|
|
574
|
+
untrack(marquee.reset)
|
|
575
|
+
})
|
|
576
|
+
const [hoverY, setHoverY] = createSignal(0)
|
|
577
|
+
const [scrollTop, setScrollTop] = createSignal(0)
|
|
578
|
+
const detail = (sessionID: string) => {
|
|
579
|
+
const fixture = tabs.detail?.(sessionID)
|
|
580
|
+
if (fixture !== undefined) return fixture
|
|
581
|
+
const session = data?.session.get(sessionID)
|
|
582
|
+
const project = session ? data?.project.get(session.projectID) : undefined
|
|
583
|
+
const vcs = session ? data?.location.vcs.info(session.location) : undefined
|
|
584
|
+
const location = session ? data?.location.info(session.location) : undefined
|
|
585
|
+
return sessionTabDetail(
|
|
586
|
+
projectName(project, session?.location.directory) ?? "",
|
|
587
|
+
vcs?.branch.current,
|
|
588
|
+
vcs?.branch.default,
|
|
589
|
+
!!location && location.project.directory !== location.project.canonical,
|
|
590
|
+
)
|
|
591
|
+
}
|
|
592
|
+
// OpenTUI captures the first drag target, which may differ from the tab pressed on a fast move.
|
|
593
|
+
const [dragging, setDragging] = createSignal<string>()
|
|
594
|
+
const [preview, setPreview] = createSignal<{ sessionID: string; index: number }>()
|
|
595
|
+
const [contextMenu, setContextMenu] = createSignal<TabContextMenuState>()
|
|
596
|
+
const newTab = () => tabs.newTab?.() ?? false
|
|
597
|
+
const activeID = createMemo(() => (newTab() ? undefined : tabs.current()))
|
|
598
|
+
const ordered = createMemo(() => {
|
|
599
|
+
const pending = preview()
|
|
600
|
+
if (!pending) return tabs.tabs()
|
|
601
|
+
return moveSessionTab(tabs.tabs(), pending.sessionID, pending.index)
|
|
602
|
+
})
|
|
603
|
+
const items = ordered
|
|
604
|
+
const highlightColor = createMemo(() => tint(background(), actionHovered(), actionHovered().a))
|
|
605
|
+
const highlighted = (sessionID: string | undefined) =>
|
|
606
|
+
sessionID !== undefined && (activeID() === sessionID || hovered() === sessionID || dragging() === sessionID)
|
|
607
|
+
const addHighlighted = () => newTab() || addHovered()
|
|
608
|
+
const belowHighlighted = createMemo(() => {
|
|
609
|
+
const tab = items()[Math.floor(scrollTop() / stride())]
|
|
610
|
+
return tab ? highlighted(tab.sessionID) : addHighlighted()
|
|
611
|
+
})
|
|
612
|
+
createEffect(() => {
|
|
613
|
+
const active = marquee.active()
|
|
614
|
+
if (active && !items().some((tab) => tab.sessionID === active)) marquee.reset()
|
|
615
|
+
})
|
|
616
|
+
const statuses = createMemo(
|
|
617
|
+
() =>
|
|
618
|
+
new Map(
|
|
619
|
+
items().map((tab) => {
|
|
620
|
+
const status = tabs.status(tab.sessionID)
|
|
621
|
+
return [
|
|
622
|
+
tab.sessionID,
|
|
623
|
+
{
|
|
624
|
+
...status,
|
|
625
|
+
complete: sessionTabComplete(status.unread, status.busy),
|
|
626
|
+
runs: status.busy && !status.attention,
|
|
627
|
+
glows: Boolean(
|
|
628
|
+
status.attention || (tab.sessionID !== activeID() && !status.busy && status.unread !== undefined),
|
|
629
|
+
),
|
|
630
|
+
},
|
|
631
|
+
] as const
|
|
632
|
+
}),
|
|
633
|
+
),
|
|
634
|
+
)
|
|
635
|
+
const itemStatus = (tab: SessionTab) => statuses().get(tab.sessionID)!
|
|
636
|
+
let rail: { screenX: number; screenY: number } | undefined
|
|
637
|
+
let scroll: ScrollBoxRenderable | undefined
|
|
638
|
+
const updateScroll = () => setScrollTop(scroll?.scrollTop ?? 0)
|
|
639
|
+
onCleanup(() => scroll?.verticalScrollBar.off("change", updateScroll))
|
|
640
|
+
let didDrag = false
|
|
641
|
+
let addPressed = false
|
|
642
|
+
// A captured drag ends with a synthetic up on its drop target; do not turn that into a click.
|
|
643
|
+
let suppressClick = false
|
|
644
|
+
|
|
645
|
+
createEffect(() => {
|
|
646
|
+
const pending = preview()
|
|
647
|
+
if (!pending || dragging()) return
|
|
648
|
+
const index = tabs.tabs().findIndex((tab) => tab.sessionID === pending.sessionID)
|
|
649
|
+
if (index === -1 || index === Math.min(pending.index, tabs.tabs().length - 1)) setPreview(undefined)
|
|
650
|
+
})
|
|
651
|
+
|
|
652
|
+
createEffect(() => {
|
|
653
|
+
if (!scroll) return
|
|
654
|
+
dimensions()
|
|
655
|
+
const index = newTab() ? items().length : items().findIndex((tab) => tab.sessionID === activeID())
|
|
656
|
+
if (index === -1) return
|
|
657
|
+
const top = index * stride()
|
|
658
|
+
const height = compact() ? 3 : newTab() ? 1 : 2
|
|
659
|
+
// Scroll after layout: newly opened tabs do not contribute to the scroll range yet.
|
|
660
|
+
const reveal = () => {
|
|
661
|
+
if (!scroll) return
|
|
662
|
+
if (top < scroll.scrollTop) return scroll.scrollTo(top)
|
|
663
|
+
if (top + height > scroll.scrollTop + scroll.viewport.height) {
|
|
664
|
+
scroll.scrollTo(top + height - scroll.viewport.height)
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
renderer.once(CliRenderEvents.FRAME, reveal)
|
|
668
|
+
renderer.requestRender()
|
|
669
|
+
onCleanup(() => renderer.off(CliRenderEvents.FRAME, reveal))
|
|
670
|
+
})
|
|
671
|
+
|
|
672
|
+
const release = () => {
|
|
673
|
+
const source = dragging()
|
|
674
|
+
if (!source) return
|
|
675
|
+
if (didDrag) suppressClick = true
|
|
676
|
+
setDragging(undefined)
|
|
677
|
+
const pending = preview()
|
|
678
|
+
if (pending?.sessionID === source) tabs.move(pending.sessionID, pending.index)
|
|
679
|
+
tabs.select(source)
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
const drag = (event: MouseEvent) => {
|
|
683
|
+
if (!rail) return
|
|
684
|
+
const source = dragging()
|
|
685
|
+
if (!source) return
|
|
686
|
+
didDrag = true
|
|
687
|
+
const target = Math.max(
|
|
688
|
+
0,
|
|
689
|
+
Math.min(
|
|
690
|
+
tabs.tabs().length - 1,
|
|
691
|
+
Math.floor(
|
|
692
|
+
(event.y - (scroll?.viewport.screenY ?? rail.screenY + 1) - (compact() ? 1 : 0) + (scroll?.scrollTop ?? 0)) /
|
|
693
|
+
stride(),
|
|
694
|
+
),
|
|
695
|
+
),
|
|
696
|
+
)
|
|
697
|
+
const sourceIndex = items().findIndex((item) => item.sessionID === source)
|
|
698
|
+
if (target !== sourceIndex && preview()?.index !== target) setPreview({ sessionID: source, index: target })
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
return (
|
|
702
|
+
<box
|
|
703
|
+
ref={(element) => (rail = element)}
|
|
704
|
+
width={width()}
|
|
705
|
+
height="100%"
|
|
706
|
+
flexShrink={0}
|
|
707
|
+
flexDirection="column"
|
|
708
|
+
position="relative"
|
|
709
|
+
paddingTop={1}
|
|
710
|
+
backgroundColor={background()}
|
|
711
|
+
onMouseOut={marquee.leaveHovered}
|
|
712
|
+
onMouseUp={(event) => {
|
|
713
|
+
if (event.button === RIGHT_MOUSE_BUTTON) return
|
|
714
|
+
release()
|
|
715
|
+
if (!didDrag) return
|
|
716
|
+
didDrag = false
|
|
717
|
+
queueMicrotask(() => (suppressClick = false))
|
|
718
|
+
}}
|
|
719
|
+
onMouseDrag={drag}
|
|
720
|
+
onMouseDragEnd={release}
|
|
721
|
+
>
|
|
722
|
+
<Show when={compact()}>
|
|
723
|
+
<SessionTabsRailControls width={width()} tabs={tabs} belowHighlighted={belowHighlighted()} />
|
|
724
|
+
</Show>
|
|
725
|
+
<scrollbox
|
|
726
|
+
ref={(element) => {
|
|
727
|
+
scroll = element
|
|
728
|
+
scroll.verticalScrollBar.on("change", updateScroll)
|
|
729
|
+
updateScroll()
|
|
730
|
+
}}
|
|
731
|
+
flexGrow={1}
|
|
732
|
+
minHeight={0}
|
|
733
|
+
backgroundColor={background()}
|
|
734
|
+
scrollbarOptions={{ visible: false }}
|
|
735
|
+
>
|
|
736
|
+
<box flexShrink={0} flexDirection="column" gap={1} paddingY={compact() ? 1 : 0}>
|
|
737
|
+
<For each={items()}>
|
|
738
|
+
{(tab, index) => {
|
|
739
|
+
const selected = () => activeID() === tab.sessionID
|
|
740
|
+
const status = createMemo(() => itemStatus(tab))
|
|
741
|
+
const [sweepLevel, setSweepLevel] = createSignal(0)
|
|
742
|
+
const [closeHovered, setCloseHovered] = createSignal(false)
|
|
743
|
+
const session = createMemo(() => data?.session.get(tab.sessionID))
|
|
744
|
+
const numberWidth = () => Math.max(2, String(items().length).length)
|
|
745
|
+
const prefixWidth = () => numberWidth() + 1
|
|
746
|
+
const restingTitleWidth = () => Math.max(1, width() - prefixWidth() - 1)
|
|
747
|
+
const hoveredTitleWidth = () => Math.max(1, restingTitleWidth() - 1)
|
|
748
|
+
const titleWidth = () => (hovered() === tab.sessionID ? hoveredTitleWidth() : restingTitleWidth())
|
|
749
|
+
const title = () => (props.controller ? undefined : session()?.title) ?? tab.title ?? "Untitled session"
|
|
750
|
+
const scrolling = () => marquee.active() === tab.sessionID
|
|
751
|
+
const visibleTitleParts = createMemo(() =>
|
|
752
|
+
scrolling()
|
|
753
|
+
? marqueeTextParts(title(), titleWidth(), marquee.offset())
|
|
754
|
+
: Locale.graphemes(Locale.takeWidth(title(), titleWidth())).map((value) => ({
|
|
755
|
+
value,
|
|
756
|
+
separator: false,
|
|
757
|
+
})),
|
|
758
|
+
)
|
|
759
|
+
const visibleTitle = createMemo(() =>
|
|
760
|
+
visibleTitleParts()
|
|
761
|
+
.map((part) => part.value)
|
|
762
|
+
.join(""),
|
|
763
|
+
)
|
|
764
|
+
const titleFades = createMemo(() => marqueeOverflows(title(), titleWidth()) && titleWidth() > FADE_WIDTH)
|
|
765
|
+
const tabDetail = createMemo(() => detail(tab.sessionID))
|
|
766
|
+
const visibleDetail = createMemo(() => Locale.takeWidth(tabDetail(), titleWidth()))
|
|
767
|
+
const visibleDetailParts = createMemo(() => Locale.graphemes(visibleDetail()))
|
|
768
|
+
const detailFades = createMemo(
|
|
769
|
+
() => marqueeOverflows(tabDetail(), titleWidth()) && titleWidth() > FADE_WIDTH,
|
|
770
|
+
)
|
|
771
|
+
const tabBackground = createMemo(() => {
|
|
772
|
+
if (selected() && !compact()) return actionSelected()
|
|
773
|
+
if ((compact() && selected()) || hovered() === tab.sessionID || dragging() === tab.sessionID)
|
|
774
|
+
return actionHovered()
|
|
775
|
+
return background()
|
|
776
|
+
})
|
|
777
|
+
const pulseBackground = createMemo(() => tint(background(), tabBackground(), tabBackground().a))
|
|
778
|
+
const runs = () => status().runs
|
|
779
|
+
const numberIgnition = createNumberIgnition(runs, () => status().promptPulse, animations)
|
|
780
|
+
const numberColor = () => {
|
|
781
|
+
const base =
|
|
782
|
+
hovered() === tab.sessionID && !selected()
|
|
783
|
+
? foreground()
|
|
784
|
+
: tint(idleNumber(), tint(theme.text.base, pulseBackground(), 0.25), Number(selected()))
|
|
785
|
+
const color = tabFeedbackColor(status(), theme) ?? tint(base, glowHue(), numberGlow.value().level)
|
|
786
|
+
const runningColor = runs() ? activeNumber() : color
|
|
787
|
+
return sweepLevel() === 0
|
|
788
|
+
? tint(runningColor, theme.text.base, numberIgnition.value().level)
|
|
789
|
+
: tint(runningColor, theme.text.base, Math.max(numberIgnition.value().level, 0.35 * sweepLevel()))
|
|
790
|
+
}
|
|
791
|
+
const foreground = () => {
|
|
792
|
+
if (hovered() === tab.sessionID) return theme.text.base
|
|
793
|
+
return selected() ? theme.text.base : theme.text.muted
|
|
794
|
+
}
|
|
795
|
+
const complete = () => status().complete
|
|
796
|
+
// Latched so a resolving glow fades out in the hue it lit with instead of snapping to the unread color.
|
|
797
|
+
let lastGlowHue: RGBA | undefined
|
|
798
|
+
const glowHue = () => {
|
|
799
|
+
const feedback = tabFeedbackColor(status(), theme)
|
|
800
|
+
if (feedback) return (lastGlowHue = feedback)
|
|
801
|
+
if (status().unread !== undefined) return (lastGlowHue = unreadColor())
|
|
802
|
+
return lastGlowHue ?? unreadColor()
|
|
803
|
+
}
|
|
804
|
+
const pulseColor = createMemo(() => tint(pulseBackground(), theme.text.base, 0.25))
|
|
805
|
+
const flashColor = createMemo(() => tint(pulseBackground(), theme.text.base, 0.7))
|
|
806
|
+
const glowLevel = createGlowLevel(() => selected() && Boolean(status().attention), animations)
|
|
807
|
+
const glowColor = createMemo(() => tint(pulseBackground(), glowHue(), 0.45 * glowLevel()))
|
|
808
|
+
const detailPulseColor = createMemo(() => tint(pulseBackground(), theme.text.base, 0.13))
|
|
809
|
+
const detailFlashColor = createMemo(() => tint(pulseBackground(), theme.text.base, 0.42))
|
|
810
|
+
const detailGlowColor = createMemo(() => tint(pulseBackground(), glowHue(), 0.25 * glowLevel()))
|
|
811
|
+
const detailColor = createMemo(() => tint(theme.text.muted, pulseBackground(), 0.35))
|
|
812
|
+
const detailTextColor = (index: number) =>
|
|
813
|
+
detailFades()
|
|
814
|
+
? fadeTitleColor(detailColor(), pulseBackground(), index, visibleDetailParts().length, 0)
|
|
815
|
+
: detailColor()
|
|
816
|
+
const glows = () => status().glows
|
|
817
|
+
// Text tints ride an eased level so they diffuse away with the background glow instead of snapping.
|
|
818
|
+
const titleGlow = createAnimatable(
|
|
819
|
+
{ level: 0 },
|
|
820
|
+
{ enabled: animations, transition: tween({ duration: 0.4 }) },
|
|
821
|
+
)
|
|
822
|
+
createEffect(() => titleGlow.animate({ level: glows() ? 1 : 0 }))
|
|
823
|
+
const numberGlow = createAnimatable(
|
|
824
|
+
{ level: 0 },
|
|
825
|
+
{ enabled: animations, transition: tween({ duration: 0.4 }) },
|
|
826
|
+
)
|
|
827
|
+
createEffect(() =>
|
|
828
|
+
numberGlow.animate({
|
|
829
|
+
level: status().attention || status().unread === "error" || complete() ? 1 : 0,
|
|
830
|
+
}),
|
|
831
|
+
)
|
|
832
|
+
const previous = createMemo(() => items()[index() - 1])
|
|
833
|
+
const previousStatus = createMemo(() => {
|
|
834
|
+
const tab = previous()
|
|
835
|
+
return tab
|
|
836
|
+
? itemStatus(tab)
|
|
837
|
+
: { ...EMPTY_SESSION_TAB_STATUS, complete: false, runs: false, glows: false }
|
|
838
|
+
})
|
|
839
|
+
const previousGlows = () => previousStatus().glows
|
|
840
|
+
const previousRuns = () => previousStatus().runs
|
|
841
|
+
const previousGlowLevel = createGlowLevel(
|
|
842
|
+
() => previous()?.sessionID === activeID() && Boolean(previousStatus().attention),
|
|
843
|
+
animations,
|
|
844
|
+
)
|
|
845
|
+
let lastPreviousGlowHue: RGBA | undefined
|
|
846
|
+
const previousGlowHue = () => {
|
|
847
|
+
const feedback = tabFeedbackColor(previousStatus(), theme)
|
|
848
|
+
if (feedback) return (lastPreviousGlowHue = feedback)
|
|
849
|
+
if (previousStatus().unread !== undefined) return (lastPreviousGlowHue = unreadColor())
|
|
850
|
+
return lastPreviousGlowHue ?? unreadColor()
|
|
851
|
+
}
|
|
852
|
+
const separatorUpperColor = createMemo(() =>
|
|
853
|
+
tint(background(), previousGlowHue(), 0.1 * previousGlowLevel()),
|
|
854
|
+
)
|
|
855
|
+
const separatorLowerColor = createMemo(() => tint(background(), glowHue(), 0.12 * glowLevel()))
|
|
856
|
+
const titleColor = (index: number, separator: boolean) => {
|
|
857
|
+
const level = titleGlow.value().level
|
|
858
|
+
const color =
|
|
859
|
+
level === 0
|
|
860
|
+
? foreground()
|
|
861
|
+
: glowTextColor(foreground(), glowColor(), 1 + numberWidth() + index, width(), level)
|
|
862
|
+
const faded = titleFades()
|
|
863
|
+
? fadeTitleColor(
|
|
864
|
+
color,
|
|
865
|
+
pulseBackground(),
|
|
866
|
+
index,
|
|
867
|
+
visibleTitleParts().length,
|
|
868
|
+
scrolling() ? marquee.leading() : 0,
|
|
869
|
+
)
|
|
870
|
+
: color
|
|
871
|
+
return separator ? tint(faded, pulseBackground(), 0.55) : faded
|
|
872
|
+
}
|
|
873
|
+
return (
|
|
874
|
+
<box
|
|
875
|
+
height={compact() ? 1 : 2}
|
|
876
|
+
width="100%"
|
|
877
|
+
position="relative"
|
|
878
|
+
flexDirection="column"
|
|
879
|
+
backgroundColor={tabBackground()}
|
|
880
|
+
onMouseOver={(event) => {
|
|
881
|
+
setHoverY(event.y)
|
|
882
|
+
marquee.enter(tab.sessionID, title(), compact() ? Infinity : hoveredTitleWidth())
|
|
883
|
+
}}
|
|
884
|
+
onMouseOut={() => marquee.leave(tab.sessionID)}
|
|
885
|
+
onMouseDown={(event) => {
|
|
886
|
+
if (event.button === MIDDLE_MOUSE_BUTTON) {
|
|
887
|
+
didDrag = false
|
|
888
|
+
setDragging(undefined)
|
|
889
|
+
tabs.close(tab.sessionID)
|
|
890
|
+
event.preventDefault()
|
|
891
|
+
event.stopPropagation()
|
|
892
|
+
return
|
|
893
|
+
}
|
|
894
|
+
if (event.button === RIGHT_MOUSE_BUTTON) {
|
|
895
|
+
didDrag = false
|
|
896
|
+
setDragging(undefined)
|
|
897
|
+
if (!rail) return
|
|
898
|
+
setContextMenu({
|
|
899
|
+
x: event.x,
|
|
900
|
+
y: event.y,
|
|
901
|
+
sessionID: tab.sessionID,
|
|
902
|
+
title: tab.title,
|
|
903
|
+
})
|
|
904
|
+
event.preventDefault()
|
|
905
|
+
event.stopPropagation()
|
|
906
|
+
return
|
|
907
|
+
}
|
|
908
|
+
didDrag = false
|
|
909
|
+
marquee.enter(tab.sessionID, title(), compact() ? Infinity : hoveredTitleWidth())
|
|
910
|
+
setDragging(tab.sessionID)
|
|
911
|
+
}}
|
|
912
|
+
>
|
|
913
|
+
<Show when={compact()}>
|
|
914
|
+
<Show when={highlighted(tab.sessionID)}>
|
|
915
|
+
<SessionTabHalfRow
|
|
916
|
+
top={-1}
|
|
917
|
+
edge="top"
|
|
918
|
+
width={width()}
|
|
919
|
+
color={pulseBackground()}
|
|
920
|
+
background={highlighted(items()[index() - 1]?.sessionID) ? highlightColor() : background()}
|
|
921
|
+
/>
|
|
922
|
+
<SessionTabHalfRow
|
|
923
|
+
top={1}
|
|
924
|
+
edge="bottom"
|
|
925
|
+
width={width()}
|
|
926
|
+
color={pulseBackground()}
|
|
927
|
+
background={
|
|
928
|
+
(
|
|
929
|
+
index() === items().length - 1
|
|
930
|
+
? addHighlighted()
|
|
931
|
+
: highlighted(items()[index() + 1]?.sessionID)
|
|
932
|
+
)
|
|
933
|
+
? highlightColor()
|
|
934
|
+
: background()
|
|
935
|
+
}
|
|
936
|
+
/>
|
|
937
|
+
</Show>
|
|
938
|
+
<box height={1} flexDirection="row" justifyContent="center">
|
|
939
|
+
<TabIndicator
|
|
940
|
+
centered
|
|
941
|
+
selected={selected()}
|
|
942
|
+
width={width()}
|
|
943
|
+
status={status()}
|
|
944
|
+
label={sessionTabNumberLabel(index())}
|
|
945
|
+
idleLabel={Locale.graphemes(title().trimStart())[0] ?? "U"}
|
|
946
|
+
color={
|
|
947
|
+
selected()
|
|
948
|
+
? theme.text.base
|
|
949
|
+
: props.numbers
|
|
950
|
+
? numberColor()
|
|
951
|
+
: (tabFeedbackColor(status(), theme) ?? (runs() ? activeNumber() : foreground()))
|
|
952
|
+
}
|
|
953
|
+
unreadColor={tabFeedbackColor(status(), theme) ?? unreadColor()}
|
|
954
|
+
backgroundColor={pulseBackground()}
|
|
955
|
+
flashColor={theme.text.base}
|
|
956
|
+
animations={animations()}
|
|
957
|
+
numbers={props.numbers}
|
|
958
|
+
spinner={props.spinner}
|
|
959
|
+
unreadMarker={props.unreadMarker}
|
|
960
|
+
attributes={selected() ? TextAttributes.BOLD : undefined}
|
|
961
|
+
/>
|
|
962
|
+
</box>
|
|
963
|
+
</Show>
|
|
964
|
+
<Show when={!compact()}>
|
|
965
|
+
<TabPulse
|
|
966
|
+
top={-1}
|
|
967
|
+
edge="above"
|
|
968
|
+
enabled={animations()}
|
|
969
|
+
active={runs()}
|
|
970
|
+
outerActive={previousRuns()}
|
|
971
|
+
promptPulse={status().promptPulse}
|
|
972
|
+
outerPromptPulse={previousStatus().promptPulse}
|
|
973
|
+
complete={complete() && !status().attention}
|
|
974
|
+
outerComplete={previousStatus().complete && !previousStatus().attention}
|
|
975
|
+
glow={glows()}
|
|
976
|
+
outerGlow={previousGlows()}
|
|
977
|
+
color={separatorLowerPulseColor()}
|
|
978
|
+
outerColor={separatorUpperPulseColor()}
|
|
979
|
+
flashColor={tint(background(), theme.text.base, 0.22)}
|
|
980
|
+
outerFlashColor={tint(background(), theme.text.base, 0.18)}
|
|
981
|
+
flashTail={8}
|
|
982
|
+
glowColor={separatorLowerColor()}
|
|
983
|
+
outerGlowColor={separatorUpperColor()}
|
|
984
|
+
glowTail={8}
|
|
985
|
+
outerGlowTail={5}
|
|
986
|
+
completionColor={separatorLowerColor()}
|
|
987
|
+
outerCompletionColor={separatorUpperColor()}
|
|
988
|
+
backgroundColor={background()}
|
|
989
|
+
/>
|
|
990
|
+
<Show when={index() === items().length - 1}>
|
|
991
|
+
<TabPulse
|
|
992
|
+
top={2}
|
|
993
|
+
edge="below"
|
|
994
|
+
enabled={animations()}
|
|
995
|
+
active={runs()}
|
|
996
|
+
outerActive={false}
|
|
997
|
+
promptPulse={status().promptPulse}
|
|
998
|
+
outerPromptPulse={0}
|
|
999
|
+
complete={complete() && !status().attention}
|
|
1000
|
+
outerComplete={false}
|
|
1001
|
+
glow={glows()}
|
|
1002
|
+
outerGlow={false}
|
|
1003
|
+
color={tint(background(), theme.text.base, 0.04)}
|
|
1004
|
+
outerColor={tint(background(), theme.text.base, 0.006)}
|
|
1005
|
+
flashColor={tint(background(), theme.text.base, 0.18)}
|
|
1006
|
+
flashTail={8}
|
|
1007
|
+
glowColor={tint(background(), glowHue(), 0.1 * glowLevel())}
|
|
1008
|
+
outerGlowColor={background()}
|
|
1009
|
+
glowTail={8}
|
|
1010
|
+
outerGlowTail={5}
|
|
1011
|
+
completionColor={tint(background(), glowHue(), 0.1 * glowLevel())}
|
|
1012
|
+
outerCompletionColor={background()}
|
|
1013
|
+
backgroundColor={background()}
|
|
1014
|
+
/>
|
|
1015
|
+
</Show>
|
|
1016
|
+
<box height={1} width="100%" flexDirection="row" position="relative">
|
|
1017
|
+
<TabPulse
|
|
1018
|
+
enabled={animations()}
|
|
1019
|
+
active={runs()}
|
|
1020
|
+
promptPulse={status().promptPulse}
|
|
1021
|
+
complete={complete() && !status().attention}
|
|
1022
|
+
glow={glows()}
|
|
1023
|
+
color={pulseColor()}
|
|
1024
|
+
glowColor={glowColor()}
|
|
1025
|
+
flashColor={flashColor()}
|
|
1026
|
+
flashTail={8}
|
|
1027
|
+
completionColor={glowColor()}
|
|
1028
|
+
backgroundColor={pulseBackground()}
|
|
1029
|
+
onLevel={setSweepLevel}
|
|
1030
|
+
/>
|
|
1031
|
+
<box zIndex={1} width="100%" flexDirection="row" paddingRight={1}>
|
|
1032
|
+
<TabIndicator
|
|
1033
|
+
status={status()}
|
|
1034
|
+
label={sessionTabNumberLabel(index())}
|
|
1035
|
+
width={numberWidth()}
|
|
1036
|
+
color={numberColor()}
|
|
1037
|
+
unreadColor={tabFeedbackColor(status(), theme) ?? unreadColor()}
|
|
1038
|
+
backgroundColor={pulseBackground()}
|
|
1039
|
+
flashColor={theme.text.base}
|
|
1040
|
+
animations={animations()}
|
|
1041
|
+
numbers={props.numbers}
|
|
1042
|
+
spinner={props.spinner}
|
|
1043
|
+
unreadMarker={props.unreadMarker}
|
|
1044
|
+
attributes={selected() ? TextAttributes.BOLD : undefined}
|
|
1045
|
+
/>
|
|
1046
|
+
<title_shimmer
|
|
1047
|
+
width={titleWidth()}
|
|
1048
|
+
height={1}
|
|
1049
|
+
fg={foreground()}
|
|
1050
|
+
rename={{ pending: status().renaming, title: title() }}
|
|
1051
|
+
enabled={animations()}
|
|
1052
|
+
backdrop={pulseBackground()}
|
|
1053
|
+
wrapMode="none"
|
|
1054
|
+
selectable={false}
|
|
1055
|
+
attributes={
|
|
1056
|
+
status().renaming && !animations()
|
|
1057
|
+
? TextAttributes.DIM
|
|
1058
|
+
: selected()
|
|
1059
|
+
? TextAttributes.BOLD
|
|
1060
|
+
: undefined
|
|
1061
|
+
}
|
|
1062
|
+
>
|
|
1063
|
+
<Show
|
|
1064
|
+
when={scrolling() || titleGlow.value().level > 0 || titleFades()}
|
|
1065
|
+
fallback={visibleTitle()}
|
|
1066
|
+
>
|
|
1067
|
+
<Index each={visibleTitleParts()}>
|
|
1068
|
+
{(part, index) => (
|
|
1069
|
+
<span style={{ fg: titleColor(index, part().separator) }}>{part().value}</span>
|
|
1070
|
+
)}
|
|
1071
|
+
</Index>
|
|
1072
|
+
</Show>
|
|
1073
|
+
</title_shimmer>
|
|
1074
|
+
<text
|
|
1075
|
+
position="absolute"
|
|
1076
|
+
right={1}
|
|
1077
|
+
zIndex={2}
|
|
1078
|
+
width={1}
|
|
1079
|
+
fg={closeHovered() ? theme.text.base : theme.text.muted}
|
|
1080
|
+
selectable={false}
|
|
1081
|
+
onMouseOver={() => setCloseHovered(true)}
|
|
1082
|
+
onMouseOut={() => setCloseHovered(false)}
|
|
1083
|
+
onMouseDown={(event) => {
|
|
1084
|
+
if (event.button === RIGHT_MOUSE_BUTTON || hovered() !== tab.sessionID) return
|
|
1085
|
+
didDrag = false
|
|
1086
|
+
event.stopPropagation()
|
|
1087
|
+
}}
|
|
1088
|
+
onMouseUp={(event) => {
|
|
1089
|
+
if (event.button === RIGHT_MOUSE_BUTTON) return
|
|
1090
|
+
if (suppressClick) return
|
|
1091
|
+
if (hovered() !== tab.sessionID) return
|
|
1092
|
+
event.stopPropagation()
|
|
1093
|
+
tabs.close(tab.sessionID)
|
|
1094
|
+
}}
|
|
1095
|
+
>
|
|
1096
|
+
{hovered() === tab.sessionID ? "✕" : ""}
|
|
1097
|
+
</text>
|
|
1098
|
+
</box>
|
|
1099
|
+
</box>
|
|
1100
|
+
<box height={1} width="100%" position="relative" flexDirection="row">
|
|
1101
|
+
<TabPulse
|
|
1102
|
+
enabled={animations()}
|
|
1103
|
+
active={runs()}
|
|
1104
|
+
promptPulse={status().promptPulse}
|
|
1105
|
+
complete={complete() && !status().attention}
|
|
1106
|
+
glow={glows()}
|
|
1107
|
+
color={detailPulseColor()}
|
|
1108
|
+
glowColor={detailGlowColor()}
|
|
1109
|
+
glowTail={10}
|
|
1110
|
+
flashColor={detailFlashColor()}
|
|
1111
|
+
flashTail={8}
|
|
1112
|
+
completionColor={detailGlowColor()}
|
|
1113
|
+
backgroundColor={pulseBackground()}
|
|
1114
|
+
/>
|
|
1115
|
+
<box zIndex={1} width="100%" flexDirection="row" paddingLeft={prefixWidth()} paddingRight={2}>
|
|
1116
|
+
<text fg={detailColor()} wrapMode="none" selectable={false}>
|
|
1117
|
+
<Show when={detailFades()} fallback={visibleDetail()}>
|
|
1118
|
+
<For each={visibleDetailParts()}>
|
|
1119
|
+
{(character, index) => <span style={{ fg: detailTextColor(index()) }}>{character}</span>}
|
|
1120
|
+
</For>
|
|
1121
|
+
</Show>
|
|
1122
|
+
</text>
|
|
1123
|
+
</box>
|
|
1124
|
+
</box>
|
|
1125
|
+
</Show>
|
|
1126
|
+
</box>
|
|
1127
|
+
)
|
|
1128
|
+
}}
|
|
1129
|
+
</For>
|
|
1130
|
+
{/* One slot with two states: a muted affordance that promotes in place into the
|
|
1131
|
+
active new-session tab, instead of spawning a separate pseudo tab above itself. */}
|
|
1132
|
+
<Show when={tabs.add || newTab()}>
|
|
1133
|
+
<box
|
|
1134
|
+
height={1}
|
|
1135
|
+
width="100%"
|
|
1136
|
+
position="relative"
|
|
1137
|
+
flexDirection="row"
|
|
1138
|
+
paddingLeft={compact() ? 0 : 1}
|
|
1139
|
+
justifyContent={compact() ? "center" : "flex-start"}
|
|
1140
|
+
alignItems="center"
|
|
1141
|
+
backgroundColor={
|
|
1142
|
+
newTab() && !compact()
|
|
1143
|
+
? actionSelected()
|
|
1144
|
+
: addHovered() || (compact() && newTab())
|
|
1145
|
+
? actionHovered()
|
|
1146
|
+
: background()
|
|
1147
|
+
}
|
|
1148
|
+
onMouseOver={() => setAddHovered(true)}
|
|
1149
|
+
onMouseOut={() => setAddHovered(false)}
|
|
1150
|
+
onMouseDown={(event: MouseEvent) => {
|
|
1151
|
+
didDrag = false
|
|
1152
|
+
setDragging(undefined)
|
|
1153
|
+
addPressed = event.button !== RIGHT_MOUSE_BUTTON
|
|
1154
|
+
if (addPressed) return
|
|
1155
|
+
if (!rail) return
|
|
1156
|
+
setContextMenu({ x: event.x, y: event.y })
|
|
1157
|
+
event.preventDefault()
|
|
1158
|
+
event.stopPropagation()
|
|
1159
|
+
}}
|
|
1160
|
+
onMouseUp={(event: MouseEvent) => {
|
|
1161
|
+
if (event.button === RIGHT_MOUSE_BUTTON) return
|
|
1162
|
+
if (suppressClick) return
|
|
1163
|
+
if (!addPressed) return
|
|
1164
|
+
addPressed = false
|
|
1165
|
+
if (!newTab()) tabs.add?.()
|
|
1166
|
+
}}
|
|
1167
|
+
onMouseDragEnd={() => (addPressed = false)}
|
|
1168
|
+
>
|
|
1169
|
+
<Show when={compact() && addHighlighted()}>
|
|
1170
|
+
<SessionTabHalfRow
|
|
1171
|
+
top={-1}
|
|
1172
|
+
edge="top"
|
|
1173
|
+
width={width()}
|
|
1174
|
+
color={highlightColor()}
|
|
1175
|
+
background={highlighted(items().at(-1)?.sessionID) ? highlightColor() : background()}
|
|
1176
|
+
/>
|
|
1177
|
+
<SessionTabHalfRow
|
|
1178
|
+
top={1}
|
|
1179
|
+
edge="bottom"
|
|
1180
|
+
width={width()}
|
|
1181
|
+
color={highlightColor()}
|
|
1182
|
+
background={background()}
|
|
1183
|
+
/>
|
|
1184
|
+
</Show>
|
|
1185
|
+
<text
|
|
1186
|
+
width={compact() ? 1 : 2}
|
|
1187
|
+
fg={newTab() || addHovered() ? theme.text.base : idleNumber()}
|
|
1188
|
+
selectable={false}
|
|
1189
|
+
attributes={newTab() ? TextAttributes.BOLD : undefined}
|
|
1190
|
+
>
|
|
1191
|
+
+
|
|
1192
|
+
</text>
|
|
1193
|
+
<Show when={!compact()}>
|
|
1194
|
+
<text
|
|
1195
|
+
fg={newTab() || addHovered() ? theme.text.base : theme.text.muted}
|
|
1196
|
+
wrapMode="none"
|
|
1197
|
+
selectable={false}
|
|
1198
|
+
attributes={newTab() ? TextAttributes.BOLD : undefined}
|
|
1199
|
+
>
|
|
1200
|
+
{NEW_SESSION_TAB_TITLE}
|
|
1201
|
+
</text>
|
|
1202
|
+
</Show>
|
|
1203
|
+
<Show when={newTab() && !compact()}>
|
|
1204
|
+
<text
|
|
1205
|
+
position="absolute"
|
|
1206
|
+
right={1}
|
|
1207
|
+
zIndex={2}
|
|
1208
|
+
width={1}
|
|
1209
|
+
fg={theme.text.muted}
|
|
1210
|
+
selectable={false}
|
|
1211
|
+
onMouseUp={(event) => {
|
|
1212
|
+
if (event.button === RIGHT_MOUSE_BUTTON) return
|
|
1213
|
+
if (suppressClick) return
|
|
1214
|
+
if (!addHovered()) return
|
|
1215
|
+
event.stopPropagation()
|
|
1216
|
+
tabs.close()
|
|
1217
|
+
}}
|
|
1218
|
+
>
|
|
1219
|
+
{addHovered() ? "×" : ""}
|
|
1220
|
+
</text>
|
|
1221
|
+
</Show>
|
|
1222
|
+
</box>
|
|
1223
|
+
</Show>
|
|
1224
|
+
</box>
|
|
1225
|
+
</scrollbox>
|
|
1226
|
+
<Show when={compact() && !dragging() && !contextMenu() && hovered()}>
|
|
1227
|
+
{(sessionID) => (
|
|
1228
|
+
<box
|
|
1229
|
+
position="absolute"
|
|
1230
|
+
left={width()}
|
|
1231
|
+
top={Math.max(0, Math.min(hoverY() - 1, dimensions().height - 4) - (rail?.screenY ?? 0))}
|
|
1232
|
+
width={tooltipWidth()}
|
|
1233
|
+
height={4}
|
|
1234
|
+
paddingY={1}
|
|
1235
|
+
zIndex={2000}
|
|
1236
|
+
>
|
|
1237
|
+
<SessionTabHalfRow
|
|
1238
|
+
top={0}
|
|
1239
|
+
edge="top"
|
|
1240
|
+
width={tooltipWidth()}
|
|
1241
|
+
color={background()}
|
|
1242
|
+
background={base.background.base}
|
|
1243
|
+
/>
|
|
1244
|
+
<box height={2} paddingX={1} backgroundColor={background()}>
|
|
1245
|
+
<text fg={theme.text.base} wrapMode="none" selectable={false}>
|
|
1246
|
+
{Locale.truncateWidth(
|
|
1247
|
+
data?.session.get(sessionID())?.title ??
|
|
1248
|
+
items().find((tab) => tab.sessionID === sessionID())?.title ??
|
|
1249
|
+
"Untitled session",
|
|
1250
|
+
tooltipWidth() - 2,
|
|
1251
|
+
)}
|
|
1252
|
+
</text>
|
|
1253
|
+
<text fg={theme.text.muted} wrapMode="none" selectable={false}>
|
|
1254
|
+
{Locale.takeWidth(detail(sessionID()), tooltipWidth() - 2)}
|
|
1255
|
+
</text>
|
|
1256
|
+
</box>
|
|
1257
|
+
<SessionTabHalfRow
|
|
1258
|
+
top={3}
|
|
1259
|
+
edge="bottom"
|
|
1260
|
+
width={tooltipWidth()}
|
|
1261
|
+
color={background()}
|
|
1262
|
+
background={base.background.base}
|
|
1263
|
+
/>
|
|
1264
|
+
</box>
|
|
1265
|
+
)}
|
|
1266
|
+
</Show>
|
|
1267
|
+
<Show when={contextMenu()}>
|
|
1268
|
+
{(state) => <TabContextMenu state={state()} tabs={tabs} onClose={() => setContextMenu(undefined)} />}
|
|
1269
|
+
</Show>
|
|
1270
|
+
</box>
|
|
1271
|
+
)
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
function HorizontalSessionTabs(props: {
|
|
1275
|
+
controller?: SessionTabsController
|
|
1276
|
+
animations?: boolean
|
|
1277
|
+
spinner?: TabSpinner
|
|
1278
|
+
unreadMarker?: TabUnreadMarker
|
|
1279
|
+
numbers: boolean
|
|
1280
|
+
}) {
|
|
1281
|
+
const tabs = props.controller ?? useSessionTabs()
|
|
1282
|
+
const data = props.controller ? undefined : useData()
|
|
1283
|
+
const dimensions = useTerminalDimensions()
|
|
1284
|
+
const theme = useTheme()
|
|
1285
|
+
const config = useConfig().data
|
|
1286
|
+
const animations = () => props.animations ?? config.animations ?? true
|
|
1287
|
+
const [addHovered, setAddHovered] = createSignal(false)
|
|
1288
|
+
const marquee = createTabMarquee(animations)
|
|
1289
|
+
const hovered = marquee.hovered
|
|
1290
|
+
// OpenTUI captures the first drag target, which may differ from the tab pressed on a fast move.
|
|
1291
|
+
const [dragging, setDragging] = createSignal<string>()
|
|
1292
|
+
// A drag reorders a local preview and persists one move on release instead of writing
|
|
1293
|
+
// per slot crossing; the preview holds after release until the store reflects the move,
|
|
1294
|
+
// so the strip never flashes the pre-drag order while the write is in flight.
|
|
1295
|
+
const [preview, setPreview] = createSignal<{ sessionID: string; index: number }>()
|
|
1296
|
+
const [contextMenu, setContextMenu] = createSignal<TabContextMenuState>()
|
|
1297
|
+
const [closeHold, setCloseHold] = createSignal<MouseCloseHold>()
|
|
1298
|
+
let strip: { screenX: number; screenY: number; width: number; height: number } | undefined
|
|
1299
|
+
let didDrag = false
|
|
1300
|
+
let addPressed = false
|
|
1301
|
+
let closeHoldTimer: ReturnType<typeof setTimeout> | undefined
|
|
1302
|
+
let releasingCloseHold = false
|
|
1303
|
+
const clearCloseHold = () => {
|
|
1304
|
+
setCloseHold(undefined)
|
|
1305
|
+
if (closeHoldTimer) clearTimeout(closeHoldTimer)
|
|
1306
|
+
closeHoldTimer = undefined
|
|
1307
|
+
}
|
|
1308
|
+
const releaseCloseHold = () => {
|
|
1309
|
+
if (!closeHold()) return
|
|
1310
|
+
releasingCloseHold = true
|
|
1311
|
+
clearCloseHold()
|
|
1312
|
+
}
|
|
1313
|
+
onCleanup(clearCloseHold)
|
|
1314
|
+
// A captured drag ends with a synthetic up on its drop target; do not turn that into a click.
|
|
1315
|
+
let suppressClick = false
|
|
1316
|
+
const unreadColor = () => theme.hue.accent[200]
|
|
1317
|
+
const activeNumber = () => theme.hue.interactive[200]
|
|
1318
|
+
const idleNumber = () => tint(theme.text.formfield.base, theme.background.base, 0.55)
|
|
1319
|
+
const newTab = () => tabs.newTab?.() ?? false
|
|
1320
|
+
const activeID = createMemo(() => (newTab() ? NEW_SESSION_TAB.sessionID : tabs.current()))
|
|
1321
|
+
const ordered = createMemo(() => {
|
|
1322
|
+
const pending = preview()
|
|
1323
|
+
if (!pending) return tabs.tabs()
|
|
1324
|
+
return moveSessionTab(tabs.tabs(), pending.sessionID, pending.index)
|
|
1325
|
+
})
|
|
1326
|
+
// The promoted new-session slot joins the strip as the active tab; the idle plus affordance
|
|
1327
|
+
// and the promoted slot are mutually exclusive states of one control.
|
|
1328
|
+
const items = createMemo(() => (newTab() ? [...ordered(), NEW_SESSION_TAB] : ordered()))
|
|
1329
|
+
const showPlus = () => Boolean(tabs.add) && !newTab()
|
|
1330
|
+
createEffect(() => {
|
|
1331
|
+
const pending = preview()
|
|
1332
|
+
if (!pending || dragging()) return
|
|
1333
|
+
const index = tabs.tabs().findIndex((tab) => tab.sessionID === pending.sessionID)
|
|
1334
|
+
if (index === -1 || index === Math.min(pending.index, tabs.tabs().length - 1)) setPreview(undefined)
|
|
1335
|
+
})
|
|
1336
|
+
const heldLayout = createMemo(() => {
|
|
1337
|
+
const hold = closeHold()
|
|
1338
|
+
return hold ? heldSessionTabLayout(hold, items()) : undefined
|
|
1339
|
+
})
|
|
1340
|
+
const layout = createMemo(
|
|
1341
|
+
(previous: ReturnType<typeof adaptiveSessionTabLayout> | undefined) =>
|
|
1342
|
+
heldLayout() ??
|
|
1343
|
+
adaptiveSessionTabLayout(
|
|
1344
|
+
items(),
|
|
1345
|
+
activeID(),
|
|
1346
|
+
dimensions().width - (showPlus() ? ADD_TAB_WIDTH : 0),
|
|
1347
|
+
previous?.start,
|
|
1348
|
+
),
|
|
1349
|
+
)
|
|
1350
|
+
createEffect(() => {
|
|
1351
|
+
if (closeHold() && !heldLayout()) clearCloseHold()
|
|
1352
|
+
})
|
|
1353
|
+
createEffect(() => {
|
|
1354
|
+
const active = marquee.active()
|
|
1355
|
+
if (active && !layout().tabs.some((tab) => tab.sessionID === active)) marquee.reset()
|
|
1356
|
+
})
|
|
1357
|
+
const statuses = createMemo(
|
|
1358
|
+
() =>
|
|
1359
|
+
new Map(
|
|
1360
|
+
layout().tabs.map((tab) => {
|
|
1361
|
+
const status = tab === NEW_SESSION_TAB ? EMPTY_SESSION_TAB_STATUS : tabs.status(tab.sessionID)
|
|
1362
|
+
return [
|
|
1363
|
+
tab.sessionID,
|
|
1364
|
+
{
|
|
1365
|
+
...status,
|
|
1366
|
+
complete: sessionTabComplete(status.unread, status.busy),
|
|
1367
|
+
},
|
|
1368
|
+
] as const
|
|
1369
|
+
}),
|
|
1370
|
+
),
|
|
1371
|
+
)
|
|
1372
|
+
const targets = createMemo(() => ({
|
|
1373
|
+
widths: layout().widths,
|
|
1374
|
+
selections: layout().tabs.map((tab) => Number(tab.sessionID === activeID())),
|
|
1375
|
+
activities: layout().tabs.map((tab) => Number(statuses().get(tab.sessionID)!.complete)),
|
|
1376
|
+
}))
|
|
1377
|
+
const motion = createAnimatable(targets(), {
|
|
1378
|
+
enabled: animations,
|
|
1379
|
+
transition: spring({ visualDuration: 0.1 }),
|
|
1380
|
+
})
|
|
1381
|
+
const identity = createMemo(() =>
|
|
1382
|
+
layout()
|
|
1383
|
+
.tabs.map((tab) => tab.sessionID)
|
|
1384
|
+
.join(":"),
|
|
1385
|
+
)
|
|
1386
|
+
let signature = ""
|
|
1387
|
+
let total = 0
|
|
1388
|
+
let terminalWidth = dimensions().width
|
|
1389
|
+
|
|
1390
|
+
// createComputed runs before render effects, so seeded widths are visible on the first frame
|
|
1391
|
+
// of a membership change instead of flashing the final layout.
|
|
1392
|
+
createComputed(() => {
|
|
1393
|
+
const next = targets()
|
|
1394
|
+
const nextSignature = identity()
|
|
1395
|
+
const changed = Boolean(signature) && signature !== nextSignature
|
|
1396
|
+
const resized = Boolean(total) && total !== layout().total
|
|
1397
|
+
const terminalResized = terminalWidth !== dimensions().width
|
|
1398
|
+
const previous = signature
|
|
1399
|
+
signature = nextSignature
|
|
1400
|
+
total = layout().total
|
|
1401
|
+
terminalWidth = dimensions().width
|
|
1402
|
+
const releasing = releasingCloseHold
|
|
1403
|
+
releasingCloseHold = false
|
|
1404
|
+
if (terminalResized && closeHold()) {
|
|
1405
|
+
clearCloseHold()
|
|
1406
|
+
return
|
|
1407
|
+
}
|
|
1408
|
+
if (closeHold() && heldLayout()) {
|
|
1409
|
+
const current = untrack(motion.value)
|
|
1410
|
+
const seeded = changed
|
|
1411
|
+
? seedSessionTabMotion(
|
|
1412
|
+
previous.split(":"),
|
|
1413
|
+
layout().tabs.map((tab) => tab.sessionID),
|
|
1414
|
+
current,
|
|
1415
|
+
next,
|
|
1416
|
+
)
|
|
1417
|
+
: current
|
|
1418
|
+
if (!seeded) return motion.jump(next)
|
|
1419
|
+
motion.jump({ ...seeded, widths: next.widths })
|
|
1420
|
+
return motion.animate(next)
|
|
1421
|
+
}
|
|
1422
|
+
if (!changed && !resized) return motion.animate(next)
|
|
1423
|
+
// Identity-stable total changes are terminal resizes and still jump.
|
|
1424
|
+
if (!changed) return releasing ? motion.animate(next) : motion.jump(next)
|
|
1425
|
+
const seeded = seedSessionTabMotion(
|
|
1426
|
+
previous.split(":"),
|
|
1427
|
+
layout().tabs.map((tab) => tab.sessionID),
|
|
1428
|
+
untrack(motion.value),
|
|
1429
|
+
next,
|
|
1430
|
+
)
|
|
1431
|
+
if (!seeded) return motion.jump(next)
|
|
1432
|
+
motion.jump(seeded)
|
|
1433
|
+
motion.animate(next)
|
|
1434
|
+
})
|
|
1435
|
+
|
|
1436
|
+
const activeIndex = createMemo(() => layout().tabs.findIndex((tab) => tab.sessionID === activeID()))
|
|
1437
|
+
const visuals = createMemo(() => {
|
|
1438
|
+
const current = signature === identity() && total === layout().total ? motion.value() : targets()
|
|
1439
|
+
const widths = current.widths.map((width) => Math.max(1, Math.round(width)))
|
|
1440
|
+
const active = activeIndex()
|
|
1441
|
+
const remainder = layout().total - widths.reduce((sum, width) => sum + width, 0)
|
|
1442
|
+
// Absorb only rounding slack; membership animations leave a real gap while widths grow into place.
|
|
1443
|
+
if (active !== -1 && Math.abs(remainder) <= layout().tabs.length) widths[active] += remainder
|
|
1444
|
+
return new Map(
|
|
1445
|
+
layout().tabs.map((tab, index) => [
|
|
1446
|
+
tab.sessionID,
|
|
1447
|
+
{
|
|
1448
|
+
width: widths[index],
|
|
1449
|
+
selection: current.selections[index] ?? Number(tab.sessionID === activeID()),
|
|
1450
|
+
activity: current.activities[index] ?? Number(statuses().get(tab.sessionID)!.complete),
|
|
1451
|
+
},
|
|
1452
|
+
]),
|
|
1453
|
+
)
|
|
1454
|
+
})
|
|
1455
|
+
|
|
1456
|
+
const holdCloseCell = (sessionID: string, x: number) => {
|
|
1457
|
+
if (!strip) return clearCloseHold()
|
|
1458
|
+
const current = layout()
|
|
1459
|
+
const index = current.tabs.findIndex((tab) => tab.sessionID === sessionID)
|
|
1460
|
+
const all = items()
|
|
1461
|
+
const itemIndex = all.findIndex((tab) => tab.sessionID === sessionID)
|
|
1462
|
+
const target = all[itemIndex + 1] ?? all[itemIndex - 1]
|
|
1463
|
+
if (index === -1 || itemIndex === -1 || !target) return clearCloseHold()
|
|
1464
|
+
const ids = current.tabs.map((tab) => tab.sessionID)
|
|
1465
|
+
const values = ids.map((id) => visuals().get(id))
|
|
1466
|
+
if (values.some((value) => !value)) return clearCloseHold()
|
|
1467
|
+
setCloseHold({
|
|
1468
|
+
items: all.map((tab) => tab.sessionID),
|
|
1469
|
+
ids,
|
|
1470
|
+
widths: values.map((value) => value!.width),
|
|
1471
|
+
closed: sessionID,
|
|
1472
|
+
target: target.sessionID,
|
|
1473
|
+
x: x - strip.screenX,
|
|
1474
|
+
})
|
|
1475
|
+
if (closeHoldTimer) clearTimeout(closeHoldTimer)
|
|
1476
|
+
closeHoldTimer = setTimeout(releaseCloseHold, MOUSE_CLOSE_HOLD_MS)
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
// Map an absolute pointer column to the items index of the visible slot beneath it.
|
|
1480
|
+
const slotAt = (x: number) => {
|
|
1481
|
+
if (!strip) return undefined
|
|
1482
|
+
const stripX = x - strip.screenX
|
|
1483
|
+
let edge = layout().before > 0 ? sessionTabOverflowWidth(layout().before) : 0
|
|
1484
|
+
for (const [index, width] of layout().widths.entries()) {
|
|
1485
|
+
edge += width
|
|
1486
|
+
if (stripX < edge) return layout().before + index
|
|
1487
|
+
}
|
|
1488
|
+
return layout().before + layout().widths.length - 1
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
const release = () => {
|
|
1492
|
+
const source = dragging()
|
|
1493
|
+
if (!source) return
|
|
1494
|
+
if (didDrag) suppressClick = true
|
|
1495
|
+
setDragging(undefined)
|
|
1496
|
+
const pending = preview()
|
|
1497
|
+
if (pending?.sessionID === source) tabs.move(pending.sessionID, pending.index)
|
|
1498
|
+
if (source === NEW_SESSION_TAB.sessionID) return
|
|
1499
|
+
tabs.select(source)
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
const drag = (event: MouseEvent) => {
|
|
1503
|
+
const source = dragging()
|
|
1504
|
+
if (!source || source === NEW_SESSION_TAB.sessionID) return
|
|
1505
|
+
didDrag = true
|
|
1506
|
+
const slot = slotAt(event.x)
|
|
1507
|
+
const target = slot === undefined ? undefined : Math.min(slot, tabs.tabs().length - 1)
|
|
1508
|
+
const sourceIndex = items().findIndex((item) => item.sessionID === source)
|
|
1509
|
+
if (target !== undefined && target !== sourceIndex && preview()?.index !== target) {
|
|
1510
|
+
setPreview({ sessionID: source, index: target })
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
return (
|
|
1515
|
+
<box
|
|
1516
|
+
ref={(element) => (strip = element)}
|
|
1517
|
+
height={1}
|
|
1518
|
+
flexShrink={0}
|
|
1519
|
+
position="relative"
|
|
1520
|
+
flexDirection="row"
|
|
1521
|
+
zIndex={1}
|
|
1522
|
+
onMouseOut={(event) => {
|
|
1523
|
+
marquee.leaveHovered()
|
|
1524
|
+
if (!strip) return
|
|
1525
|
+
if (
|
|
1526
|
+
event.x < strip.screenX ||
|
|
1527
|
+
event.x >= strip.screenX + strip.width ||
|
|
1528
|
+
event.y < strip.screenY ||
|
|
1529
|
+
event.y >= strip.screenY + strip.height
|
|
1530
|
+
)
|
|
1531
|
+
releaseCloseHold()
|
|
1532
|
+
}}
|
|
1533
|
+
onMouseUp={(event) => {
|
|
1534
|
+
if (event.button === RIGHT_MOUSE_BUTTON) return
|
|
1535
|
+
release()
|
|
1536
|
+
if (!didDrag) return
|
|
1537
|
+
didDrag = false
|
|
1538
|
+
queueMicrotask(() => (suppressClick = false))
|
|
1539
|
+
}}
|
|
1540
|
+
onMouseDrag={drag}
|
|
1541
|
+
onMouseDragEnd={release}
|
|
1542
|
+
>
|
|
1543
|
+
<Show when={layout().before > 0}>
|
|
1544
|
+
<text width={sessionTabOverflowWidth(layout().before)} fg={theme.text.muted} selectable={false}>
|
|
1545
|
+
‹{layout().before}
|
|
1546
|
+
</text>
|
|
1547
|
+
</Show>
|
|
1548
|
+
<For each={layout().tabs}>
|
|
1549
|
+
{(tab) => {
|
|
1550
|
+
const selected = () => activeID() === tab.sessionID
|
|
1551
|
+
const status = () => statuses().get(tab.sessionID)!
|
|
1552
|
+
const width = () => visuals().get(tab.sessionID)?.width ?? 1
|
|
1553
|
+
const selection = () => visuals().get(tab.sessionID)?.selection ?? Number(selected())
|
|
1554
|
+
const activity = () => visuals().get(tab.sessionID)?.activity ?? Number(status().complete)
|
|
1555
|
+
const dragged = () => dragging() === tab.sessionID
|
|
1556
|
+
const background = createMemo(() => {
|
|
1557
|
+
const lifted = (hovered() === tab.sessionID || dragged()) && !selected()
|
|
1558
|
+
const base = lifted ? theme.background.action.primary.hovered : theme.background.base
|
|
1559
|
+
// A dragged tab lifts to full selected elevation while it is held.
|
|
1560
|
+
return tint(base, theme.decrease(theme.background.raised.base), dragged() ? 1 : selection())
|
|
1561
|
+
})
|
|
1562
|
+
const pulseColor = () => tint(background(), theme.text.base, 0.45)
|
|
1563
|
+
// The edge flash washes toward a brighter stop on the same background-to-text ramp,
|
|
1564
|
+
// so it reads as a lift of the pulse color rather than a different hue.
|
|
1565
|
+
const flashColor = () => tint(background(), theme.text.base, 0.65)
|
|
1566
|
+
const feedbackColor = () => tabFeedbackColor(status(), theme)
|
|
1567
|
+
const glowLevel = createGlowLevel(() => selected() && Boolean(status().attention), animations)
|
|
1568
|
+
const glowColor = createMemo(() => tint(background(), feedbackColor() ?? unreadColor(), glowLevel()))
|
|
1569
|
+
const glows = () =>
|
|
1570
|
+
Boolean(status().attention || (!selected() && !status().busy && status().unread !== undefined))
|
|
1571
|
+
const title = () => data?.session.get(tab.sessionID)?.title ?? tab.title ?? "Untitled session"
|
|
1572
|
+
const tabNumber = createMemo(() => items().findIndex((item) => item.sessionID === tab.sessionID) + 1)
|
|
1573
|
+
const numberWidth = () => Math.max(2, String(items().length).length)
|
|
1574
|
+
// Hovering reveals the close mark, so the title's right bound shifts left of it.
|
|
1575
|
+
const restingTitleWidth = () => Math.max(1, width() - 1 - numberWidth())
|
|
1576
|
+
const hoveredTitleWidth = () => Math.max(1, restingTitleWidth() - 2)
|
|
1577
|
+
const availableTitleWidth = () => (hovered() === tab.sessionID ? hoveredTitleWidth() : restingTitleWidth())
|
|
1578
|
+
const scrolling = () => marquee.active() === tab.sessionID
|
|
1579
|
+
const visibleTitleParts = createMemo(() =>
|
|
1580
|
+
scrolling()
|
|
1581
|
+
? marqueeTextParts(title(), availableTitleWidth(), marquee.offset())
|
|
1582
|
+
: Locale.graphemes(Locale.takeWidth(title(), availableTitleWidth())).map((value) => ({
|
|
1583
|
+
value,
|
|
1584
|
+
separator: false,
|
|
1585
|
+
})),
|
|
1586
|
+
)
|
|
1587
|
+
const visibleTitle = createMemo(() =>
|
|
1588
|
+
visibleTitleParts()
|
|
1589
|
+
.map((part) => part.value)
|
|
1590
|
+
.join(""),
|
|
1591
|
+
)
|
|
1592
|
+
const titleFades = createMemo(
|
|
1593
|
+
() => marqueeOverflows(title(), availableTitleWidth()) && availableTitleWidth() > FADE_WIDTH,
|
|
1594
|
+
)
|
|
1595
|
+
const runs = () => status().busy && !status().attention
|
|
1596
|
+
const numberIgnition = createNumberIgnition(runs, () => status().promptPulse, animations)
|
|
1597
|
+
const foreground = () => {
|
|
1598
|
+
if (hovered() === tab.sessionID) return theme.text.base
|
|
1599
|
+
return tint(theme.text.muted, theme.text.base, selection())
|
|
1600
|
+
}
|
|
1601
|
+
// Title characters sitting over the glow tinge toward its color, following the same
|
|
1602
|
+
// spatial falloff as the glow itself; characters beyond the tail stay neutral.
|
|
1603
|
+
const characterColor = (index: number, separator: boolean) => {
|
|
1604
|
+
const base = foreground()
|
|
1605
|
+
const color = glows() ? glowTextColor(base, glowColor(), 1 + numberWidth() + index, width()) : base
|
|
1606
|
+
const faded = titleFades()
|
|
1607
|
+
? fadeTitleColor(
|
|
1608
|
+
color,
|
|
1609
|
+
background(),
|
|
1610
|
+
index,
|
|
1611
|
+
visibleTitleParts().length,
|
|
1612
|
+
scrolling() ? marquee.leading() : 0,
|
|
1613
|
+
)
|
|
1614
|
+
: color
|
|
1615
|
+
return separator ? tint(faded, background(), 0.55) : faded
|
|
1616
|
+
}
|
|
1617
|
+
// The running sweep's level under the number cell, reported by the pulse renderable.
|
|
1618
|
+
const [sweepLevel, setSweepLevel] = createSignal(0)
|
|
1619
|
+
const [closeHovered, setCloseHovered] = createSignal(false)
|
|
1620
|
+
const numberColor = () => {
|
|
1621
|
+
const feedback = feedbackColor()
|
|
1622
|
+
const base =
|
|
1623
|
+
hovered() === tab.sessionID && !selected()
|
|
1624
|
+
? foreground()
|
|
1625
|
+
: tint(idleNumber(), tint(theme.text.base, background(), 0.25), selection())
|
|
1626
|
+
const color = runs() ? activeNumber() : (feedback ?? tint(base, unreadColor(), activity()))
|
|
1627
|
+
// The number brightens faintly as the running sweep passes beneath it.
|
|
1628
|
+
return tint(color, theme.text.base, Math.max(numberIgnition.value().level, 0.15 * sweepLevel()))
|
|
1629
|
+
}
|
|
1630
|
+
const bold = () => (selected() || dragged() ? TextAttributes.BOLD : undefined)
|
|
1631
|
+
const closeColor = () => tint(theme.text.muted, theme.text.base, 0.6)
|
|
1632
|
+
return (
|
|
1633
|
+
<box
|
|
1634
|
+
width={width()}
|
|
1635
|
+
position="relative"
|
|
1636
|
+
flexDirection="row"
|
|
1637
|
+
backgroundColor={background()}
|
|
1638
|
+
onMouseOver={() => marquee.enter(tab.sessionID, title(), hoveredTitleWidth())}
|
|
1639
|
+
onMouseOut={() => marquee.leave(tab.sessionID)}
|
|
1640
|
+
onMouseDown={(event) => {
|
|
1641
|
+
if (event.button === MIDDLE_MOUSE_BUTTON) {
|
|
1642
|
+
releaseCloseHold()
|
|
1643
|
+
didDrag = false
|
|
1644
|
+
setDragging(undefined)
|
|
1645
|
+
tabs.close(tab === NEW_SESSION_TAB ? undefined : tab.sessionID)
|
|
1646
|
+
event.preventDefault()
|
|
1647
|
+
event.stopPropagation()
|
|
1648
|
+
return
|
|
1649
|
+
}
|
|
1650
|
+
if (event.button === RIGHT_MOUSE_BUTTON) {
|
|
1651
|
+
releaseCloseHold()
|
|
1652
|
+
didDrag = false
|
|
1653
|
+
setDragging(undefined)
|
|
1654
|
+
setContextMenu({
|
|
1655
|
+
x: event.x,
|
|
1656
|
+
y: event.y,
|
|
1657
|
+
sessionID: tab === NEW_SESSION_TAB ? undefined : tab.sessionID,
|
|
1658
|
+
title: tab === NEW_SESSION_TAB ? undefined : tab.title,
|
|
1659
|
+
})
|
|
1660
|
+
event.preventDefault()
|
|
1661
|
+
event.stopPropagation()
|
|
1662
|
+
return
|
|
1663
|
+
}
|
|
1664
|
+
didDrag = false
|
|
1665
|
+
releaseCloseHold()
|
|
1666
|
+
marquee.enter(tab.sessionID, title(), hoveredTitleWidth())
|
|
1667
|
+
setDragging(tab.sessionID)
|
|
1668
|
+
}}
|
|
1669
|
+
>
|
|
1670
|
+
<TabPulse
|
|
1671
|
+
enabled={animations()}
|
|
1672
|
+
active={status().busy && !status().attention}
|
|
1673
|
+
promptPulse={status().promptPulse}
|
|
1674
|
+
complete={status().complete && !status().attention}
|
|
1675
|
+
glow={glows()}
|
|
1676
|
+
color={pulseColor()}
|
|
1677
|
+
glowColor={glowColor()}
|
|
1678
|
+
flashColor={flashColor()}
|
|
1679
|
+
completionColor={unreadColor()}
|
|
1680
|
+
backgroundColor={background()}
|
|
1681
|
+
onLevel={setSweepLevel}
|
|
1682
|
+
/>
|
|
1683
|
+
<box zIndex={1} width="100%" flexDirection="row">
|
|
1684
|
+
<TabIndicator
|
|
1685
|
+
status={status()}
|
|
1686
|
+
label={tab === NEW_SESSION_TAB ? "+" : sessionTabNumberLabel(tabNumber() - 1)}
|
|
1687
|
+
width={numberWidth()}
|
|
1688
|
+
color={numberColor()}
|
|
1689
|
+
unreadColor={feedbackColor() ?? unreadColor()}
|
|
1690
|
+
backgroundColor={background()}
|
|
1691
|
+
flashColor={theme.text.base}
|
|
1692
|
+
animations={animations()}
|
|
1693
|
+
numbers={props.numbers}
|
|
1694
|
+
spinner={props.spinner}
|
|
1695
|
+
unreadMarker={props.unreadMarker}
|
|
1696
|
+
attributes={bold()}
|
|
1697
|
+
/>
|
|
1698
|
+
<title_shimmer
|
|
1699
|
+
width={availableTitleWidth()}
|
|
1700
|
+
height={1}
|
|
1701
|
+
fg={foreground()}
|
|
1702
|
+
rename={{ pending: status().renaming, title: title() }}
|
|
1703
|
+
enabled={animations()}
|
|
1704
|
+
backdrop={background()}
|
|
1705
|
+
wrapMode="none"
|
|
1706
|
+
selectable={false}
|
|
1707
|
+
attributes={status().renaming && !animations() ? TextAttributes.DIM : bold()}
|
|
1708
|
+
>
|
|
1709
|
+
<Show when={scrolling() || glows() || titleFades()} fallback={visibleTitle()}>
|
|
1710
|
+
<Index each={visibleTitleParts()}>
|
|
1711
|
+
{(part, index) => (
|
|
1712
|
+
<span style={{ fg: characterColor(index, part().separator) }}>{part().value}</span>
|
|
1713
|
+
)}
|
|
1714
|
+
</Index>
|
|
1715
|
+
</Show>
|
|
1716
|
+
</title_shimmer>
|
|
1717
|
+
<text
|
|
1718
|
+
position="absolute"
|
|
1719
|
+
right={1}
|
|
1720
|
+
zIndex={2}
|
|
1721
|
+
width={1}
|
|
1722
|
+
fg={closeHovered() ? theme.text.base : closeColor()}
|
|
1723
|
+
selectable={false}
|
|
1724
|
+
onMouseOver={() => setCloseHovered(true)}
|
|
1725
|
+
onMouseOut={() => setCloseHovered(false)}
|
|
1726
|
+
onMouseDown={(event) => {
|
|
1727
|
+
if (event.button === RIGHT_MOUSE_BUTTON || hovered() !== tab.sessionID) return
|
|
1728
|
+
didDrag = false
|
|
1729
|
+
event.stopPropagation()
|
|
1730
|
+
}}
|
|
1731
|
+
onMouseUp={(event) => {
|
|
1732
|
+
if (event.button === RIGHT_MOUSE_BUTTON) return
|
|
1733
|
+
if (suppressClick) return
|
|
1734
|
+
// The close mark only renders while hovered; without motion events a click can
|
|
1735
|
+
// land here first, and must select the tab instead of closing it invisibly.
|
|
1736
|
+
if (hovered() !== tab.sessionID) return
|
|
1737
|
+
event.stopPropagation()
|
|
1738
|
+
holdCloseCell(tab.sessionID, event.x)
|
|
1739
|
+
tabs.close(tab === NEW_SESSION_TAB ? undefined : tab.sessionID)
|
|
1740
|
+
}}
|
|
1741
|
+
>
|
|
1742
|
+
{hovered() === tab.sessionID ? "✕" : ""}
|
|
1743
|
+
</text>
|
|
1744
|
+
</box>
|
|
1745
|
+
</box>
|
|
1746
|
+
)
|
|
1747
|
+
}}
|
|
1748
|
+
</For>
|
|
1749
|
+
<Show when={layout().after > 0}>
|
|
1750
|
+
<text width={sessionTabOverflowWidth(layout().after)} fg={theme.text.muted} selectable={false}>
|
|
1751
|
+
{" " + layout().after}›
|
|
1752
|
+
</text>
|
|
1753
|
+
</Show>
|
|
1754
|
+
<Show when={showPlus()}>
|
|
1755
|
+
<text
|
|
1756
|
+
width={ADD_TAB_WIDTH}
|
|
1757
|
+
fg={addHovered() ? theme.text.base : theme.text.muted}
|
|
1758
|
+
bg={addHovered() ? theme.background.action.primary.hovered : undefined}
|
|
1759
|
+
selectable={false}
|
|
1760
|
+
onMouseOver={() => setAddHovered(true)}
|
|
1761
|
+
onMouseOut={() => setAddHovered(false)}
|
|
1762
|
+
onMouseDown={(event) => {
|
|
1763
|
+
releaseCloseHold()
|
|
1764
|
+
didDrag = false
|
|
1765
|
+
setDragging(undefined)
|
|
1766
|
+
addPressed = event.button !== RIGHT_MOUSE_BUTTON
|
|
1767
|
+
if (addPressed) return
|
|
1768
|
+
setContextMenu({ x: event.x, y: event.y })
|
|
1769
|
+
event.preventDefault()
|
|
1770
|
+
event.stopPropagation()
|
|
1771
|
+
}}
|
|
1772
|
+
onMouseUp={(event) => {
|
|
1773
|
+
if (event.button === RIGHT_MOUSE_BUTTON) return
|
|
1774
|
+
if (suppressClick) return
|
|
1775
|
+
if (!addPressed) return
|
|
1776
|
+
addPressed = false
|
|
1777
|
+
tabs.add?.()
|
|
1778
|
+
}}
|
|
1779
|
+
onMouseDragEnd={() => (addPressed = false)}
|
|
1780
|
+
>
|
|
1781
|
+
{" + "}
|
|
1782
|
+
</text>
|
|
1783
|
+
</Show>
|
|
1784
|
+
<Show when={contextMenu()}>
|
|
1785
|
+
{(state) => <TabContextMenu state={state()} tabs={tabs} onClose={() => setContextMenu(undefined)} />}
|
|
1786
|
+
</Show>
|
|
1787
|
+
</box>
|
|
1788
|
+
)
|
|
1789
|
+
}
|