@oh-my-pi/pi-tui 18.13.2 → 18.14.0
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/CHANGELOG.md +40 -54
- package/README.md +34 -34
- package/dist/types/app-keybindings.d.ts +15 -0
- package/dist/types/apps/session-picker.d.ts +5 -0
- package/dist/types/charts/chart-plan.d.ts +9 -7
- package/dist/types/chat/assistant-message.d.ts +15 -3
- package/dist/types/chat/bash-execution.d.ts +2 -0
- package/dist/types/chat/display-preferences.d.ts +2 -0
- package/dist/types/chat/extension-types.d.ts +31 -0
- package/dist/types/chat/reply-write.d.ts +48 -0
- package/dist/types/chat/table-chart.d.ts +4 -3
- package/dist/types/chat/tool-execution.d.ts +1 -2
- package/dist/types/chat/transcript-outline.d.ts +7 -0
- package/dist/types/chat/transcript-render-helpers.d.ts +2 -0
- package/dist/types/chrome/index.d.ts +1 -0
- package/dist/types/chrome/transcript-notice.d.ts +35 -0
- package/dist/types/chrome/transcript-status.d.ts +20 -8
- package/dist/types/components/editor.d.ts +8 -0
- package/dist/types/components/markdown.d.ts +7 -0
- package/dist/types/native/blobs.d.ts +2 -1
- package/dist/types/native/picker.d.ts +3 -3
- package/dist/types/overlays/annotation-overlay.d.ts +7 -1
- package/dist/types/overlays/annotation-types.d.ts +28 -0
- package/dist/types/overlays/login-dialog.d.ts +5 -1
- package/dist/types/overlays/model-browser.d.ts +10 -1
- package/dist/types/overlays/oauth-selector.d.ts +23 -0
- package/dist/types/overlays/plan-review-overlay.d.ts +2 -0
- package/dist/types/overlays/rewind-selector.d.ts +1 -1
- package/dist/types/overlays/session-selector.d.ts +22 -2
- package/dist/types/prompt/composer.d.ts +41 -4
- package/dist/types/prompt/interactive-context-helpers.d.ts +10 -3
- package/dist/types/prompt/welcome.d.ts +6 -2
- package/dist/types/render/extension-links.d.ts +65 -0
- package/dist/types/render/hyperlink.d.ts +25 -7
- package/dist/types/render/index.d.ts +1 -0
- package/dist/types/setup/scenes/model.d.ts +1 -1
- package/dist/types/setup/scenes/outro.d.ts +5 -4
- package/dist/types/setup/scenes/sign-in.d.ts +13 -8
- package/dist/types/setup/scenes/splash.d.ts +4 -4
- package/dist/types/setup/scenes/types.d.ts +16 -1
- package/dist/types/setup/startup-splash.d.ts +1 -1
- package/dist/types/setup/wizard-overlay.d.ts +11 -7
- package/dist/types/setup/wizard.d.ts +5 -1
- package/dist/types/status-line/component.d.ts +1 -1
- package/dist/types/status-line/context-usage.d.ts +28 -6
- package/dist/types/status-line/host.d.ts +6 -2
- package/dist/types/theme/theme.d.ts +0 -23
- package/dist/types/tools/bash-interactive.d.ts +6 -0
- package/dist/types/tools/bash.d.ts +2 -0
- package/dist/types/tools/default-renderer.d.ts +6 -4
- package/dist/types/tools/irc.d.ts +6 -0
- package/dist/types/tools/json-tree.d.ts +23 -4
- package/dist/types/tools/lsp.d.ts +2 -0
- package/dist/types/tools/mcp.d.ts +6 -5
- package/dist/types/tools/native-view.d.ts +1 -1
- package/dist/types/tools/renderer.d.ts +2 -0
- package/dist/types/tools/streaming-output.d.ts +11 -0
- package/dist/types/tools/task.d.ts +9 -1
- package/dist/types/tools/url-scheme-host.d.ts +17 -0
- package/dist/types/tools/yield.d.ts +1 -1
- package/dist/types/tui.d.ts +7 -2
- package/package.json +10 -15
- package/src/app-keybindings.ts +15 -0
- package/src/apps/session-picker.ts +7 -0
- package/src/charts/chart-plan.ts +20 -50
- package/src/chat/advisor-message.ts +2 -0
- package/src/chat/assistant-message.ts +137 -19
- package/src/chat/background-tan-message.ts +4 -0
- package/src/chat/bash-execution.ts +6 -0
- package/src/chat/chat-transcript-builder.ts +58 -28
- package/src/chat/compaction-summary-message.ts +2 -1
- package/src/chat/display-preferences.ts +3 -0
- package/src/chat/extension-types.ts +34 -0
- package/src/chat/reply-write.ts +127 -0
- package/src/chat/table-chart.ts +10 -4
- package/src/chat/tool-execution.ts +20 -13
- package/src/chat/transcript-outline.ts +27 -0
- package/src/chat/transcript-render-helpers.ts +66 -24
- package/src/chrome/index.ts +1 -0
- package/src/chrome/transcript-notice.ts +83 -0
- package/src/chrome/transcript-status.ts +29 -29
- package/src/components/editor.ts +10 -1
- package/src/components/markdown.ts +116 -6
- package/src/hotkeys-markdown.ts +1 -0
- package/src/native/backend.ts +5 -66
- package/src/native/blobs.ts +3 -2
- package/src/native/picker.ts +3 -3
- package/src/overlays/advisor-config.ts +1 -10
- package/src/overlays/annotation-overlay.ts +125 -37
- package/src/overlays/annotation-types.ts +24 -0
- package/src/overlays/hook-selector.ts +2 -2
- package/src/overlays/login-dialog.ts +31 -5
- package/src/overlays/model-browser.ts +37 -0
- package/src/overlays/model-hub.ts +1 -7
- package/src/overlays/model-picker.ts +1 -10
- package/src/overlays/oauth-selector.ts +44 -6
- package/src/overlays/plan-review-overlay.ts +13 -2
- package/src/overlays/rewind-selector.ts +29 -12
- package/src/overlays/session-selector.ts +305 -39
- package/src/overlays/usage-dashboard.ts +5 -12
- package/src/prompt/composer.ts +213 -5
- package/src/prompt/custom-editor.ts +6 -1
- package/src/prompt/emoji-autocomplete.ts +0 -2
- package/src/prompt/interactive-context-helpers.ts +29 -4
- package/src/prompt/welcome.ts +31 -45
- package/src/render/extension-links.ts +214 -0
- package/src/render/hyperlink.ts +65 -9
- package/src/render/index.ts +1 -0
- package/src/setup/scenes/composer.ts +2 -0
- package/src/setup/scenes/glyph.ts +2 -0
- package/src/setup/scenes/model.ts +192 -29
- package/src/setup/scenes/outro.ts +30 -17
- package/src/setup/scenes/sign-in.ts +196 -400
- package/src/setup/scenes/splash.ts +25 -21
- package/src/setup/scenes/theme.ts +2 -0
- package/src/setup/scenes/types.ts +18 -1
- package/src/setup/startup-splash.ts +8 -7
- package/src/setup/wizard-overlay.ts +164 -33
- package/src/setup/wizard.ts +11 -2
- package/src/status-line/component.ts +4 -10
- package/src/status-line/context-usage.ts +72 -21
- package/src/status-line/host.ts +6 -2
- package/src/terminal.ts +24 -2
- package/src/theme/defaults.json +1 -0
- package/src/theme/loader.ts +1 -1
- package/src/theme/theme.ts +2 -75
- package/src/tools/bash-interactive.ts +6 -1
- package/src/tools/bash.ts +2 -0
- package/src/tools/default-renderer.ts +9 -6
- package/src/tools/eval.ts +14 -4
- package/src/tools/irc.ts +6 -0
- package/src/tools/job-widget.ts +13 -1
- package/src/tools/json-tree.ts +132 -42
- package/src/tools/lsp.ts +36 -15
- package/src/tools/mcp.ts +20 -12
- package/src/tools/native-view.ts +1 -1
- package/src/tools/renderer.ts +2 -0
- package/src/tools/streaming-output.ts +41 -0
- package/src/tools/task.ts +59 -17
- package/src/tools/url-scheme-host.ts +21 -0
- package/src/tools/yield.ts +18 -9
- package/src/tui.ts +43 -15
- package/THIRD-PARTY-NOTICES.txt +0 -22901
- package/dist/types/theme/defaults/index.d.ts +0 -10289
- package/src/theme/defaults/alabaster.json +0 -103
- package/src/theme/defaults/amethyst.json +0 -106
- package/src/theme/defaults/anthracite.json +0 -103
- package/src/theme/defaults/basalt.json +0 -101
- package/src/theme/defaults/birch.json +0 -105
- package/src/theme/defaults/dark-abyss.json +0 -101
- package/src/theme/defaults/dark-arctic.json +0 -114
- package/src/theme/defaults/dark-aurora.json +0 -105
- package/src/theme/defaults/dark-catppuccin.json +0 -117
- package/src/theme/defaults/dark-cavern.json +0 -101
- package/src/theme/defaults/dark-celestial.json +0 -116
- package/src/theme/defaults/dark-copper.json +0 -105
- package/src/theme/defaults/dark-cosmos.json +0 -100
- package/src/theme/defaults/dark-cyberpunk.json +0 -112
- package/src/theme/defaults/dark-dracula.json +0 -108
- package/src/theme/defaults/dark-eclipse.json +0 -101
- package/src/theme/defaults/dark-ember.json +0 -105
- package/src/theme/defaults/dark-equinox.json +0 -100
- package/src/theme/defaults/dark-forest.json +0 -106
- package/src/theme/defaults/dark-github.json +0 -115
- package/src/theme/defaults/dark-gruvbox.json +0 -122
- package/src/theme/defaults/dark-lavender.json +0 -105
- package/src/theme/defaults/dark-lunar.json +0 -99
- package/src/theme/defaults/dark-midnight.json +0 -105
- package/src/theme/defaults/dark-monochrome.json +0 -104
- package/src/theme/defaults/dark-monokai.json +0 -108
- package/src/theme/defaults/dark-nebula.json +0 -100
- package/src/theme/defaults/dark-neon-noir.json +0 -110
- package/src/theme/defaults/dark-nord.json +0 -108
- package/src/theme/defaults/dark-ocean.json +0 -111
- package/src/theme/defaults/dark-one.json +0 -110
- package/src/theme/defaults/dark-poimandres.json +0 -125
- package/src/theme/defaults/dark-rainforest.json +0 -101
- package/src/theme/defaults/dark-reef.json +0 -101
- package/src/theme/defaults/dark-retro.json +0 -102
- package/src/theme/defaults/dark-rose-pine.json +0 -106
- package/src/theme/defaults/dark-sakura.json +0 -105
- package/src/theme/defaults/dark-slate.json +0 -105
- package/src/theme/defaults/dark-solarized.json +0 -107
- package/src/theme/defaults/dark-solstice.json +0 -100
- package/src/theme/defaults/dark-starfall.json +0 -101
- package/src/theme/defaults/dark-sunset.json +0 -109
- package/src/theme/defaults/dark-swamp.json +0 -100
- package/src/theme/defaults/dark-synthwave.json +0 -113
- package/src/theme/defaults/dark-taiga.json +0 -101
- package/src/theme/defaults/dark-terminal.json +0 -105
- package/src/theme/defaults/dark-tokyo-night.json +0 -111
- package/src/theme/defaults/dark-tundra.json +0 -101
- package/src/theme/defaults/dark-twilight.json +0 -101
- package/src/theme/defaults/dark-volcanic.json +0 -101
- package/src/theme/defaults/graphite.json +0 -102
- package/src/theme/defaults/index.ts +0 -203
- package/src/theme/defaults/light-arctic.json +0 -117
- package/src/theme/defaults/light-aurora-day.json +0 -101
- package/src/theme/defaults/light-canyon.json +0 -101
- package/src/theme/defaults/light-catppuccin.json +0 -116
- package/src/theme/defaults/light-cirrus.json +0 -100
- package/src/theme/defaults/light-coral.json +0 -105
- package/src/theme/defaults/light-cyberpunk.json +0 -106
- package/src/theme/defaults/light-dawn.json +0 -100
- package/src/theme/defaults/light-dunes.json +0 -101
- package/src/theme/defaults/light-eucalyptus.json +0 -105
- package/src/theme/defaults/light-forest.json +0 -110
- package/src/theme/defaults/light-frost.json +0 -105
- package/src/theme/defaults/light-github.json +0 -125
- package/src/theme/defaults/light-glacier.json +0 -101
- package/src/theme/defaults/light-gruvbox.json +0 -118
- package/src/theme/defaults/light-haze.json +0 -100
- package/src/theme/defaults/light-honeycomb.json +0 -105
- package/src/theme/defaults/light-lagoon.json +0 -101
- package/src/theme/defaults/light-lavender.json +0 -105
- package/src/theme/defaults/light-meadow.json +0 -101
- package/src/theme/defaults/light-mint.json +0 -105
- package/src/theme/defaults/light-monochrome.json +0 -111
- package/src/theme/defaults/light-ocean.json +0 -109
- package/src/theme/defaults/light-one.json +0 -109
- package/src/theme/defaults/light-opal.json +0 -101
- package/src/theme/defaults/light-orchard.json +0 -101
- package/src/theme/defaults/light-paper.json +0 -105
- package/src/theme/defaults/light-poimandres.json +0 -125
- package/src/theme/defaults/light-prism.json +0 -100
- package/src/theme/defaults/light-retro.json +0 -108
- package/src/theme/defaults/light-sand.json +0 -105
- package/src/theme/defaults/light-savanna.json +0 -101
- package/src/theme/defaults/light-solarized.json +0 -112
- package/src/theme/defaults/light-soleil.json +0 -100
- package/src/theme/defaults/light-sunset.json +0 -109
- package/src/theme/defaults/light-synthwave.json +0 -108
- package/src/theme/defaults/light-tokyo-night.json +0 -121
- package/src/theme/defaults/light-wetland.json +0 -101
- package/src/theme/defaults/light-zenith.json +0 -99
- package/src/theme/defaults/limestone.json +0 -104
- package/src/theme/defaults/mahogany.json +0 -107
- package/src/theme/defaults/marble.json +0 -103
- package/src/theme/defaults/obsidian.json +0 -101
- package/src/theme/defaults/onyx.json +0 -101
- package/src/theme/defaults/pearl.json +0 -103
- package/src/theme/defaults/porcelain.json +0 -101
- package/src/theme/defaults/quartz.json +0 -106
- package/src/theme/defaults/sandstone.json +0 -105
- package/src/theme/defaults/titanium.json +0 -100
|
@@ -18,6 +18,7 @@ import { formatBytes, getProjectDir } from "@oh-my-pi/pi-utils";
|
|
|
18
18
|
import type { TspPickerGroup, TspPickerItem, TspSpan, TspText, TspTone } from "@oh-my-pi/pi-wire";
|
|
19
19
|
import { compact, kv, md, node, span } from "../native/describe";
|
|
20
20
|
import {
|
|
21
|
+
bindingKeys,
|
|
21
22
|
picker,
|
|
22
23
|
pickerAction,
|
|
23
24
|
pickerAge,
|
|
@@ -27,11 +28,12 @@ import {
|
|
|
27
28
|
pickerHits,
|
|
28
29
|
} from "../native/picker";
|
|
29
30
|
import type { DescribeContext, NativeChild, NativeNode, NativeUiEvent } from "../native/node";
|
|
30
|
-
import { hintsRow, type NativeHint, overlayCard } from "../native/overlay";
|
|
31
|
+
import { actionHint, hintsRow, type NativeHint, overlayCard } from "../native/overlay";
|
|
31
32
|
import { plainText } from "../native/spans";
|
|
32
33
|
import { theme } from "../theme/theme";
|
|
33
34
|
import { contentRowWidth } from "../chrome/selector-helpers";
|
|
34
35
|
import { matchesAppInterrupt, matchesSelectDown, matchesSelectUp } from "../keybinding-matchers";
|
|
36
|
+
import { getKeybindings } from "../keybindings";
|
|
35
37
|
/** Session lifecycle status presented by the picker. */
|
|
36
38
|
export type SessionSelectorStatus = "complete" | "interrupted" | "aborted" | "error" | "pending" | "unknown";
|
|
37
39
|
|
|
@@ -51,8 +53,10 @@ export interface SessionSelectorEntry {
|
|
|
51
53
|
parentSessionPath?: string;
|
|
52
54
|
}
|
|
53
55
|
import { shortenPath } from "../render/render-utils";
|
|
56
|
+
import { formTheme } from "../chrome/form-theme";
|
|
54
57
|
import { HookSelectorComponent } from "./hook-selector";
|
|
55
58
|
import { bottomBorder, OverlayPanel, row, topBorder } from "../chrome/overlay-box";
|
|
59
|
+
import { TextFormField } from "../components/form";
|
|
56
60
|
import { MenuSelection, getMenuWindow } from "../components/menu-selection";
|
|
57
61
|
import { formatKeyHint, formatKeyHints } from "../app-keybindings";
|
|
58
62
|
import { boundKeys, interruptKey } from "../chrome/keybinding-hints";
|
|
@@ -518,6 +522,8 @@ class SessionList<T extends SessionSelectorEntry> implements Component {
|
|
|
518
522
|
readonly #getTerminalRows: () => number;
|
|
519
523
|
|
|
520
524
|
onDeleteRequest?: (session: T) => void;
|
|
525
|
+
onRenameRequest?: (session: T) => void;
|
|
526
|
+
onPinRequest?: (session: T, pinned: boolean) => void;
|
|
521
527
|
|
|
522
528
|
#allSessions: T[];
|
|
523
529
|
#showCwd: boolean;
|
|
@@ -585,7 +591,7 @@ class SessionList<T extends SessionSelectorEntry> implements Component {
|
|
|
585
591
|
this.#getCurrentSessionPath =
|
|
586
592
|
typeof currentSessionPath === "function" ? currentSessionPath : () => currentSessionPath;
|
|
587
593
|
this.#historyMatcher = historyMatcher;
|
|
588
|
-
this.#menu = new MenuSelection<T>(sessions, {
|
|
594
|
+
this.#menu = new MenuSelection<T>(this.#pinnedFirst(sessions), {
|
|
589
595
|
getKey: session => session.path,
|
|
590
596
|
getSearchText: sessionSearchText,
|
|
591
597
|
});
|
|
@@ -661,8 +667,9 @@ class SessionList<T extends SessionSelectorEntry> implements Component {
|
|
|
661
667
|
this.#hadFilterQuery = tokens.length > 0;
|
|
662
668
|
this.#lastFilterQuery = query;
|
|
663
669
|
if (tokens.length === 0) {
|
|
664
|
-
const
|
|
665
|
-
this.#menu.
|
|
670
|
+
const items = this.#pinnedFirst(this.#allSessions);
|
|
671
|
+
const keepIndex = Math.min(this.#menu.selectedIndex, Math.max(0, items.length - 1));
|
|
672
|
+
this.#menu.setItems(items, keepIndex >= 0 ? items[keepIndex]?.path : undefined);
|
|
666
673
|
if (hadQuery) this.#selectCurrentSession();
|
|
667
674
|
this.#scheduleHistoryMerge(query);
|
|
668
675
|
return;
|
|
@@ -736,8 +743,9 @@ class SessionList<T extends SessionSelectorEntry> implements Component {
|
|
|
736
743
|
}
|
|
737
744
|
|
|
738
745
|
/**
|
|
739
|
-
* Rebuild the menu's visible list with
|
|
740
|
-
* prompt-history hits, literal matches (recency), and
|
|
746
|
+
* Rebuild the menu's visible list with pinned sessions first, then title
|
|
747
|
+
* matches, other prompt-history hits, literal matches (recency), and
|
|
748
|
+
* fuzzy-only hits (score).
|
|
741
749
|
*/
|
|
742
750
|
#composeFiltered(): void {
|
|
743
751
|
this.#itemsVersion++;
|
|
@@ -745,17 +753,31 @@ class SessionList<T extends SessionSelectorEntry> implements Component {
|
|
|
745
753
|
const base: T[] = [];
|
|
746
754
|
for (const match of this.#literalRanked) base.push(match.session);
|
|
747
755
|
for (const match of this.#fuzzyRanked) base.push(match.session);
|
|
748
|
-
const composed =
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
756
|
+
const composed = this.#pinnedFirst(
|
|
757
|
+
prioritizeTitleMatches(
|
|
758
|
+
this.#historyIds.length > 0 ? mergeSessionRanking(this.#allSessions, base, this.#historyIds) : base,
|
|
759
|
+
tokenizeSessionQuery(this.#searchInput.getValue()),
|
|
760
|
+
this.#literalRanked,
|
|
761
|
+
),
|
|
752
762
|
);
|
|
753
|
-
//
|
|
754
|
-
// selection
|
|
763
|
+
// A late pinned or history match can land above the cursor: a moved
|
|
764
|
+
// selection follows its session, an untouched one keeps the top rank.
|
|
765
|
+
// The query path resets explicitly.
|
|
766
|
+
if (this.#selectionMoved) {
|
|
767
|
+
this.#menu.setItems(composed);
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
755
770
|
const keepIndex = Math.min(this.#menu.selectedIndex, Math.max(0, composed.length - 1));
|
|
756
771
|
this.#menu.setItems(composed, keepIndex >= 0 ? composed[keepIndex]?.path : undefined);
|
|
757
772
|
}
|
|
758
773
|
|
|
774
|
+
/** Stable partition: pinned sessions first, each group in its incoming order. */
|
|
775
|
+
#pinnedFirst(sessions: readonly T[]): readonly T[] {
|
|
776
|
+
const pins = this.#pinnedIds;
|
|
777
|
+
const pinned = pins.size > 0 ? sessions.filter(session => pins.has(session.id)) : [];
|
|
778
|
+
return pinned.length > 0 ? [...pinned, ...sessions.filter(session => !pins.has(session.id))] : sessions;
|
|
779
|
+
}
|
|
780
|
+
|
|
759
781
|
/**
|
|
760
782
|
* Augment ranked results with prompt-history matches without replacing them.
|
|
761
783
|
* The session-list corpus only sees the first 4KB of each session, so a prompt
|
|
@@ -810,6 +832,22 @@ class SessionList<T extends SessionSelectorEntry> implements Component {
|
|
|
810
832
|
}
|
|
811
833
|
}
|
|
812
834
|
|
|
835
|
+
/** Update a session's title in place and refresh the visible list, keeping the selection. */
|
|
836
|
+
renameSessionTitle(sessionPath: string, title: string): void {
|
|
837
|
+
const entry = this.#allSessions.find(s => s.path === sessionPath);
|
|
838
|
+
if (!entry) return;
|
|
839
|
+
this.#datasetVersion++;
|
|
840
|
+
entry.title = title;
|
|
841
|
+
// The cached native item embeds the old title, and the search haystack
|
|
842
|
+
// caches it too: drop both so the next describe rebuilds the row and
|
|
843
|
+
// the literal/fuzzy search paths match the new title. Selection is
|
|
844
|
+
// path-keyed, so the same-query refilter keeps the cursor on the
|
|
845
|
+
// renamed session.
|
|
846
|
+
delete (entry as NativeSessionInfo)[kNativeItem];
|
|
847
|
+
delete (entry as SearchableSessionInfo)[kSearchTextLower];
|
|
848
|
+
this.#filterSessions(this.#searchInput.getValue());
|
|
849
|
+
}
|
|
850
|
+
|
|
813
851
|
/** Resolve a list-local rendered-line index to a filtered-session index. */
|
|
814
852
|
hitTestSession(line: number): number | undefined {
|
|
815
853
|
return this.#hitRows[line];
|
|
@@ -853,6 +891,43 @@ class SessionList<T extends SessionSelectorEntry> implements Component {
|
|
|
853
891
|
if (selected) this.onDeleteRequest?.(selected);
|
|
854
892
|
}
|
|
855
893
|
|
|
894
|
+
/** F2: ask the parent to rename the selected session. */
|
|
895
|
+
requestRename(): void {
|
|
896
|
+
const selected = this.#menu.selectedItem;
|
|
897
|
+
if (selected) this.onRenameRequest?.(selected);
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
/** Pin keys: ask the parent to pin or unpin the selected session (default: flip it); no-op when already there. */
|
|
901
|
+
requestPin(pinned?: boolean): void {
|
|
902
|
+
const selected = this.#menu.selectedItem;
|
|
903
|
+
if (!selected) return;
|
|
904
|
+
const isPinned = this.#pinnedIds.has(selected.id);
|
|
905
|
+
if (pinned !== isPinned) this.onPinRequest?.(selected, !isPinned);
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
/** Apply a persisted pin change; the list re-partitions and the cursor follows the session. */
|
|
909
|
+
setPinned(sessionId: string, pinned: boolean): void {
|
|
910
|
+
const pinnedIds = new Set(this.#pinnedIds);
|
|
911
|
+
if (pinned) pinnedIds.add(sessionId);
|
|
912
|
+
else pinnedIds.delete(sessionId);
|
|
913
|
+
this.#pinnedIds = pinnedIds;
|
|
914
|
+
// Counts as moving the selection: it keeps the cursor on this session
|
|
915
|
+
// and a pending history merge from reordering under it.
|
|
916
|
+
this.#selectionMoved = true;
|
|
917
|
+
if (this.#hadFilterQuery) {
|
|
918
|
+
this.#composeFiltered();
|
|
919
|
+
} else {
|
|
920
|
+
this.#itemsVersion++;
|
|
921
|
+
this.#menu.setItems(this.#pinnedFirst(this.#allSessions));
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
/** Whether the selected session is pinned (picks the pin action's direction). */
|
|
926
|
+
get selectedPinned(): boolean {
|
|
927
|
+
const selected = this.#menu.selectedItem;
|
|
928
|
+
return selected !== undefined && this.#pinnedIds.has(selected.id);
|
|
929
|
+
}
|
|
930
|
+
|
|
856
931
|
/** Empty the search query (the empty state's "Clear search"). */
|
|
857
932
|
clearSearch(): void {
|
|
858
933
|
this.#searchInput.setValue("");
|
|
@@ -902,7 +977,7 @@ class SessionList<T extends SessionSelectorEntry> implements Component {
|
|
|
902
977
|
if (tokens.length === 0) {
|
|
903
978
|
const now = new Date();
|
|
904
979
|
const startOfToday = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();
|
|
905
|
-
// Pins lead the listing (`
|
|
980
|
+
// Pins lead the listing (`#pinnedFirst`), so they get their own group ahead of the days.
|
|
906
981
|
const groups = visible.map(session =>
|
|
907
982
|
this.#pinnedIds.has(session.id) ? PINNED_GROUP : sessionDayGroup(session.modified, startOfToday),
|
|
908
983
|
);
|
|
@@ -1277,6 +1352,21 @@ class SessionList<T extends SessionSelectorEntry> implements Component {
|
|
|
1277
1352
|
this.requestDelete();
|
|
1278
1353
|
return;
|
|
1279
1354
|
}
|
|
1355
|
+
// F2 renames the selected session; as a non-printable key it never
|
|
1356
|
+
// collides with the search input.
|
|
1357
|
+
if (matchesKey(keyData, "f2")) {
|
|
1358
|
+
this.requestRename();
|
|
1359
|
+
return;
|
|
1360
|
+
}
|
|
1361
|
+
const keybindings = getKeybindings();
|
|
1362
|
+
if (keybindings.matches(keyData, "app.session.pin")) {
|
|
1363
|
+
this.requestPin(true);
|
|
1364
|
+
return;
|
|
1365
|
+
}
|
|
1366
|
+
if (keybindings.matches(keyData, "app.session.unpin")) {
|
|
1367
|
+
this.requestPin(false);
|
|
1368
|
+
return;
|
|
1369
|
+
}
|
|
1280
1370
|
// Up arrow
|
|
1281
1371
|
if (matchesSelectUp(keyData)) {
|
|
1282
1372
|
this.#selectionMoved = true;
|
|
@@ -1331,6 +1421,14 @@ class SessionList<T extends SessionSelectorEntry> implements Component {
|
|
|
1331
1421
|
|
|
1332
1422
|
export interface SessionSelectorOptions<T extends SessionSelectorEntry = SessionSelectorEntry> {
|
|
1333
1423
|
onDelete?: (session: T) => Promise<boolean>;
|
|
1424
|
+
/**
|
|
1425
|
+
* Rename the selected session to a user-supplied title; resolve with the
|
|
1426
|
+
* title as stored (the session canonicalizes it) or null when the rename
|
|
1427
|
+
* did not happen.
|
|
1428
|
+
*/
|
|
1429
|
+
onRename?: (session: T, title: string) => Promise<string | null>;
|
|
1430
|
+
/** Persist the selected session's pin state (pin keys / the picker's Pin action). */
|
|
1431
|
+
onSetPinned?: (session: T, pinned: boolean) => Promise<void>;
|
|
1334
1432
|
historyMatcher?: SessionHistoryMatcher;
|
|
1335
1433
|
/** Loads sessions across all projects for the all-projects scope toggle (Tab). */
|
|
1336
1434
|
loadAllSessions?: () => Promise<T[]>;
|
|
@@ -1378,15 +1476,21 @@ export interface SessionSelectorOptions<T extends SessionSelectorEntry = Session
|
|
|
1378
1476
|
export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSelectorEntry> extends OverlayPanel {
|
|
1379
1477
|
#sessionList: SessionList<T>;
|
|
1380
1478
|
#confirmationDialog: HookSelectorComponent | null = null;
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1479
|
+
/** Open rename dialog: an OverlayPanel hosting the rename TextFormField. */
|
|
1480
|
+
#renameDialog: OverlayPanel | null = null;
|
|
1481
|
+
/** The rename dialog's input; keystrokes route here while the dialog is open. */
|
|
1482
|
+
#renameField: TextFormField | null = null;
|
|
1483
|
+
// Hosts whichever of `#sessionList` / `#confirmationDialog` / `#renameDialog`
|
|
1484
|
+
// is live this frame. The delete dialog REPLACES the list in this slot rather
|
|
1485
|
+
// than being appended below the picker chrome, so the picker is always
|
|
1384
1486
|
// `chrome + max(list, dialog) + chrome` and never overflows the viewport
|
|
1385
1487
|
// (issue #3283: an overflowing dialog frame committed the header into
|
|
1386
1488
|
// scrollback, stranding it above the viewport once the dialog closed).
|
|
1387
1489
|
#contentSlot: Container;
|
|
1388
1490
|
#messageContainer: Container;
|
|
1389
1491
|
#onDelete?: (session: T) => Promise<boolean>;
|
|
1492
|
+
#onRename?: (session: T, title: string) => Promise<string | null>;
|
|
1493
|
+
#onSetPinned?: (session: T, pinned: boolean) => Promise<void>;
|
|
1390
1494
|
#onRequestRender?: () => void;
|
|
1391
1495
|
readonly #loadAllSessions?: () => Promise<T[]>;
|
|
1392
1496
|
#folderSessions: T[];
|
|
@@ -1431,6 +1535,7 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1431
1535
|
message: SessionPickerMessage | undefined;
|
|
1432
1536
|
errorOpen: boolean;
|
|
1433
1537
|
choice: DeleteChoice<T> | null;
|
|
1538
|
+
rename: OverlayPanel | null;
|
|
1434
1539
|
node: NativeNode;
|
|
1435
1540
|
}
|
|
1436
1541
|
| undefined;
|
|
@@ -1439,7 +1544,7 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1439
1544
|
title: string;
|
|
1440
1545
|
scope: "folder" | "all";
|
|
1441
1546
|
message: SessionPickerMessage | undefined;
|
|
1442
|
-
dialog: HookSelectorComponent | null;
|
|
1547
|
+
dialog: HookSelectorComponent | OverlayPanel | null;
|
|
1443
1548
|
list: NativeNode;
|
|
1444
1549
|
node: NativeNode;
|
|
1445
1550
|
}
|
|
@@ -1456,6 +1561,8 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1456
1561
|
|
|
1457
1562
|
this.#messageContainer = new Container();
|
|
1458
1563
|
this.#onDelete = options.onDelete;
|
|
1564
|
+
this.#onRename = options.onRename;
|
|
1565
|
+
this.#onSetPinned = options.onSetPinned;
|
|
1459
1566
|
this.#loadAllSessions = options.loadAllSessions;
|
|
1460
1567
|
this.#folderSessions = sessions;
|
|
1461
1568
|
// Storage directory, not recorded cwd: one folder's sessions may record
|
|
@@ -1505,6 +1612,16 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1505
1612
|
this.#showDeleteConfirmation(session);
|
|
1506
1613
|
};
|
|
1507
1614
|
}
|
|
1615
|
+
if (this.#onRename) {
|
|
1616
|
+
this.#sessionList.onRenameRequest = (session: T) => {
|
|
1617
|
+
this.#showRenameDialog(session);
|
|
1618
|
+
};
|
|
1619
|
+
}
|
|
1620
|
+
if (this.#onSetPinned) {
|
|
1621
|
+
this.#sessionList.onPinRequest = (session: T, pinned: boolean) => {
|
|
1622
|
+
void this.#setPinned(session, pinned);
|
|
1623
|
+
};
|
|
1624
|
+
}
|
|
1508
1625
|
if (this.#loadAllSessions || this.#globalSessions) {
|
|
1509
1626
|
this.#sessionList.onToggleScope = () => {
|
|
1510
1627
|
void this.#toggleScope();
|
|
@@ -1527,7 +1644,7 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1527
1644
|
* never pays for the cross-project scan.
|
|
1528
1645
|
*/
|
|
1529
1646
|
async #toggleScope(): Promise<void> {
|
|
1530
|
-
if (this.#toggling || this.#confirmationDialog) return;
|
|
1647
|
+
if (this.#toggling || this.#confirmationDialog || this.#renameDialog) return;
|
|
1531
1648
|
if (this.#scope === "folder") {
|
|
1532
1649
|
let global = this.#globalSessions;
|
|
1533
1650
|
if (!global) {
|
|
@@ -1651,6 +1768,107 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1651
1768
|
this.#onRequestRender?.();
|
|
1652
1769
|
}
|
|
1653
1770
|
|
|
1771
|
+
/**
|
|
1772
|
+
* Mirror a renamed title into the scope caches. The visible list holds
|
|
1773
|
+
* one entry per session, but the folder and all-projects caches can hold
|
|
1774
|
+
* their own copies of the same session, so a rename has to reach all of
|
|
1775
|
+
* them or a scope switch shows the old title again.
|
|
1776
|
+
*/
|
|
1777
|
+
#syncScopeTitles(sessionPath: string, title: string): void {
|
|
1778
|
+
for (const cache of [this.#folderSessions, this.#globalSessions]) {
|
|
1779
|
+
if (!cache) continue;
|
|
1780
|
+
const entry = cache.find(s => s.path === sessionPath);
|
|
1781
|
+
if (!entry) continue;
|
|
1782
|
+
entry.title = title;
|
|
1783
|
+
delete (entry as NativeSessionInfo)[kNativeItem];
|
|
1784
|
+
delete (entry as SearchableSessionInfo)[kSearchTextLower];
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
/** Close the rename dialog without changes, restoring the session list. */
|
|
1789
|
+
#closeRenameDialog(): void {
|
|
1790
|
+
if (!this.#renameDialog) return;
|
|
1791
|
+
this.#renameDialog = null;
|
|
1792
|
+
this.#renameField = null;
|
|
1793
|
+
// Restore the SessionList into the content slot so the picker is back
|
|
1794
|
+
// to its normal layout on the very next render — the same frame the
|
|
1795
|
+
// dialog disappears.
|
|
1796
|
+
this.#contentSlot.clear();
|
|
1797
|
+
this.#contentSlot.addChild(this.#sessionList);
|
|
1798
|
+
this.#onRequestRender?.();
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1801
|
+
#showRenameDialog(session: T): void {
|
|
1802
|
+
if (!this.#onRename || this.#confirmationDialog || this.#renameDialog || this.#toggling) return;
|
|
1803
|
+
// One submit at a time: a second Enter while the rename is still
|
|
1804
|
+
// awaiting disk I/O would queue a second write for the same session.
|
|
1805
|
+
let pending = false;
|
|
1806
|
+
// This editor's own identity: a submit that settles after the user
|
|
1807
|
+
// opened another editor must not close it.
|
|
1808
|
+
const owner = new OverlayPanel("Rename Session");
|
|
1809
|
+
const submit = async (value: string) => {
|
|
1810
|
+
if (pending) return;
|
|
1811
|
+
const title = value.trim();
|
|
1812
|
+
// Empty treated as cancel: Esc and a blank submit both leave the title.
|
|
1813
|
+
if (title.length === 0) {
|
|
1814
|
+
this.#closeRenameDialog();
|
|
1815
|
+
return;
|
|
1816
|
+
}
|
|
1817
|
+
const rename = this.#onRename;
|
|
1818
|
+
if (!rename) {
|
|
1819
|
+
this.#closeRenameDialog();
|
|
1820
|
+
return;
|
|
1821
|
+
}
|
|
1822
|
+
this.#clearError();
|
|
1823
|
+
pending = true;
|
|
1824
|
+
try {
|
|
1825
|
+
const stored = await rename(session, title);
|
|
1826
|
+
if (stored) {
|
|
1827
|
+
// The stored title is the canonical one (the session may
|
|
1828
|
+
// collapse whitespace), so the row and the search index
|
|
1829
|
+
// match what is on disk.
|
|
1830
|
+
this.#sessionList.renameSessionTitle(session.path, stored);
|
|
1831
|
+
this.#syncScopeTitles(session.path, stored);
|
|
1832
|
+
if (this.#preview?.session === session) this.#preview = undefined;
|
|
1833
|
+
} else {
|
|
1834
|
+
this.#showError("Failed to rename session.");
|
|
1835
|
+
}
|
|
1836
|
+
} catch (err) {
|
|
1837
|
+
this.#showError(err instanceof Error ? err.message : String(err));
|
|
1838
|
+
} finally {
|
|
1839
|
+
pending = false;
|
|
1840
|
+
}
|
|
1841
|
+
if (this.#renameDialog === owner) this.#closeRenameDialog();
|
|
1842
|
+
};
|
|
1843
|
+
const field = new TextFormField({
|
|
1844
|
+
theme: formTheme,
|
|
1845
|
+
label: "Rename session",
|
|
1846
|
+
initialValue: session.title ?? "",
|
|
1847
|
+
empty: "cancel",
|
|
1848
|
+
onSubmit: value => {
|
|
1849
|
+
void submit(value);
|
|
1850
|
+
},
|
|
1851
|
+
onCancel: () => {
|
|
1852
|
+
// A cancel while the rename is still in flight must not tear
|
|
1853
|
+
// the editor down underneath it; the submit closes it.
|
|
1854
|
+
if (pending) return;
|
|
1855
|
+
this.#closeRenameDialog();
|
|
1856
|
+
},
|
|
1857
|
+
});
|
|
1858
|
+
field.focused = true;
|
|
1859
|
+
owner.addChild(field);
|
|
1860
|
+
this.#renameDialog = owner;
|
|
1861
|
+
this.#renameField = field;
|
|
1862
|
+
// Swap the SessionList out of the content slot and mount the dialog in its
|
|
1863
|
+
// place: the dialog competes only with the SessionList's rendered budget,
|
|
1864
|
+
// never the SessionList AND the picker chrome, so the picker frame stays
|
|
1865
|
+
// inside the terminal viewport and the TUI never commits the header into
|
|
1866
|
+
// scrollback (issue #3283).
|
|
1867
|
+
this.#contentSlot.clear();
|
|
1868
|
+
this.#contentSlot.addChild(owner);
|
|
1869
|
+
this.#onRequestRender?.();
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1654
1872
|
/**
|
|
1655
1873
|
* Render the panel directly so fill-height mode can keep its footer pinned
|
|
1656
1874
|
* while sharing OverlayPanel's exact rounded-box chrome. Children receive
|
|
@@ -1675,14 +1893,37 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1675
1893
|
return lines;
|
|
1676
1894
|
}
|
|
1677
1895
|
|
|
1896
|
+
/** Persist a pin change, then reorder the list; a failure shows the error and leaves the list as it was. */
|
|
1897
|
+
async #setPinned(session: T, pinned: boolean): Promise<void> {
|
|
1898
|
+
if (!this.#onSetPinned) return;
|
|
1899
|
+
this.#clearError();
|
|
1900
|
+
try {
|
|
1901
|
+
await this.#onSetPinned(session, pinned);
|
|
1902
|
+
this.#sessionList.setPinned(session.id, pinned);
|
|
1903
|
+
} catch (err) {
|
|
1904
|
+
this.#showError(err instanceof Error ? err.message : String(err));
|
|
1905
|
+
}
|
|
1906
|
+
this.#onRequestRender?.();
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1909
|
+
/** The pin action that applies to the selected session: unpin when it is pinned, else pin. */
|
|
1910
|
+
#pinAction(): { binding: "app.session.pin" | "app.session.unpin"; label: string } | undefined {
|
|
1911
|
+
if (!this.#onSetPinned) return undefined;
|
|
1912
|
+
return this.#sessionList.selectedPinned
|
|
1913
|
+
? { binding: "app.session.unpin", label: "unpin" }
|
|
1914
|
+
: { binding: "app.session.pin", label: "pin" };
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1678
1917
|
/** Blank · keybinding hint · bottom border. Rendered by {@link render}. */
|
|
1679
1918
|
#footerLines(width: number): string[] {
|
|
1680
1919
|
const scopeHint = this.#scope === "all" ? "current folder" : "all projects";
|
|
1681
1920
|
// Keys mirror SessionList#handleInput; cancel is `app.interrupt` (raw Escape when unbound).
|
|
1682
1921
|
const cancel = interruptKey();
|
|
1922
|
+
const pin = this.#pinAction();
|
|
1923
|
+
const pinKey = pin && getKeybindings().getKeys(pin.binding)[0];
|
|
1683
1924
|
const hint = theme.fg(
|
|
1684
1925
|
"muted",
|
|
1685
|
-
`[${this.#onDelete ? `${formatKeyHints(["delete", "backspace"])} delete · ` : ""}${formatKeyHint("enter")} select · ${formatKeyHint("tab")} ${scopeHint} · ${cancel} cancel]`,
|
|
1926
|
+
`[${this.#onDelete ? `${formatKeyHints(["delete", "backspace"])} delete · ` : ""}${this.#onRename ? `${formatKeyHint("f2")} rename · ` : ""}${pinKey ? `${formatKeyHint(pinKey)} ${pin.label} · ` : ""}${formatKeyHint("enter")} select · ${formatKeyHint("tab")} ${scopeHint} · ${cancel} cancel]`,
|
|
1686
1927
|
);
|
|
1687
1928
|
return [row("", width), row(hint, width), row("", width), bottomBorder(width)];
|
|
1688
1929
|
}
|
|
@@ -1694,24 +1935,32 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1694
1935
|
|
|
1695
1936
|
/** Over the transcript the picker is its own sheet (`layer`); the standalone app fills the screen surface. */
|
|
1696
1937
|
nativeSheet(cx: DescribeContext): boolean {
|
|
1938
|
+
// A rename editor is a card with a text field, not a picker sheet: it
|
|
1939
|
+
// renders in place, like the generic composition does.
|
|
1940
|
+
if (this.#renameDialog) return false;
|
|
1697
1941
|
return cx.supports("picker") && !this.#standalone;
|
|
1698
1942
|
}
|
|
1699
1943
|
|
|
1700
1944
|
/**
|
|
1701
1945
|
* With the `picker` kind: the data-first session picker (§4.7). Otherwise
|
|
1702
1946
|
* scope `tabs`, loading/error message, then the search `input` and session
|
|
1703
|
-
* `list` — or the delete-confirmation dialog in their place, as on
|
|
1704
|
-
* path — and the key-hint footer.
|
|
1947
|
+
* `list` — or the delete-confirmation / rename dialog in their place, as on
|
|
1948
|
+
* the ANSI path — and the key-hint footer.
|
|
1705
1949
|
*/
|
|
1706
1950
|
override describe(cx: DescribeContext): NativeNode {
|
|
1707
|
-
|
|
1951
|
+
// The picker kind has no text-input affordance, so a rename would
|
|
1952
|
+
// capture every keystroke into an invisible field. While the rename
|
|
1953
|
+
// editor is open, describe the card path instead (the same fallback
|
|
1954
|
+
// the hook selector uses for its slider and countdown).
|
|
1955
|
+
if (cx.supports("picker") && !this.#renameDialog) return this.#describePicker();
|
|
1708
1956
|
const list = this.#sessionList.describeList();
|
|
1957
|
+
const dialog = this.#confirmationDialog ?? this.#renameDialog;
|
|
1709
1958
|
const memo = this.#nativeMemo;
|
|
1710
1959
|
if (
|
|
1711
1960
|
memo?.title === this.title &&
|
|
1712
1961
|
memo.scope === this.#scope &&
|
|
1713
1962
|
memo.message === this.#message &&
|
|
1714
|
-
memo.dialog ===
|
|
1963
|
+
memo.dialog === dialog &&
|
|
1715
1964
|
memo.list === list
|
|
1716
1965
|
) {
|
|
1717
1966
|
return memo.node;
|
|
@@ -1725,13 +1974,16 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1725
1974
|
} else if (message) {
|
|
1726
1975
|
children.push(node("text", { spans: [span(message.text, "error")] }, undefined, "message"));
|
|
1727
1976
|
}
|
|
1728
|
-
if (
|
|
1729
|
-
children.push(
|
|
1977
|
+
if (dialog) {
|
|
1978
|
+
children.push(dialog);
|
|
1730
1979
|
} else {
|
|
1731
1980
|
children.push(this.#sessionList.searchInput, list);
|
|
1732
1981
|
}
|
|
1733
1982
|
const hints: (NativeHint | undefined)[] = [];
|
|
1734
1983
|
if (this.#onDelete) hints.push({ keys: ["delete", "backspace"], label: "delete" });
|
|
1984
|
+
if (this.#onRename) hints.push({ keys: ["f2"], label: "rename" });
|
|
1985
|
+
const pin = this.#pinAction();
|
|
1986
|
+
if (pin) hints.push(actionHint(pin.binding, pin.label));
|
|
1735
1987
|
hints.push({ keys: ["enter"], label: "select" });
|
|
1736
1988
|
if (this.#sessionList.onToggleScope) {
|
|
1737
1989
|
hints.push({ keys: ["tab"], label: this.#scope === "all" ? "current folder" : "all projects" });
|
|
@@ -1745,7 +1997,7 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1745
1997
|
title: this.title,
|
|
1746
1998
|
scope: this.#scope,
|
|
1747
1999
|
message,
|
|
1748
|
-
dialog
|
|
2000
|
+
dialog,
|
|
1749
2001
|
list,
|
|
1750
2002
|
node: result,
|
|
1751
2003
|
};
|
|
@@ -1756,8 +2008,9 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1756
2008
|
* `lg` cards sheet (`screen` for the standalone app): sessions grouped by
|
|
1757
2009
|
* day (ranked flat while searching), the selected session's preview, the
|
|
1758
2010
|
* delete confirm strip, and the actions of the keys Enter, Delete/Backspace,
|
|
1759
|
-
*
|
|
1760
|
-
*
|
|
2011
|
+
* F2 (rename), the pin keys (Pin / Unpin, whichever applies to the selected
|
|
2012
|
+
* session), Tab (the scope toggle, labelled with the scope it switches
|
|
2013
|
+
* to) and Esc. Untitled unless the caller named it; the placeholder says the scope.
|
|
1761
2014
|
*/
|
|
1762
2015
|
#describePicker(): NativeNode {
|
|
1763
2016
|
const list = this.#sessionList;
|
|
@@ -1766,6 +2019,7 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1766
2019
|
const message = this.#message;
|
|
1767
2020
|
const errorOpen = this.#pickerErrorOpen && message?.kind === "error";
|
|
1768
2021
|
const choice = this.#deleteChoice;
|
|
2022
|
+
const rename = this.#renameDialog;
|
|
1769
2023
|
const memo = this.#pickerMemo;
|
|
1770
2024
|
if (
|
|
1771
2025
|
memo?.view === view &&
|
|
@@ -1773,7 +2027,8 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1773
2027
|
memo.scope === this.#scope &&
|
|
1774
2028
|
memo.message === message &&
|
|
1775
2029
|
memo.errorOpen === errorOpen &&
|
|
1776
|
-
memo.choice === choice
|
|
2030
|
+
memo.choice === choice &&
|
|
2031
|
+
memo.rename === rename
|
|
1777
2032
|
) {
|
|
1778
2033
|
return memo.node;
|
|
1779
2034
|
}
|
|
@@ -1781,6 +2036,9 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1781
2036
|
const toggle = list.onToggleScope !== undefined;
|
|
1782
2037
|
const actions = [pickerAction("resume", this.#actionLabel, "enter", { primary: true })];
|
|
1783
2038
|
if (this.#onDelete) actions.push(pickerAction("delete", "Delete", "backspace"));
|
|
2039
|
+
if (this.#onRename) actions.push(pickerAction("rename", "Rename", "f2"));
|
|
2040
|
+
const pin = this.#pinAction();
|
|
2041
|
+
if (pin) actions.push(pickerAction("pin", pin.label === "pin" ? "Pin" : "Unpin", bindingKeys(pin.binding)));
|
|
1784
2042
|
if (toggle) {
|
|
1785
2043
|
actions.push(pickerAction("scope", this.#scope === "all" ? "This folder" : "All projects", "tab"));
|
|
1786
2044
|
}
|
|
@@ -1831,7 +2089,7 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1831
2089
|
},
|
|
1832
2090
|
preview,
|
|
1833
2091
|
);
|
|
1834
|
-
this.#pickerMemo = { view, preview, scope: this.#scope, message, errorOpen, choice, node: result };
|
|
2092
|
+
this.#pickerMemo = { view, preview, scope: this.#scope, message, errorOpen, choice, rename, node: result };
|
|
1835
2093
|
return result;
|
|
1836
2094
|
}
|
|
1837
2095
|
|
|
@@ -1867,27 +2125,32 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1867
2125
|
|
|
1868
2126
|
/**
|
|
1869
2127
|
* Picker pointer events run the keys' paths: a row click selects (arrows),
|
|
1870
|
-
* a second click or `Resume` resumes (Enter), `Delete` asks (Delete),
|
|
1871
|
-
* tab or `All projects` toggles scope (Tab),
|
|
1872
|
-
* the confirm strip answers the delete dialog (Yes / Esc).
|
|
2128
|
+
* a second click or `Resume` resumes (Enter), `Delete` asks (Delete),
|
|
2129
|
+
* `Rename` renames (F2), `Pin` / `Unpin` flips the pin, the tab or `All projects` toggles scope (Tab),
|
|
2130
|
+
* `Close` cancels (Esc), and the confirm strip answers the delete dialog (Yes / Esc).
|
|
1873
2131
|
*/
|
|
1874
2132
|
#handlePickerEvent(ev: PickerEvent): void {
|
|
1875
2133
|
const list = this.#sessionList;
|
|
1876
2134
|
const choice = this.#deleteChoice;
|
|
1877
2135
|
if (ev.kind !== "action") {
|
|
1878
|
-
if (choice) return;
|
|
2136
|
+
if (choice || this.#renameDialog) return;
|
|
1879
2137
|
if (ev.kind === "select") list.selectSession(ev.item);
|
|
1880
2138
|
else list.confirmSession(ev.item);
|
|
1881
2139
|
return;
|
|
1882
2140
|
}
|
|
1883
2141
|
if (ev.act === "delete-confirm") choice?.confirm();
|
|
1884
|
-
else if (ev.act === "cancel")
|
|
1885
|
-
|
|
2142
|
+
else if (ev.act === "cancel") {
|
|
2143
|
+
if (choice) choice.cancel();
|
|
2144
|
+
else this.#closeRenameDialog();
|
|
2145
|
+
} else if (ev.act === "close") {
|
|
1886
2146
|
if (choice) choice.cancel();
|
|
2147
|
+
else if (this.#renameDialog) this.#closeRenameDialog();
|
|
1887
2148
|
else list.onCancel?.();
|
|
1888
|
-
} else if (choice) return;
|
|
2149
|
+
} else if (choice || this.#renameDialog) return;
|
|
1889
2150
|
else if (ev.act === "resume") list.resumeSelected();
|
|
1890
2151
|
else if (ev.act === "delete") list.requestDelete();
|
|
2152
|
+
else if (ev.act === "rename") list.requestRename();
|
|
2153
|
+
else if (ev.act === "pin") list.requestPin();
|
|
1891
2154
|
else if (ev.act === "scope") {
|
|
1892
2155
|
list.onToggleScope?.();
|
|
1893
2156
|
} else if (ev.act === "clear") list.clearSearch();
|
|
@@ -1907,7 +2170,8 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1907
2170
|
if (event.type === "select" && event.item !== this.#scope) void this.#toggleScope();
|
|
1908
2171
|
return;
|
|
1909
2172
|
}
|
|
1910
|
-
if (event.key === "list" && !this.#confirmationDialog
|
|
2173
|
+
if (event.key === "list" && !this.#confirmationDialog && !this.#renameDialog)
|
|
2174
|
+
this.#sessionList.confirmSession(event.item);
|
|
1911
2175
|
}
|
|
1912
2176
|
|
|
1913
2177
|
handleInput(keyData: string): void {
|
|
@@ -1919,6 +2183,8 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1919
2183
|
}
|
|
1920
2184
|
if (this.#confirmationDialog) {
|
|
1921
2185
|
this.#confirmationDialog.handleInput(keyData);
|
|
2186
|
+
} else if (this.#renameDialog) {
|
|
2187
|
+
this.#renameField?.handleInput(keyData);
|
|
1922
2188
|
} else {
|
|
1923
2189
|
this.#sessionList.handleInput(keyData);
|
|
1924
2190
|
}
|
|
@@ -1931,7 +2197,7 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1931
2197
|
* pointer. Mouse is inert while the delete-confirmation dialog is open.
|
|
1932
2198
|
*/
|
|
1933
2199
|
#handleMouse(data: string): void {
|
|
1934
|
-
if (this.#confirmationDialog) return;
|
|
2200
|
+
if (this.#confirmationDialog || this.#renameDialog) return;
|
|
1935
2201
|
routeSgrMouseInput(data, event => {
|
|
1936
2202
|
if (event.wheel !== null) {
|
|
1937
2203
|
this.#sessionList.handleWheel(event.wheel);
|
|
@@ -435,22 +435,15 @@ function clockTime(date: Date): string {
|
|
|
435
435
|
}
|
|
436
436
|
|
|
437
437
|
/**
|
|
438
|
-
* When a window resets,
|
|
439
|
-
*
|
|
440
|
-
*
|
|
438
|
+
* When a window resets, `resetMs` from `nowMs`: the countdown (`resets in
|
|
439
|
+
* 2h30m`), which reads the same in every time zone; the title carries the
|
|
440
|
+
* local date and time.
|
|
441
441
|
*/
|
|
442
442
|
function resetLabel(nowMs: number, resetMs: number): { text: string; title: string } {
|
|
443
443
|
const at = new Date(nowMs + resetMs);
|
|
444
|
-
const now = new Date(nowMs);
|
|
445
|
-
const sameDay = at.toDateString() === now.toDateString();
|
|
446
|
-
const text = sameDay
|
|
447
|
-
? `resets ${clockTime(at)}`
|
|
448
|
-
: resetMs < 6 * 86_400_000
|
|
449
|
-
? `resets ${WEEKDAY_NAMES[at.getDay()]} ${clockTime(at)}`
|
|
450
|
-
: `resets ${at.getDate()} ${MONTH_NAMES[at.getMonth()]}`;
|
|
451
444
|
return {
|
|
452
|
-
text
|
|
453
|
-
title: `Resets ${shortDate(at)} ${at.getFullYear()}, ${clockTime(at)}
|
|
445
|
+
text: `resets in ${formatDuration(resetMs)}`,
|
|
446
|
+
title: `Resets ${shortDate(at)} ${at.getFullYear()}, ${clockTime(at)}`,
|
|
454
447
|
};
|
|
455
448
|
}
|
|
456
449
|
|