projmux 0.4.5 → 0.4.7

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.
@@ -0,0 +1,228 @@
1
+ # Native Picker Engine
2
+
3
+ This note tracks the native picker engine. Native is the default picker backend,
4
+ while the `internal/ui/fzf` backend remains available as an explicit fallback.
5
+
6
+ The fzf compatibility surface for the native engine is tracked in
7
+ [native-picker-parity.md](native-picker-parity.md).
8
+
9
+ ## What This Covers
10
+
11
+ - `internal/ui/picker` is the backend-neutral contract for native picker rows,
12
+ actions, filtering, and typed-query prompts.
13
+ - `internal/ui/projmuxpicker` is the projmux-specific native picker surface for
14
+ frame, redraw updates, theme tokens, ANSI width/truncation,
15
+ prompt/footer/list rendering, and preview pane layout. The POC keeps `picker`
16
+ responsible for backend routing, keyboard input, filtering, preview command
17
+ execution, and result contracts, while moving visual composition into
18
+ `projmuxpicker` so projmux can evolve a native picker design without coupling
19
+ every visual tweak to the fzf adapter.
20
+ - `internal/ui/fzf` now owns the adapter between fzf's legacy option/result
21
+ shape and the backend-neutral `picker.Options` contract. App code should
22
+ describe picker intent as rows, actions, preview commands, and initial focus;
23
+ the fzf adapter is responsible for translating that into `--expect`,
24
+ `--bind execute-silent(...)`, `+refresh-preview`, and `start:pos(N)`.
25
+ - `intfzf.NewPickerRunner()` wraps fzf behind the same `picker.Runner`
26
+ interface as the native runner. This is the current DI boundary for swapping
27
+ picker engines while keeping fzf available.
28
+ - Settings > Labs > Picker Engine stores the backend selection in
29
+ `~/.config/projmux/picker-backend` and updates the live tmux environment so
30
+ new picker popups can switch between `fzf` and `native` without restarting
31
+ the app server.
32
+ - Native is the default backend. `PROJMUX_PICKER_BACKEND=fzf` remains an
33
+ explicit environment override and takes priority over the saved Labs setting.
34
+ - Picker flows covered by the native path include AI picker/settings, shell
35
+ update prompt, settings hub sections, switch settings/add-pin, the main
36
+ project switcher list, recent sessions, and notify sidebar.
37
+ - The native picker supports ranked fuzzy search/filter, arrow-key selection in
38
+ normal CSI and tmux application-cursor modes, Enter, Esc, Ctrl-C, Backspace,
39
+ Ctrl-U, Ctrl-W, PageUp/PageDown, Home/End, modified CSI keys, custom expect
40
+ keys such as Ctrl-X/Alt-P, printable expect keys such as notify `x`, control
41
+ expect keys such as notify `Ctrl-X`, `start:pos(N)` initial focus, preview
42
+ command output, preview cycle command bindings, and sidebar focus command
43
+ bindings.
44
+ - FZF-style movement keys are supported for native selection: `Ctrl-N` moves
45
+ down, while `Ctrl-P` and `Ctrl-K` move up unless the app claims the key as a
46
+ custom action.
47
+ - Typed-query prompts support cursor-aware insertion/deletion with a visible
48
+ prompt cursor, Left/Right, Ctrl-A/E, Delete, Backspace, Ctrl-U, and Ctrl-W
49
+ for settings path entry.
50
+ - The native key parser recognizes the app's CSI-u keybind-probe sequences
51
+ such as `ESC [ 9005 u` for `Alt-1`, plus generic modified CSI-u forms such as
52
+ `ESC [ 115 ; 7 u` for `Ctrl-Alt-S`.
53
+ - Native interactive picker screens use an alternate screen lifecycle to better
54
+ match fzf fullscreen behavior and restore the tmux pane after exit. Frame
55
+ updates and screen exit both return to column 0 before emitting terminal
56
+ control sequences, and screen exit resets styles plus clears the alternate
57
+ buffer from the home cursor before restore. This keeps restore/update escapes
58
+ and selected-session handoff output from visually trailing the bottom border
59
+ in tmux/script captures. Native also gives real TTY screen restore a short
60
+ settle window before returning to callers that may immediately draw a tmux
61
+ session.
62
+ - Native interactive picker screens render inside a full-screen border frame to
63
+ match the app's fzf `--height 100% --border` surface more closely.
64
+ - Popup-toggle commands use tmux `display-popup -B` when the native backend is
65
+ active so the native picker owns the visible frame and does not double-draw
66
+ with tmux's outer popup border.
67
+ - Native Alt-1 sidebar popups use the same responsive width calculation as fzf
68
+ with a smaller native-only minimum, so the borderless native frame is not
69
+ wider than the existing fzf sidebar surface on normal terminals.
70
+ - Native Alt-2 notify sidebar popups keep the fzf baseline width contract
71
+ (`24%`, minimum `64`) while still letting the native picker own the frame.
72
+ - Native sidebar popups reserve two rows at the bottom for the tmux statusbar
73
+ area instead of using the full client height.
74
+ - Simple native lists use the available terminal height after header, prompt,
75
+ footer, and preview reservations instead of a fixed page-sized viewport.
76
+ - Navigation-only native lists mirror fzf `--disabled --no-input`: the input
77
+ prompt is hidden, printable non-action keys do not alter the query, and
78
+ expect/action keys still work.
79
+ - Native frame content now uses the full inner border width so prompt/list/footer
80
+ separators reach the right border like fzf.
81
+ - Native frames can render an optional picker-owned titlebar row below the top
82
+ border when `picker.Options.Title` is set; empty titles keep the default frame
83
+ unchanged. The native Alt-1 project sidebar uses this for a `Projects`
84
+ titlebar.
85
+ - Native width/truncation uses terminal cell width for Korean/CJK text, emoji,
86
+ and combining marks instead of raw rune count, so localized project names and
87
+ decorated notify headers do not push the right frame border out of alignment.
88
+ - Searchable native pickers draw an explicit `Search` label and a muted
89
+ separator under the prompt/count line so the query area reads as distinct
90
+ chrome rather than the first row of the list. Footer, down-preview, and
91
+ multi-line card gaps share the same `projmuxpicker` separator primitive for a
92
+ more consistent native surface.
93
+ - Native interactive mode enables SGR mouse reporting while the alternate screen
94
+ is active. Primary click applies the clicked row, release events are ignored,
95
+ mouse wheel moves selection up/down, and reporting is disabled again during
96
+ screen restore.
97
+ - When terminal size detection is unavailable, native picker falls back to a
98
+ conservative 80x24 terminal instead of assuming a wider surface. Interactive
99
+ tmux popups still use the detected popup size when `stty size` is available.
100
+ - Simple and multi-line native rows share the same projmux current-row style and
101
+ pointer marker rather than falling back to terminal inverse video for simple
102
+ pickers.
103
+ - Selected multi-line rows use the same pointer-width `▌` continuation marker
104
+ as the first selected project line, so switch/session/notify cards read as one
105
+ focused block.
106
+ - Pointer and continuation markers render inside the current-row gutter style so
107
+ selected cards do not visually break between the marker and row content.
108
+ - Native redraws use terminal synchronized-update wrappers and coalesced
109
+ row-diff updates after the first frame. The frame/redraw renderer lives in
110
+ `projmuxpicker` rather than the backend loop, skips unchanged frames, and
111
+ avoids a trailing newline after the bottom border. This reduces visible
112
+ keyboard-navigation flicker and prevents exact-height popups from scrolling
113
+ the top border off screen.
114
+ - Native preview panes normalize tabs and control bytes before horizontal
115
+ clipping, preventing long preview rows from wrapping and consuming extra
116
+ vertical viewport rows in Alt-3/session popups.
117
+ - Native sidebar list scrollbars use the fixed list viewport as their track and
118
+ measure multi-line cards in rendered rows, so the thumb does not shrink or
119
+ jump when card heights vary.
120
+ - Switch picker git branch badges are capped more tightly for the native card
121
+ surface, so inactive branch backgrounds do not dominate narrow Alt-1 sidebar
122
+ rows.
123
+ - Native selection changes render their frame diff before running sidebar focus
124
+ commands, so tmux focus/switch side effects do not delay the visible picker
125
+ movement.
126
+ - In app TTY contexts, the native picker opens the controlling terminal
127
+ (`/dev/tty`) before entering raw mode. This avoids stdin/stdout mismatch and
128
+ line-mode escape leakage such as arrow keys appearing as `^[[`.
129
+ - Raw TTY reads keep polling briefly across empty reads while decoding
130
+ escape-key sequences, so split arrow/Alt key bytes are consumed by the picker
131
+ instead of leaking into the query or parent shell.
132
+
133
+ ## Experimental Boundaries
134
+
135
+ - The `projmuxpicker` package is intended as a foundation that can be carried
136
+ forward, along with the fzf-to-picker adapter boundary in `internal/ui/fzf`.
137
+ Its frame, row, preview, theme, ANSI, and redraw modules are foundation code;
138
+ Docker sandbox scripts and dependency-policy notes remain support
139
+ scaffolding.
140
+ - Switch and sessions preview panes are native previews for the concrete
141
+ projmux option shapes. Wide right-side preview windows render beside the
142
+ list, and sidebar-style `down,25%,border-top` previews render below the list
143
+ without a synthetic preview title row, using fzf-measured percent sizing.
144
+ Preview rows are padded by `projmuxpicker` to the full preview surface width
145
+ before the outer frame is applied, which keeps split/down preview columns
146
+ visually stable during redraws.
147
+ The full fzf preview-window grammar remains outside this POC surface.
148
+ - Preview cycle state is covered in Docker e2e against real tmux sessions: the
149
+ switch and sessions popup flows type a filtered query, send `Right` and
150
+ `Alt-Down`, and assert the stored preview window/pane cursor for the selected
151
+ session.
152
+ - Public doctor dependency policy remains separate from picker backend
153
+ selection. Native is the default picker backend, and fzf remains available as
154
+ an explicit fallback.
155
+
156
+ ## Interactive No-fzf Sandbox
157
+
158
+ Use this when you want to enter a Docker container and experience this build
159
+ directly without `fzf`. It builds the no-fzf dependency image, mounts this
160
+ worktree, builds `projmux` inside the container, creates sample projects under
161
+ `/workspace/projects`, stores the native picker backend in the sandbox config,
162
+ writes a tmux config with the same backend in the tmux server environment, and
163
+ launches `projmux shell`. It also forces UTF-8 locale inside the container. This
164
+ uses `wt path` instead of `wt run` because `docker run -it` needs the current
165
+ terminal TTY:
166
+
167
+ ```sh
168
+ bash "$(wt path poc/native-picker-no-fzf)/scripts/poc-native-picker-no-fzf-sandbox.sh"
169
+ ```
170
+
171
+ Inside the tmux shell, try:
172
+
173
+ ```sh
174
+ projmux switch
175
+ projmux settings
176
+ projmux doctor --json
177
+ ```
178
+
179
+ Manual UX checks for the Docker sandbox:
180
+
181
+ - Alt-1 opens with the top border/title visible, not clipped.
182
+ - Vertical borders stay continuous while moving Up/Down.
183
+ - Alt-1 closes the sidebar immediately when pressed again.
184
+ - Alt-2, Alt-3, Alt-4, and Alt-5 open their matching native popups and close
185
+ on the same Alt key immediately.
186
+ - Arrow keys move selection without leaking `^[[` text into the query.
187
+
188
+ `fzf` is intentionally not installed in the image.
189
+
190
+ ## Automated No-fzf Docker E2E Command
191
+
192
+ Run this from the repository root. It builds a Go 1.24 Trixie no-fzf
193
+ dependency image from `test/docker/no-fzf-poc.Dockerfile`, including Go module
194
+ cache, then mounts the repository into an isolated `--network none` container,
195
+ builds `projmux`, asserts `fzf` is not on `PATH`, runs the focused native-picker
196
+ tests, stores the native backend through Settings > Labs, verifies the saved
197
+ backend works without an env override, exercises `projmux switch --ui=sidebar`
198
+ search/selection under a container PTY,
199
+ exercises `projmux switch --ui=popup` and `projmux sessions --ui=popup` against
200
+ existing tmux sessions under a wide 150x30 PTY, sends `Right` and `Alt-Down`
201
+ once to smoke the preview-cycle bindings, asserts those popup flows stay on the
202
+ right-side preview layout instead of falling back to inline preview, asserts the
203
+ explicit `Search` chrome across the searchable native picker surfaces, launches
204
+ `projmux shell` under a container PTY, verifies
205
+ that it creates a tmux session, verifies immediate launch-key close behavior for
206
+ Alt-1 through Alt-5 native popup surfaces, exercises `notify list --ui=sidebar`
207
+ with the printable `x` expect key, and exercises the settings picker under a PTY
208
+ using Enter and arrow-key navigation through the native backend. Settings flows
209
+ must keep stderr clean in the no-tmux-server container; tmux no-server noise is
210
+ treated as an e2e failure.
211
+
212
+ Short tmux-friendly form:
213
+
214
+ ```sh
215
+ wt run poc/native-picker-no-fzf -- scripts/poc-native-picker-no-fzf-e2e.sh
216
+ ```
217
+
218
+ The script contains the Docker image build and isolated `docker run` command:
219
+
220
+ ```sh
221
+ scripts/poc-native-picker-no-fzf-e2e.sh
222
+ ```
223
+
224
+ To compare another base image without editing the repo, override the build arg:
225
+
226
+ ```sh
227
+ PROJMUX_POC_NO_FZF_BASE_IMAGE=golang:1.24-bookworm bash "$(wt path poc/native-picker-no-fzf)/scripts/poc-native-picker-no-fzf-sandbox.sh"
228
+ ```
@@ -0,0 +1,145 @@
1
+ # Native Picker fzf Parity Map
2
+
3
+ This audit note reverse-engineers the subset of fzf behavior that projmux
4
+ currently uses and maps it to native picker evidence. It supports the default
5
+ native picker engine and is not a public dependency-policy change.
6
+
7
+ ## App fzf Surface
8
+
9
+ | fzf surface | projmux usage | Native status | Evidence |
10
+ | --- | --- | --- | --- |
11
+ | `--prompt` | AI, settings, shell update, switch, sessions, notify | Covered | `renderNativeInteractive`, `renderNative`; `TestNativePromptLineIncludesInlineMatchCount` |
12
+ | prompt/list separation | native searchable picker chrome | Covered | native renders an explicit `Search` header label plus a separator under searchable prompt/count lines; `TestNativeInteractiveSeparatesSearchHeaderFromList`; Docker no-fzf e2e asserts the `Search` header in Settings, AI settings, mouse-click, switch sidebar, switch popup, sessions popup, and shell Alt-1 PTY logs |
13
+ | `--height 100%` / `--border` | all interactive picker screens | Covered for fullscreen rounded border frame | `renderNativeFrame`; screen-height list budgeting; conservative 80x24 fallback only when terminal size detection is unavailable; `TestNativeInteractiveRendersBorderFrame`; `TestNativeInteractiveUsesAvailableHeightForSimpleLists` |
14
+ | `--header` | AI, settings, shell update, notify | Covered | `renderNativeInteractive`, `renderNative`; settings native tests |
15
+ | `--footer` / `--footer-border line` | AI, settings, shell update, switch, sessions, notify | Covered for interactive native screens | `renderNativeInteractive` reserves bottom footer space and renders a separator line; `TestNativeInteractiveRendersFooterAtBottom` |
16
+ | `--ansi` | colored row labels from render package | Covered | native writes row labels directly, strips ANSI escapes from default search text, restores selected-row styling after embedded ANSI resets, and measures rendered cell width for Korean/CJK text, emoji, and combining marks; `TestFilterItemsIgnoresANSIEscapeSequences`; `TestNativeInteractiveUsesCurrentStyleForSimpleSelection`; `TestVisibleLenUsesTerminalCellWidth`; Docker e2e shows ANSI rows |
17
+ | hidden value after tab delimiter | all picker selections and default fzf matching | Covered by `picker.Item.Value` and default search text | `fzf.PickerOptions`; `TestNativeRunnerFiltersAndSelectsByNumber`; `TestFilterItemsSearchesHiddenValueWhenNoSearchKey` |
18
+ | plain fzf candidates without structured entries | legacy runner call shape | Covered | `fzf.PickerOptions`; `TestPickerOptionsFromFZFMapsCandidatesWhenEntriesAreEmpty` |
19
+ | search key filtering (`--nth`/reload filter file) | switch/sessions/notify entries | Covered by `Item.SearchText` with fzf reload order preservation | `FilterItems`; `TestFilterItemsUsesSearchTextNotMetadata`; `TestFilterItemsPreservesSearchKeyOrder` |
20
+ | default `--smart-case` matching | all searchable picker rows | Covered | native filter keeps lower-case queries case-insensitive and uppercase queries case-sensitive; `TestFilterItemsUsesFZFSmartCase` |
21
+ | fzf match highlighting | searchable simple picker rows | Covered for non-search-key simple rows | native highlights matched visible label runes while preserving embedded ANSI style; search-key reload lists intentionally keep fzf disabled-filter rendering without match highlights; `TestNativeInteractiveHighlightsSimpleQueryMatches`; `TestNativeInteractiveDoesNotHighlightSearchKeyReloadLists` |
22
+ | `--disabled --no-input` | navigation-only notify sidebar | Covered | native suppresses prompt/query editing and ignores printable non-action input; `TestNativeInteractiveDisableSearchIgnoresPrintableInput`; Docker no-fzf e2e asserts notify prompt is hidden |
23
+ | fuzzy result ranking | simple non-search-key picker UX | Covered with fzf V2 dynamic scoring for normal app rows | `fuzzyScore`; `TestFilterItemsRanksBetterMatchesFirst`; `TestFilterItemsPrefersFZFBoundaryAndCamelCaseMatches`; `TestFuzzyScoreMatchesFZFV2ReferenceScores` |
24
+ | `--scrollbar █` | long switch/session/settings lists | Covered for app lists | `nativeListLinesWithScrollbarRows`; proportional multi-row thumb rendering in `projmuxpicker`; split-preview and sidebar list viewports keep a fixed row budget and scrollbar track; multi-line cards use rendered-row scroll units; `TestNativeInteractiveUsesScrollbarForLongLists`; `TestListLinesWithScrollbarUsesProportionalThumb`; `TestListLinesWithScrollbarMovesThumbGradually`; `TestListLinesWithScrollbarRowsKeepsViewportTrack`; `TestRenderSplitPreviewRowsKeepsRequestedViewport`; `TestNativeListScrollbarUnitsUseRenderedRowsForMultiline`; `TestNativeInteractiveKeepsMultilineScrollbarOnViewportTrack` |
25
+ | `--read0` multi-line rows | switch, sessions, notify | Covered | `Options.MultiLine`; `TestNativeInteractiveRendersFZFLikeMultilineSelection` |
26
+ | `--gap --gap-line ─` | switch, sessions, notify multi-line rows | Covered for app multiline rows | `nativeGapLine`, row-budgeted range; `TestNativeInteractiveRendersMultilineGapLine`, `TestNativeVisibleRangeCountsMultilineRenderedRows` |
27
+ | selected multi-line marker | selected switch/session/notify cards | Covered for app multiline rows | native uses the same compact pointer-width red `▌` gutter as the first selected project line, and metadata lines align to the project-name column without the old deeper indent; `nativeContinuation`; `TestNativeInteractiveRendersSelectedMultilineContinuationMarker`; `TestInteractiveRowLinesUsesCompactSelectedMetaIndent`; `TestInteractiveRowLinesAlignsUnselectedMetaWithProjectName` |
28
+ | fzf current row colors | simple and multi-line rows | Covered for app rows | `nativeCurrentStart`, `nativePointer`; pointer/continuation gutter tokens carry the current-row background; `TestNativeSelectedContentKeepsCurrentStyleAfterReset`; `TestNativeInteractiveUsesCurrentStyleForSimpleSelection` |
29
+ | `--expect` keys | Enter/Ctrl-X/Alt-P/notify keys | Covered | `fzf.PickerOptions`; `TestNativeInteractiveSupportsCustomExpectKeys` |
30
+ | printable expect keys | notify sidebar `x` ack | Covered | `TestNativeInteractiveSupportsPrintableExpectKeys`; Docker no-fzf e2e |
31
+ | control expect keys | notify sidebar `Ctrl-X`, settings `Ctrl-Alt-S` close | Covered | `TestNativeInteractiveSupportsControlExpectKeys`; `TestNativeInteractiveSupportsControlAltCloseKeys` |
32
+ | close `--bind key:abort` | Esc, Ctrl-C, Alt-N, Ctrl-Alt-S variants | Covered | `CloseActions`; `TestNativeRunnerUsesSharedCloseActions` |
33
+ | terminal CSI-u key encoding | app keybind probe sequences, Ghostty/kitty-style modified keys | Covered | native handles app-specific Alt keys, generic modified letters/digits, and non-text keys such as Enter/Esc/Backspace/Tab; `TestNativeInteractiveSupportsCSIuAppKeyBindings` |
34
+ | `execute-silent(...)+refresh-preview` | switch/session preview cycling | Covered for command execution and rerender loop | `fzf.PickerOptions`/`fzf.OptionsFromPicker`; `TestNativeInteractiveRunsCustomActionCommandAndRefreshes`; `TestPickerOptionsMapsFZFBindingsToContractActions`; Docker no-fzf e2e sends `Right` and `Alt-Down` before selection |
35
+ | `focus:execute-silent(...)` | switch sidebar focus | Covered | native renders the selection frame diff before running sidebar focus commands so movement stays visible before tmux focus side effects; `runNativeFocusAction`; `TestNativeInteractiveRunsFocusActionOnSelectionChange` |
36
+ | `start:pos(N)` | switch sidebar initial row | Covered | `fzf.PickerOptions`/`fzf.OptionsFromPicker`; `TestPickerOptionsFromFZFMapsStartPosToInitialIndex`; `TestPickerOptionsMapsFZFBindingsToContractActions` |
37
+ | `--preview` | switch, sessions | Covered by command output | `nativePreviewLines`; `TestNativeInteractiveRendersSelectedPreview` |
38
+ | `--preview-window right,60%,border-left` | switch popup, sessions popup | Covered for projmux option shape | `renderNativeSplitPreview` renders a single-column left border without a synthetic title row, uses fzf-measured percent sizing, normalizes preview tabs/control bytes before clipping, and pads both panes to fixed row widths so long preview rows do not wrap into extra vertical rows; `TestNativeInteractiveRendersWidePreviewBesideList`; `TestNativePreviewWidthUsesPreviewWindowPercent`; `TestRenderSplitPreviewRowsPadsBothPanes`; `TestRenderSplitPreviewRowsNormalizesPreviewTabsBeforeTruncating` |
39
+ | `--preview-window down,25%,border-top` | switch sidebar | Covered for projmux option shape | `renderNativeDownPreview` renders an immediate top border without a synthetic title row, uses fzf-measured percent sizing, and pads preview rows to the surface width; `TestNativeInteractiveRendersDownPreviewBelowList`; `TestNativePreviewHeightUsesPreviewWindowPercent`; `TestRenderDownPreviewPadsPreviewRows` |
40
+ | preview scrolling | long switch/session preview output | Covered for keyboard preview scroll | `previewOffset`; `TestNativeInteractiveRendersPreviewOffset` |
41
+ | `--query` | typed settings path defaults | Covered | `Options.InitialQuery`; settings tests |
42
+ | `--print-query` accept-query mode | typed settings path prompts | Covered | `Options.AcceptQuery`; `TestNativeRunnerAcceptsTypedQuery` |
43
+ | query cursor editing | typed settings path prompts | Covered | Left/Right, Ctrl-A/E, Delete, Backspace, Ctrl-U/W query editing plus visible prompt cursor; `TestNativeInteractiveEditsTypedQueryAtCursor`; `TestNativeInteractiveSupportsQueryLineEditingKeys`; `TestNativeInteractiveCtrlUDeletesBeforeCursor`; `TestNativePromptLineRendersQueryCursor` |
44
+ | terminal arrow key variants | interactive selection in tmux/docker | Covered | CSI, SS3/application cursor, modified CSI tests; app TTY `/dev/tty` fallback; raw TTY EOF polling keeps split ESC sequences from leaking into the query |
45
+ | mouse support | optional fzf mouse picker interaction | Partially covered | native enables SGR mouse reporting in interactive alternate-screen mode, primary click applies the clicked row, release events are ignored, and wheel input moves selection; drag gestures remain outside this POC; `TestNativeInteractiveSupportsMouseClickSelection`; `TestNativeInteractiveIgnoresMouseReleaseBeforeClick`; `TestNativeInteractiveSupportsMouseWheelSelection`; Docker no-fzf e2e clicks the AI settings row under a PTY |
46
+ | fzf navigation keys | interactive selection in searchable lists | Covered | native maps CSI-u `Ctrl-J` plus `Ctrl-N` to down and `Ctrl-P`/`Ctrl-K` to up when not claimed by a custom action; raw LF remains Enter for PTY compatibility; `TestNativeInteractiveSupportsFZFNavigationKeys` |
47
+ | alternate-screen lifecycle | fzf fullscreen picker screen restore | Covered | native frame updates and screen exit return to column 0 before terminal control sequences, screen exit resets styles plus clears the alternate buffer from the home cursor before restore, and real TTY restores get a short settle window before caller handoff; `nativeScreenEnter`; `TestNativeInteractiveUsesAlternateScreen`; `TestRenderFullFrameUpdateAlwaysHomesAndWritesFrame` |
48
+ | frame content width | fzf border inner width | Covered | `ContentLayout` uses the frame inner width so separators and rows reach the right border; `TestRendererContentLayoutUsesFrameInnerWidth` |
49
+ | tmux popup frame interaction | native picker popups launched through `popup-toggle` | Covered for native backend popups | `popup-toggle` passes tmux `display-popup -B` when `PROJMUX_PICKER_BACKEND=native`, so the native picker owns the visible frame instead of double-drawing with the tmux popup border; native Alt-1 uses a compact native-only minimum while fzf keeps the previous project sidebar minimum; Alt-1/Alt-2 sidebar heights reserve two bottom statusbar rows; Alt-2 notify sidebar keeps the fzf-like `24%` / min `64` baseline; `TestAppRunTmuxPopupToggleUsesBorderlessPopupForNativeBackend`; `TestSessionizerSidebarWidthKeepsFZFMinimum`; `TestSidebarPopupHeightLeavesStatusbarRows`; `TestNotifySidebarWidthMatchesFZFBaseline`; `TestAppRunTmuxPopupToggleKeepsNotifySidebarFZFSizingForNative` |
50
+ | optional native titlebar | native picker popup frame | Covered for empty-title compatibility and opt-in titles | `picker.Options.Title`; `RenderFrameWithTitle`; `ContentLayoutWithTitle`; empty titles keep the prior frame unchanged, non-empty titles render in a picker-owned row below the top border, and the native Alt-1 project sidebar opts into `Projects`; `TestRendererRenderFrameWithTitleKeepsDefaultWhenTitleEmpty`; `TestRendererRenderFrameWithTitleUsesTitlebarRow`; `TestRendererContentLayoutWithTitleReservesTitlebarRow`; `TestNativeInteractiveRendersOptionalTitlebar`; `TestSwitchCommandNativeSidebarSetsTitle` |
51
+ | redraw flicker/top clipping | keyboard navigation in exact-height tmux popup | Partially covered | native redraws use synchronized updates plus coalesced row diffs after the first frame, skip unchanged frames, render frame diffs before sidebar focus commands, frame rendering avoids trailing bottom-border CRLF, and screen exit clears the alternate buffer before restore; `TestNativeInteractiveWrapsRedrawsInSynchronizedUpdates`; `TestFrameUpdateRendererSkipsUnchangedFrame`; `TestFrameUpdateRendererCoalescesEachFrameUpdate`; `TestRendererRenderFrameUsesCRLFRowsForRawTTY`; `TestNativeInteractiveUsesAlternateScreen` |
52
+
53
+ ## Native Surface Architecture
54
+
55
+ - `internal/ui/picker` remains the backend-neutral contract and owns fzf/native
56
+ routing, keyboard input, fuzzy filtering, action dispatch, preview command
57
+ execution, and result handling.
58
+ - `internal/ui/projmuxpicker` owns projmux-native visual composition: frame,
59
+ redraw updates, ANSI width/truncation, theme tokens, prompt/footer/list
60
+ rendering, selected row styling, scrollbars/gap rows, and preview pane
61
+ geometry/rendering.
62
+ - `internal/ui/fzf` owns the compatibility adapter in both directions:
63
+ `picker.Options` becomes fzf flags/bindings for fallback, and legacy
64
+ `fzf.Options` becomes `picker.Options` for the native backend. This keeps app
65
+ code closer to a DI-style picker contract instead of embedding fzf binding
66
+ strings at each call site.
67
+ - `intfzf.NewPickerRunner()` adapts fzf to the same `picker.Runner` interface
68
+ as `picker.NativeRunner`, so follow-up branches can inject either backend at
69
+ a narrower boundary without deleting the existing fzf runner.
70
+ - Settings > Labs > Picker Engine persists the selected backend in
71
+ `~/.config/projmux/picker-backend` and updates the live tmux server
72
+ environment through `PROJMUX_PICKER_BACKEND`, while direct environment
73
+ overrides still win over saved config. Native is the default when no saved
74
+ backend or override exists; `fzf` remains available as an explicit fallback.
75
+ - The split lets projmux grow a first-party picker design independently from
76
+ the fzf compatibility adapter.
77
+
78
+ ## Verified Flows
79
+
80
+ - `ai` picker/settings: native backend routing covered by app tests. Docker
81
+ no-fzf e2e also types `Codex` into `projmux ai settings` and verifies the
82
+ native simple picker writes the `codex` mode without fzf.
83
+ - `shell` update prompt: native backend routing covered by shared fzf-to-native
84
+ adapter and settings-style typed prompt tests.
85
+ - `settings`: native backend exercised in unit tests and Docker no-fzf e2e
86
+ using Enter plus arrow-key navigation under a PTY. The Docker e2e also fails
87
+ if the Settings flows write tmux no-server noise to stderr while running
88
+ outside tmux.
89
+ - `settings > Labs`: unit-covered backend toggle writes
90
+ `~/.config/projmux/picker-backend`, updates the tmux global
91
+ `PROJMUX_PICKER_BACKEND`, and lets env override saved config.
92
+ - `switch --ui=sidebar`: Docker no-fzf e2e creates sample projects, types
93
+ `bravo`, selects `bravo-web`, and confirms the opened tmux shell path.
94
+ - `switch --ui=popup`: Docker no-fzf e2e creates existing tmux sessions using
95
+ the app's session naming convention, runs the picker under a 150x30 PTY,
96
+ types `bravo`, sends `Right` and `Alt-Down` to exercise preview window/pane
97
+ cycle, asserts the popup stays on the right-side preview layout instead of
98
+ inline preview, asserts the stored preview cursor, selects `bravo-web`, and
99
+ asserts tmux reports the selected session's active target on the expected
100
+ window with the expected pane path.
101
+ - `sessions --ui=popup`: Docker no-fzf e2e creates existing tmux sessions,
102
+ runs the picker under a 150x30 PTY, types `bravo`, sends `Right` and
103
+ `Alt-Down` to exercise preview window/pane cycle, asserts the popup stays on
104
+ the right-side preview layout instead of inline preview, asserts the stored
105
+ preview cursor, selects `bravo-web`, and asserts tmux reports the selected
106
+ session's active target on the expected window with the expected pane path.
107
+ - `notify sidebar`: native routing is unit-covered; Docker no-fzf e2e pushes a
108
+ notification, presses printable expect key `x`, and verifies the row is acked.
109
+
110
+ ## Experimental Boundaries
111
+
112
+ - Preview-window parity is covered for the concrete projmux option shapes
113
+ (`right,60%,border-left` and `down,25%,border-top`) with fzf-measured percent
114
+ sizing. The full fzf preview-window grammar, threshold alternatives, sticky
115
+ headers, and offset expressions are intentionally outside this POC surface.
116
+ - fzf V2 dynamic scoring is covered for normal app-length non-search-key
117
+ rows, including reference scores for boundary, delimiter, camelCase/number,
118
+ gap, and consecutive bonuses. Very large `query * row` matrices intentionally
119
+ fall back to the greedy scorer to avoid pathological memory use. Search-keyed
120
+ app pickers preserve fzf's `--disabled` reload order instead of score-sorting.
121
+ - Mouse support is intentionally narrow in this POC: primary click applies the
122
+ clicked row, release events are ignored, and wheel input moves selection.
123
+ Drag gestures and the full fzf mouse grammar are follow-up work.
124
+ - The public doctor/docs dependency policy is tracked separately from picker
125
+ backend selection. Native is the default picker backend, while fzf remains an
126
+ explicit fallback.
127
+ - Draft PR: https://github.com/crevissepartners/projmux/pull/98.
128
+
129
+ ## Commands
130
+
131
+ Automated no-fzf e2e:
132
+
133
+ ```sh
134
+ wt run poc/native-picker-no-fzf -- scripts/poc-native-picker-no-fzf-e2e.sh
135
+ ```
136
+
137
+ Interactive no-fzf sandbox:
138
+
139
+ ```sh
140
+ bash "$(wt path poc/native-picker-no-fzf)/scripts/poc-native-picker-no-fzf-sandbox.sh"
141
+ ```
142
+
143
+ Do not run the interactive sandbox through `wt run`: current `wt run` captures
144
+ child stdio instead of forwarding the caller's TTY, so Docker cannot attach
145
+ `-it` and terminal picker input will not behave like a real session.
@@ -0,0 +1,200 @@
1
+ # Notify queue
2
+
3
+ `projmux` keeps a persistent JSON queue of pending AI notifications.
4
+ `attention` is live tmux pane state; `notify` is the user's pending
5
+ notification source of truth. The queue is derived from live state and user
6
+ pushes, but an entry remains pending until explicit ack. Each entry can route
7
+ the status-bar notify segment or notify sidebar to the originating tmux pane
8
+ via `projmux focus`, and feeds the HUD pill rendered by
9
+ `projmux status notify`.
10
+
11
+ ## File layout
12
+
13
+ ```
14
+ ${XDG_STATE_HOME:-$HOME/.local/state}/projmux/notify.json
15
+ ${XDG_STATE_HOME:-$HOME/.local/state}/projmux/notify.json.lock
16
+ ```
17
+
18
+ The lock file is acquired via `O_CREATE|O_EXCL` with bounded retry
19
+ (default ~200 attempts, 2ms–50ms jittered backoff) and a 30s
20
+ stale-after window so a crashed writer never permanently wedges the
21
+ queue.
22
+
23
+ The queue file is a pretty-printed JSON array of `Notification`
24
+ objects, sorted newest-first on read. `expires_at` is freshness metadata;
25
+ expired entries are not filtered or deleted by `list`.
26
+
27
+ ## Data model
28
+
29
+ `internal/core/notify`:
30
+
31
+ ```go
32
+ type Notification struct {
33
+ ID string // stable key for dedupe / ack
34
+ Text string // capped at 80 runes
35
+ Severity string // info | warn | critical
36
+ Source string // ai | k8s | git | external
37
+ CreatedAt time.Time
38
+ ExpiresAt time.Time
39
+ Target // session, window, pane, socket
40
+ }
41
+
42
+ type Target struct {
43
+ Socket string // tmux -L socket path; empty = default
44
+ Session string
45
+ Window string // optional; "" means session-only
46
+ Pane string // optional; "" means window-level
47
+ }
48
+ ```
49
+
50
+ Defaults: `DefaultTTL = 600s`, `MaxTextLength = 80`. TTL is retained as a
51
+ freshness/display field, not a removal condition. `Severity` and
52
+ `Source` are validated against the constants above; an invalid value
53
+ returns `ErrInvalidSeverity` / `ErrInvalidSource` which the CLI maps to
54
+ exit code 2.
55
+
56
+ ## CLI surface
57
+
58
+ ### push
59
+
60
+ ```
61
+ projmux notify push --text <s> --target <SESSION[:WINDOW[.PANE]]>
62
+ [--socket <s>] [--severity info|warn|critical]
63
+ [--source ai|k8s|git|external]
64
+ [--ttl <seconds>] [--id <s>] [--json]
65
+ ```
66
+
67
+ Appends one entry. With `--id` an existing entry is overwritten in
68
+ place (text + timestamp refresh), enabling idempotent producers like
69
+ the AI reply-ready transition. `--ttl` accepts a positive integer
70
+ number of seconds. `--json` prints `{id, queued}` for scripting.
71
+
72
+ ### list
73
+
74
+ ```
75
+ projmux notify list [--live] [--json] [--limit N] [--ui table|sidebar]
76
+ [--severity ...] [--source ...]
77
+ ```
78
+
79
+ Newest-first pending queue entries. Default output is the tab-aligned
80
+ table `ID AGE SEV SRC TARGET TEXT`. `--severity` / `--source` are
81
+ repeatable filters. Without `--live`, this command reads only the queue and
82
+ preserves the stable JSON array used by scripts.
83
+
84
+ `--ui=sidebar` opens the notify queue as an interactive right-side list when
85
+ run inside the tmux popup surface. Enter focuses the selected target pane and
86
+ acks the row after focus succeeds. `x` acks the selected row. `Ctrl-X` clears
87
+ all rows via `notify ack --all`. Rows are intentionally compact: the visible
88
+ label keeps notification text first, then age, project, window, and pane
89
+ metadata; hidden queue ids remain action values but the sidebar has no search
90
+ input.
91
+
92
+ `--live` adds a non-mutating explanation view that reads
93
+ `tmux list-panes -a` and compares the queue with live reply-state panes. It
94
+ does not push, ack, or otherwise repair anything. Human output keeps the
95
+ queue table and adds a `STATE TARGET ID EXPLANATION TEXT` section; JSON
96
+ output becomes `{queue, live, rows, errors}`. Typical states:
97
+
98
+ - `live-manual-reply` — a live reply/green badge exists, but no queue entry
99
+ is expected because the pane has no AI agent metadata.
100
+ - `live-ai-reply-queued` — a live AI reply pane has the matching actionable
101
+ queue entry.
102
+ - `live-ai-reply-missing-queue` — a live AI reply pane lacks the derived
103
+ queue entry; run `projmux notify reconcile` to back-fill it.
104
+ - `queue-stale` — an `ai:` queue entry exists, but the live pane no longer
105
+ matches reply+agent state; it remains pending until explicit ack.
106
+ - `queue-only` — a non-AI/external queue entry is pending and has no live AI
107
+ reply-pane requirement.
108
+
109
+ To inspect live pane attention without queue context, use
110
+ `projmux attention list`.
111
+
112
+ ### ack
113
+
114
+ ```
115
+ projmux notify ack <id>
116
+ projmux notify ack --all
117
+ ```
118
+
119
+ Removes one entry by id, or flushes the queue. `--all` returns the
120
+ removed count.
121
+
122
+ ### reconcile
123
+
124
+ ```
125
+ projmux notify reconcile [--json]
126
+ ```
127
+
128
+ Walks `tmux list-panes -a -F` with the producer-key format (session,
129
+ window id, pane id, attention state, AI state, agent, topic, socket
130
+ path), then:
131
+
132
+ - pushes/refreshes one `ai:<session>:<pane>` entry for every pane
133
+ whose attention state is `reply` AND whose agent option is non-empty;
134
+ - reports every existing queue entry whose id starts with `ai:` and whose
135
+ pane no longer matches that condition as stale, without acking it.
136
+
137
+ Soft-fails when tmux is not running (returns a populated `errors`
138
+ field rather than a non-zero exit) so the post-install hook does not
139
+ break. Run this as the recovery path when the on-disk queue has drifted
140
+ from live pane state.
141
+
142
+ Output: `reconcile: pushed N, acked M, kept K, stale S`.
143
+
144
+ Ack behavior is intentionally queue-local: only `ack` removes explicit ids or
145
+ flushes the queue. TTL is freshness metadata, and `reconcile` only repairs
146
+ derived `ai:` entries. Manual attention badges without agent metadata remain
147
+ live attention only.
148
+
149
+ ## Producer (AI reply-ready)
150
+
151
+ `internal/app/notify_producer.go`. The attention state machine calls
152
+ `PushReplyReady` when a pane flips to `reply`. The producer reads
153
+ `@projmux_ai_pane_agent`, `@projmux_ai_pane_topic`, `#S`,
154
+ `#{window_id}`, `#{pane_id}`, `#{socket_path}` off the pane and writes
155
+ an entry with:
156
+
157
+ - id: `ai:<session>:<pane>`
158
+ - text: `<agent>: <topic>` (or `<agent>: ready` when no topic is set)
159
+ - severity: `info`, source: `ai`, freshness TTL: 10 minutes
160
+
161
+ When the pane leaves the reply state (manual `attention clear`,
162
+ `status set idle`, or a window close), `AckReplyReady` intentionally does not
163
+ remove the entry. The user consumes it through explicit ack. Store errors are
164
+ swallowed so the live tmux UI never blocks on disk IO.
165
+
166
+ Manual `projmux attention toggle` on a pane without an agent option
167
+ does NOT push — the queue is intentionally AI-driven; reconcile honours
168
+ the same contract.
169
+
170
+ ## Consumer (status-bar click)
171
+
172
+ `internal/app/statusbar.go::handleNotify`. A click on the notify range
173
+ or the `prefix s n` chord reads the newest queue entry and dispatches:
174
+
175
+ ```
176
+ projmux focus --target <target> --source status-bar --kind segment-click [--socket <s>]
177
+ ```
178
+
179
+ Outcomes:
180
+
181
+ - **Focus succeeded** — ack the entry. Focus is the single consume path for
182
+ routed notification clicks.
183
+ - **Focus exited 2 (target unresolved)** — keep the entry pending and toast
184
+ `notify target gone; ack to clear`.
185
+ - **Other failure** — keep the entry, toast `focus failed: <reason>`
186
+ so the user can retry without losing the row.
187
+
188
+ The handler never returns a non-zero error to tmux's `run-shell`; every
189
+ failure becomes a `display-message` toast so a transient miss does not
190
+ trigger a tmux error popup.
191
+
192
+ ## Render (status segment)
193
+
194
+ `projmux status notify` is the HUD-style renderer wired to the tmux
195
+ status interval. See [statusbar.md](statusbar.md) for the layout and
196
+ degradation tiers. It shows the newest pending item as a single notification
197
+ block with project, state, optional agent, text, age, and an extra-count
198
+ marker. Window/pane ids remain routable metadata but are not displayed in the
199
+ compact HUD. The renderer is silent on every failure mode (no store, list
200
+ error, empty queue) so the status line never carries a stack trace.