Skip to content

feat(session-picker): add full message preview with formatter rendering#398

Open
jensenojs wants to merge 5 commits into
sudo-tee:mainfrom
jensenojs:feat/session-picker-preview-v2
Open

feat(session-picker): add full message preview with formatter rendering#398
jensenojs wants to merge 5 commits into
sudo-tee:mainfrom
jensenojs:feat/session-picker-preview-v2

Conversation

@jensenojs
Copy link
Copy Markdown
Contributor

@jensenojs jensenojs commented Jun 1, 2026

base on #393, to close #391

just for try out, @sudo-tee

jensenojs added 5 commits May 28, 2026 19:06
…for child sessions

- Add child_readonly config (default: true) to opt into messaging child sessions
- Infer child session agent type from first assistant message on switch
  (session.agent may be polluted by prior incorrect agent params)
- Lock agent type in child sessions, reject user-initiated mode switches
- Child sessions scan messages forward (first is reliable),
  parent sessions scan backward (most recent is current choice)
- Include subagents in agent validation list
- Send inferred agent type when messaging child sessions
  to override polluted session.agent on backend
- Replace cursor+zc fold creation with :{from},{to}fold Ex commands
  — avoids cursor-triggered screen redraws (~90ms/fold in large buffers)
- Switch to foldmethod=manual and stay there — prevents foldexpr
  recalculation on every buffer line (~4.6s on 87K lines)
- Lazy-render only viewport-sized message count on initial load
- Load more messages on scroll-to-top via WinScrolled autocmd
- Fix lazy_render_count being cleared by M.reset() — read before reset,
  persist back to ctx after determining limit
- Debounce WinScrolled load_more callback (150ms) to prevent rapid
  re-renders during fast scrolling
- Remove debug vim.notify logging from render paths

Performance: ~36s → ~10ms render time on a 2786-msg/87K-line session.

Closes sudo-tee#392
- base_picker: add preview='custom' + preview_fn type, Telescope
  buffer_previewer implementation for custom content preview
- output_window: extract apply_extmarks(bufnr, extmarks, line_offset?)
  as reusable public function; set_extmarks delegates to it
- api_client: list_messages(id, directory, opts?) accepts opts table
  for query parameters (e.g. limit)
- session: get_messages(session, opts?) passes opts through
Session picker now shows a rich preview when selecting a session:
- normalize_message_order: handle API descending order
- filter_preview_messages: show first user msg + last assistant reply
- format_messages: reuse existing formatter for consistent rendering
  (pcall per-part, no get_child_parts, no previous_message)
- render_preview_buffer: direct nvim API with window-local folds
- preview_fn: synchronous load via Promise:wait() (~20-30ms)

Only Telescope backend supported in this commit.
- Unify custom preview rendering behind a backend-neutral preview target so
  session previews work consistently with Telescope, fzf-lua, and Snacks.

- Normalize picker plugin aliases such as fzf-lua, telescope.nvim, and
  snacks.nvim to their internal backend names, and add regression coverage for
  custom preview behavior across the picker integrations.
@jensenojs jensenojs force-pushed the feat/session-picker-preview-v2 branch from cbbb455 to 67c3130 Compare June 3, 2026 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature] : preview for session message

1 participant