fix: auto-assign after merge, persistent server logs, remove duplicate pnpm install

- Call auto_assign_available_work at end of merge_agent_work so the next
  story gets picked up without waiting for the PTY exit handler
- Add persistent file logging to .story_kit/logs/server.log so server
  logs survive restarts
- Remove duplicate pnpm install block in run_squash_merge

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dave
2026-02-26 18:24:27 +00:00
parent b5135ad957
commit 2148531a46
3 changed files with 38 additions and 42 deletions

View File

@@ -7,6 +7,9 @@
//! `get_server_logs` MCP tool.
use std::collections::VecDeque;
use std::fs::OpenOptions;
use std::io::Write;
use std::path::PathBuf;
use std::sync::{Mutex, OnceLock};
const CAPACITY: usize = 1000;
@@ -68,12 +71,22 @@ impl LogEntry {
pub struct LogBuffer {
entries: Mutex<VecDeque<LogEntry>>,
log_file: Mutex<Option<PathBuf>>,
}
impl LogBuffer {
fn new() -> Self {
Self {
entries: Mutex::new(VecDeque::with_capacity(CAPACITY)),
log_file: Mutex::new(None),
}
}
/// Set the persistent log file path. Call once at startup after the
/// project root is known.
pub fn set_log_file(&self, path: PathBuf) {
if let Ok(mut f) = self.log_file.lock() {
*f = Some(path);
}
}
@@ -86,6 +99,15 @@ impl LogBuffer {
message,
};
eprintln!("{}", entry.colored_formatted());
// Append to persistent log file (best-effort).
if let Ok(guard) = self.log_file.lock()
&& let Some(ref path) = *guard
&& let Ok(mut file) = OpenOptions::new().create(true).append(true).open(path)
{
let _ = writeln!(file, "{}", entry.formatted());
}
if let Ok(mut buf) = self.entries.lock() {
if buf.len() >= CAPACITY {
buf.pop_front();
@@ -188,6 +210,7 @@ mod tests {
fn evicts_oldest_at_capacity() {
let buf = LogBuffer {
entries: Mutex::new(VecDeque::with_capacity(CAPACITY)),
log_file: Mutex::new(None),
};
// Fill past capacity
for i in 0..=CAPACITY {