Hmbown/CodeWhale · error · io::Error

Session title cannot exceed

Error message

Session title cannot exceed {} characters

What it means

Session titles are normalized by `normalize_session_title` (crates/tui/src/session_manager.rs:3008), which trims whitespace, rejects empty titles, and rejects titles longer than MAX_SESSION_TITLE_CHARS (100 chars, counted per Unicode char). Any rename or create surface that passes an over-long title gets this InvalidInput io::Error. The `{}` in the message is the constant bound (100), so the rendered message states the exact limit.

Solutions

  1. Shorten the title to 100 characters or fewer (counting chars, not bytes).
  2. Truncate before calling the API, e.g. title.chars().take(MAX_SESSION_TITLE_CHARS).collect::<String>().
  3. For scripted renames, validate the length first and surface a clear message instead of the io::Error.

Example fix

// before
manager.rename(id, long_title)?;
// after
let short: String = long_title.trim().chars().take(100).collect();
manager.rename(id, short)?;
Defensive patterns

Strategy: validation

Validate before calling

fn valid_title(t: &str) -> bool {
    let trimmed = t.trim();
    !trimmed.is_empty() && trimmed.chars().count() <= 100
}

Prevention

When it happens

Trigger: Calling any session-rename or session-create API (picker rename, `/rename` command, SessionManager::rename) with a title whose trimmed text is more than 100 Unicode characters.

Common situations: Pasting a long file path, commit message, or conversation excerpt as a session title; renaming a session from a script that builds titles programmatically; multi-byte input where byte length feels small but char count exceeds 100.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/e72983467e309f97. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/session_manager.rs:3009

        .collect()
}

/// Sanitize, trim, and bound a user-supplied session title.
///
/// Returns `InvalidInput` for an empty title or one longer than
/// [`MAX_SESSION_TITLE_CHARS`] so every rename surface (picker, `/rename`,
/// `PATCH /v1/sessions/{id}`) rejects the same inputs with the same reason.
pub fn normalize_session_title(title: &str) -> std::io::Result<String> {
    let sanitized = sanitize_session_title(title);
    let trimmed = sanitized.trim();
    if trimmed.is_empty() {
        return Err(std::io::Error::new(
            std::io::ErrorKind::InvalidInput,
            "Session title cannot be empty",
        ));
    }
    if trimmed.chars().count() > MAX_SESSION_TITLE_CHARS {
        return Err(std::io::Error::new(
            std::io::ErrorKind::InvalidInput,
            format!("Session title cannot exceed {MAX_SESSION_TITLE_CHARS} characters"),
        ));
    }
    Ok(trimmed.to_string())
}

pub(crate) fn workspace_scope_matches(saved_workspace: &Path, current_workspace: &Path) -> bool {
    if paths_equivalent(saved_workspace, current_workspace) {
        return true;
    }

    // Repository identity comes from the containing checkout itself (Git
    // dir/worktree traversal shared with project-context scope resolution),
    // never from branch names or paths mentioned in conversation.
    let canonical = |path: &Path| fs::canonicalize(path).unwrap_or_else(|_| path.to_path_buf());
    match (
        find_git_root(&canonical(saved_workspace)),

View on GitHub (pinned to 73e0f67d83)