You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
always_approve=false, -- set true to skip ACP permission prompts
640
+
resume_session=true, -- resume the last Grok ACP session for this git repo (default)
641
+
},
642
+
}
643
+
```
644
+
645
+
#### How sessions fit into the parrot workflow
646
+
647
+
Parrot and Grok maintain **two different kinds of state**:
648
+
649
+
| Layer | What it stores | Where |
650
+
|-------|----------------|-------|
651
+
|**Parrot transcript**| Markdown chat/command buffers you see in Neovim |`chat_dir` (e.g. `~/.local/share/nvim/parrot/chats`) |
652
+
|**Grok agent state**| Tool history, goals, slash-command context, permission mode |`~/.grok/sessions` on disk; session IDs in parrot `state.json`|
653
+
654
+
They are related but not identical. Editing or deleting a parrot `.md` chat file does **not** reset the Grok session, and resuming a Grok session does **not** replay old turns into the buffer.
655
+
656
+
**Scope:** Session IDs are keyed by **git repository root** (fallback: Neovim `cwd`). Any file under `chat_dir` is an ACP **chat** session (path-based); parrot chat keymaps (`PrtChatRespond`, etc.) still require the full markdown template (`utils.is_chat`). Command sessions use the buffer file's directory / git root at prompt time.
657
+
658
+
**Chat project binding** (`chat_project_cwd` in `state.json`): set at `:PrtChatNew` / first `BufEnter` on a chat file. Legacy chats created before this feature bind on the **first ACP prompt** after upgrade, using whatever Neovim `cwd` is then — `:cd` to the intended repo before that prompt. Once bound, prompts, slash commands, and mode changes keep that project even if you `:cd` elsewhere mid-chat.
659
+
660
+
**Kinds:**`chat` and `command` use **separate session IDs** per repo (`PrtChatNew` / chat buffers vs `PrtAsk`, `PrtRewrite`, popups, etc.).
661
+
662
+
**Lifecycle:**
663
+
664
+
1. Neovim starts → parrot spawns `grok agent stdio` (one process per model/connection).
665
+
2. First prompt for a kind → `initialize` → `authenticate` → `session/load` (if `resume_session = true` and a stored ID exists) or `session/new`.
666
+
3. Prompts stream via `session/prompt` / `session/update` (`agent_message_chunk`).
Set `resume_session = false` to always call `session/new` (fresh Grok context; parrot still keeps markdown transcripts).
670
+
671
+
**Recommended workflows**
672
+
673
+
-**Long-running agent work in a repo:**`resume_session = true`, chat with `grok-build`, set a goal via `:PrtAcpSlashCommand goal`, continue across Neovim restarts. Parrot markdown is your readable log; Grok session is the agent's working memory.
674
+
-**One-off edits / popups:** Command sessions (`PrtRewrite`, `PrtAsk`) stay isolated from chat. Same repo, different session kind.
675
+
-**Switch repos:**`:cd` to the other project before starting a **new** chat or command prompt. Existing chat files keep their original project binding; reopening an old chat resumes that project's Grok session.
676
+
-**Reset agent context without losing transcripts:**`resume_session = false` temporarily, or delete the repo's entries under `state.json` → `acp_sessions`, or start a new Grok session from the CLI and update the stored ID.
677
+
-**After `grok` CLI upgrade:**`:PrtReloadCache grok` refreshes models and slash-command cache (keyed by `grok --version`).
678
+
679
+
**Background agent:** Plugin setup, Tab completion on incomplete slash caches, and `:PrtReloadCache` may spawn `grok agent stdio` in the background (with a 15s warm timeout). Use `make test-acp` / `make test-acp-smoke` for offline verification without a live agent.
680
+
681
+
**Slash commands:** The full list arrives after `session/new` or `session/load` via `available_commands_update` (not from `initialize` alone). Parrot caches commands in `state.json` for instant Tab completion; incomplete caches refresh in the background. `:PrtAcpSlashCommand` with no args opens a picker; Tab completes `name` + description.
682
+
683
+
**Transcript vs agent desync:** If you `:PrtChatNew` (new markdown file) but `resume_session = true`, Grok still remembers prior tool runs. For a clean agent slate, use `resume_session = false` or clear the repo's `acp_sessions` entry. Conversely, an old markdown chat file can be reopened while Grok resumes — the buffer shows history Grok may not re-ingest unless you paste or summarize it in a new prompt.
0 commit comments