Skip to content

feat: DWIM toggle for pi-coding-agent entry point#125

Open
conornash wants to merge 1 commit intodnouri:masterfrom
conornash:pi-dwim
Open

feat: DWIM toggle for pi-coding-agent entry point#125
conornash wants to merge 1 commit intodnouri:masterfrom
conornash:pi-dwim

Conversation

@conornash
Copy link

Add agent-shell-style DWIM behavior to the main pi-coding-agent' command and a new pi-coding-agent-toggle' command for toggling session window visibility.

DWIM behavior for M-x pi-coding-agent (no prefix arg):

  • From a pi buffer: toggle visibility (hide windows)
  • From a non-pi buffer with existing project session: reuse it
  • No session for project: create a new one
  • C-u prefix or Lisp string arg: named session (unchanged)

New command `pi-coding-agent-toggle':

  • Pi windows visible -> hide them
  • Pi windows hidden but session exists -> show them
  • No session -> user-error

New functions in pi-coding-agent-ui.el:

  • `pi-coding-agent-project-buffers': find all pi chat buffers for the current project directory, ordered by buffer-list recency
  • `pi-coding-agent--hide-buffers': hide pi windows using a hybrid strategy: delete-window when the frame has other windows, bury-buffer for sole-window frames. Second pass handles the case where bury-buffer lands on the paired pi buffer.

Bug fix in test-common.el:

  • Mock session cleanup called nonexistent functions pi-coding-agent--chat-buffer-name' and pi-coding-agent--input-buffer-name' (swallowed by ignore-errors, causing buffer leaks). Fixed to use `pi-coding-agent--buffer-name' with :chat/:input type argument.

Tests: 5 new tests (502 total, all passing):

  • dwim-reuses-existing-session
  • new-session-with-prefix-arg
  • project-buffers-finds-session
  • project-buffers-excludes-other-projects
  • toggle-no-session-errors

Add agent-shell-style DWIM behavior to the main `pi-coding-agent'
command and a new `pi-coding-agent-toggle' command for toggling
session window visibility.

DWIM behavior for M-x pi-coding-agent (no prefix arg):
- From a pi buffer: toggle visibility (hide windows)
- From a non-pi buffer with existing project session: reuse it
- No session for project: create a new one
- C-u prefix or Lisp string arg: named session (unchanged)

New command `pi-coding-agent-toggle':
- Pi windows visible -> hide them
- Pi windows hidden but session exists -> show them
- No session -> user-error

New functions in pi-coding-agent-ui.el:
- `pi-coding-agent-project-buffers': find all pi chat buffers for
  the current project directory, ordered by buffer-list recency
- `pi-coding-agent--hide-buffers': hide pi windows using a hybrid
  strategy: delete-window when the frame has other windows,
  bury-buffer for sole-window frames. Second pass handles the case
  where bury-buffer lands on the paired pi buffer.

Bug fix in test-common.el:
- Mock session cleanup called nonexistent functions
  `pi-coding-agent--chat-buffer-name' and
  `pi-coding-agent--input-buffer-name' (swallowed by ignore-errors,
  causing buffer leaks). Fixed to use `pi-coding-agent--buffer-name'
  with :chat/:input type argument.

Tests: 5 new tests (502 total, all passing):
- dwim-reuses-existing-session
- new-session-with-prefix-arg
- project-buffers-finds-session
- project-buffers-excludes-other-projects
- toggle-no-session-errors
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.

1 participant