Skip to content

Commit 5e096e9

Browse files
btakitaclaude
andcommitted
v0.14.4: claim pane focus + convert handles pre-set template mode
- claim: use Tmux::select_pane() (select-window + select-pane) instead of raw select-pane, fixing cross-window pane focus after claim - convert: when frontmatter says template but no component markers exist, add exchange component instead of erroring Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b630f8b commit 5e096e9

File tree

6 files changed

+26
-12
lines changed

6 files changed

+26
-12
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "agent-doc"
3-
version = "0.14.3"
3+
version = "0.14.4"
44
edition = "2024"
55
description = "Interactive document sessions with AI agents"
66
license = "MIT"

SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
description: Submit a session document to an AI agent and append the response
33
user-invocable: true
44
argument-hint: "<file>"
5-
agent-doc-version: "0.14.3"
5+
agent-doc-version: "0.14.4"
66
---
77

88
# agent-doc submit

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "maturin"
44

55
[project]
66
name = "agent-doc"
7-
version = "0.14.3"
7+
version = "0.14.4"
88
description = "Interactive document sessions with AI agents"
99
readme = "README.md"
1010
license = "MIT"

src/claim.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,8 @@ pub fn run(file: &Path, position: Option<&str>, pane: Option<&str>, window: Opti
107107
let pane_pid = sessions::pane_pid(&pane_id).unwrap_or(std::process::id());
108108
sessions::register_with_pid(&session_id, &pane_id, &file_str, pane_pid)?;
109109

110-
// Focus the claimed pane (select its window first for cross-window support)
111-
let _ = std::process::Command::new("tmux")
112-
.args(["select-pane", "-t", &pane_id])
113-
.status();
110+
// Focus the claimed pane (select-window + select-pane for cross-window support)
111+
let _ = tmux.select_pane(&pane_id);
114112

115113
// Show a brief notification on the target pane
116114
let msg = format!("Claimed {} (pane {})", file_str, pane_id);

src/convert.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@ pub fn run(file: &Path) -> Result<()> {
1313

1414
let (fm, body) = frontmatter::parse(&content)?;
1515

16-
// Reject if already template mode
16+
// If already template mode, check if body has component markers
1717
let mode = fm.mode.as_deref().unwrap_or("append");
1818
if mode == "template" {
19-
anyhow::bail!("{} is already in template mode", file.display());
19+
let components = crate::component::parse(&content).unwrap_or_default();
20+
if !components.is_empty() {
21+
anyhow::bail!("{} is already in template mode with components", file.display());
22+
}
23+
// Frontmatter says template but no markers — add them
24+
eprintln!("Mode is template but no component markers found, adding exchange component");
2025
}
2126

2227
// Update frontmatter to template mode
@@ -123,15 +128,26 @@ mod tests {
123128
}
124129

125130
#[test]
126-
fn convert_rejects_template_mode() {
131+
fn convert_rejects_template_mode_with_components() {
127132
let dir = setup_project();
128133
let file = dir.path().join("test.md");
129-
std::fs::write(&file, "---\nagent_doc_mode: template\n---\n\n# Doc\n").unwrap();
134+
std::fs::write(&file, "---\nagent_doc_mode: template\n---\n\n<!-- agent:exchange -->\ncontent\n<!-- /agent:exchange -->\n").unwrap();
130135
let result = run(&file);
131136
assert!(result.is_err());
132137
assert!(result.unwrap_err().to_string().contains("already in template mode"));
133138
}
134139

140+
#[test]
141+
fn convert_adds_markers_when_template_but_no_components() {
142+
let dir = setup_project();
143+
let file = dir.path().join("test.md");
144+
std::fs::write(&file, "---\nagent_doc_mode: template\n---\n\n# Doc\n\n## User\n\nHello\n").unwrap();
145+
run(&file).unwrap();
146+
let result = std::fs::read_to_string(&file).unwrap();
147+
assert!(result.contains("<!-- agent:exchange -->"));
148+
assert!(result.contains("Hello"));
149+
}
150+
135151
#[test]
136152
fn convert_updates_frontmatter() {
137153
let dir = setup_project();

0 commit comments

Comments
 (0)