Skip to content

fix: resolve unreachable pattern warning in image paste PR #2823#2826

Open
Dhilan-Panjabi wants to merge 4 commits intoantinomyhq:mainfrom
Dhilan-Panjabi:pr/image-pasting
Open

fix: resolve unreachable pattern warning in image paste PR #2823#2826
Dhilan-Panjabi wants to merge 4 commits intoantinomyhq:mainfrom
Dhilan-Panjabi:pr/image-pasting

Conversation

@Dhilan-Panjabi
Copy link
Copy Markdown

Fixes the unreachable pattern warning introduced in #2823.

Problem

The Paste variant was incorrectly placed between AgentSwitch's #[strum(props(...))]" attribute and its variant declaration, causing two strum attributes to stack on Pasteand leavingAgentSwitch` without its metadata.

Fix

  • Separated Paste and AgentSwitch into their own properly annotated blocks
  • Removed extra blank line

Builds clean with zero warnings.

@github-actions github-actions bot added the type: fix Iterations on existing features or infrastructure. label Apr 3, 2026
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 3, 2026

CLA assistant check
All committers have signed the CLA.

Comment on lines +117 to +124
if let Ok(mut f) = std::fs::OpenOptions::new()
.create(true)
.append(true)
.open("/tmp/forge_paste.log")
{
let _ = writeln!(&mut f, "Received !forge_internal_paste_image");
use std::io::Write;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug logging code appears to have been accidentally left in production code. This creates a file at /tmp/forge_paste.log on every paste attempt, which could fill up disk space over time and expose user activity. This block should be removed:

if let Ok(mut f) = std::fs::OpenOptions::new()
    .create(true)
    .append(true)
    .open("/tmp/forge_paste.log")
{
    let _ = writeln!(&mut f, "Received !forge_internal_paste_image");
    use std::io::Write;
}

Spotted by Graphite

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Comment on lines +7 to +8
let home_dir = std::env::var("HOME").unwrap_or_else(|_| "/tmp".to_string());
let images_dir = PathBuf::from(home_dir).join(".local/share/forge/images");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using HOME environment variable for cross-platform path resolution is unreliable. On Windows, HOME is typically not set, causing this to fall back to /tmp which also doesn't exist on Windows. This will cause directory creation to fail silently, and image pasting won't work on Windows. Should use dirs::data_local_dir() or similar platform-aware solution:

use dirs;
fn get_images_dir() -> Option<PathBuf> {
    let base_dir = dirs::data_local_dir()?;
    let images_dir = base_dir.join("forge/images");
    std::fs::create_dir_all(&images_dir).ok()?;
    Some(images_dir)
}

Spotted by Graphite

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Stranmor and others added 4 commits April 3, 2026 11:31
…or cross-platform paths

- Remove leftover debug logging to /tmp/forge_paste.log in editor.rs
- Replace HOME env var with dirs::data_local_dir() for cross-platform
  image directory resolution in image_paste.rs
- Add dirs workspace dependency to forge_main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix Iterations on existing features or infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants