Trim comments across Rust and webapp source to direct one-liners (ticket 030)
Pass over src/*.rs, webapp/src/**, and the in-app "?" docs prose: condensed multi-paragraph doc comments to single lines that state the non-obvious why, deleted comments that only restated adjacent code, and tightened the Docs.tsx help-panel wording. No logic, structure, or code formatting changed — verified via cargo test (143 passed) and tsc -b && vite build. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XFUNZwCvz3kcod3352ZR2o
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
3cef6dc8ae
commit
00c21c8032
+7
-18
@@ -30,9 +30,7 @@ pub async fn run(engine: mpsc::Sender<EngineMessage>) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Identifies a specific file instance on disk, so a recreated path (e.g. a
|
||||
/// tailed process restarting and reopening its log file) can be told apart from
|
||||
/// the same file simply growing.
|
||||
/// Identifies a specific file instance on disk, so a recreated path can be told apart from the same file simply growing.
|
||||
#[derive(PartialEq, Eq, Clone, Copy)]
|
||||
struct FileId(#[cfg(unix)] u64, #[cfg(not(unix))] ());
|
||||
|
||||
@@ -55,13 +53,9 @@ async fn open(path: &Path) -> Option<(File, FileId)> {
|
||||
Some((file, file_id(&meta)))
|
||||
}
|
||||
|
||||
/// Tails `path` like `tail -f`: reads existing content, then keeps reading as
|
||||
/// new lines are appended. If the file is deleted and recreated at the same
|
||||
/// path (or truncated in place) — e.g. the tailed process restarted and
|
||||
/// reopened its log — tailing resumes against the new file from its start,
|
||||
/// rather than exiting or getting stuck. `sequence` keeps incrementing across
|
||||
/// a recreation event; it's ottyl's own line counter, not tied to the source
|
||||
/// file.
|
||||
/// Tails `path` like `tail -f`, resuming from the start if the file is deleted/recreated or
|
||||
/// truncated in place rather than exiting or getting stuck; `sequence` keeps incrementing
|
||||
/// across a recreation since it's ottyl's own line counter, not tied to the source file.
|
||||
pub async fn run_file(engine: mpsc::Sender<EngineMessage>, path: PathBuf) {
|
||||
let mut sequence: u64 = 0;
|
||||
|
||||
@@ -81,9 +75,7 @@ pub async fn run_file(engine: mpsc::Sender<EngineMessage>, path: PathBuf) {
|
||||
let mut chunk = String::new();
|
||||
match reader.read_line(&mut chunk).await {
|
||||
Ok(0) => {
|
||||
// EOF: decide whether the file was truncated/recreated
|
||||
// (tail the new instance from scratch) or just hasn't
|
||||
// grown yet (keep polling).
|
||||
// EOF: decide whether the file was truncated/recreated or just hasn't grown yet.
|
||||
match tokio::fs::metadata(&path).await {
|
||||
Ok(meta) => {
|
||||
let new_id = file_id(&meta);
|
||||
@@ -93,8 +85,7 @@ pub async fn run_file(engine: mpsc::Sender<EngineMessage>, path: PathBuf) {
|
||||
id = new_id;
|
||||
}
|
||||
Err(_) => {
|
||||
// Path gone (mid-recreation); wait for it to
|
||||
// reappear and reopen fresh.
|
||||
// Path gone (mid-recreation); wait for it to reappear and reopen fresh.
|
||||
}
|
||||
}
|
||||
tokio::time::sleep(POLL_INTERVAL).await;
|
||||
@@ -119,8 +110,7 @@ pub async fn run_file(engine: mpsc::Sender<EngineMessage>, path: PathBuf) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// else: partial line at EOF (write in progress) — keep
|
||||
// buffering and read again without treating it as final.
|
||||
// else: partial line at EOF (write in progress) — keep buffering.
|
||||
}
|
||||
Err(_) => continue 'reopen,
|
||||
}
|
||||
@@ -189,7 +179,6 @@ mod tests {
|
||||
|
||||
assert_eq!(recv_text(&mut rx).await, "long line before truncation");
|
||||
|
||||
// Truncate in place (same inode, shorter content) then write new data.
|
||||
let mut f = std::fs::OpenOptions::new()
|
||||
.write(true)
|
||||
.truncate(true)
|
||||
|
||||
Reference in New Issue
Block a user