{"record":{"id":"c88103c7d8509979","repo":"Hmbown/CodeWhale","slug":"session-title-cannot-be-empty","errorCode":null,"errorMessage":"Session title cannot be empty","messagePattern":"Session title cannot be empty","errorType":"validation","errorClass":"io::Error","httpStatus":null,"severity":"warning","filePath":"crates/tui/src/session_manager.rs","lineNumber":3003,"sourceCode":"/// OSC 0 terminal title, `codewhale sessions` stdout, and the picker, so the\n/// persisted value must not be able to carry a raw escape sequence. Ordinary\n/// text, punctuation, CJK, and emoji pass through untouched.\npub fn sanitize_session_title(raw: &str) -> String {\n    raw.chars()\n        .filter(|ch| !ch.is_control() && !is_title_format_char(*ch))\n        .collect()\n}\n\n/// Sanitize, trim, and bound a user-supplied session title.\n///\n/// Returns `InvalidInput` for an empty title or one longer than\n/// [`MAX_SESSION_TITLE_CHARS`] so every rename surface (picker, `/rename`,\n/// `PATCH /v1/sessions/{id}`) rejects the same inputs with the same reason.\npub fn normalize_session_title(title: &str) -> std::io::Result<String> {\n    let sanitized = sanitize_session_title(title);\n    let trimmed = sanitized.trim();\n    if trimmed.is_empty() {\n        return Err(std::io::Error::new(\n            std::io::ErrorKind::InvalidInput,\n            \"Session title cannot be empty\",\n        ));\n    }\n    if trimmed.chars().count() > MAX_SESSION_TITLE_CHARS {\n        return Err(std::io::Error::new(\n            std::io::ErrorKind::InvalidInput,\n            format!(\"Session title cannot exceed {MAX_SESSION_TITLE_CHARS} characters\"),\n        ));\n    }\n    Ok(trimmed.to_string())\n}\n\npub(crate) fn workspace_scope_matches(saved_workspace: &Path, current_workspace: &Path) -> bool {\n    if paths_equivalent(saved_workspace, current_workspace) {\n        return true;\n    }\n","sourceCodeStart":2985,"sourceCodeEnd":3021,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/session_manager.rs#L2985-L3021","documentation":"normalize_session_title sanitizes a user-supplied title and rejects the result if it is empty after trimming, with an InvalidInput io::Error. The library throws this because an empty title would make sessions unidentifiable in the picker and API surfaces that all funnel through this shared validator.","triggerScenarios":"Calling normalize_session_title (directly or via rename flows: picker rename, /rename command, PATCH /v1/sessions/{id}) with a title that is empty, whitespace-only, or becomes empty after sanitization strips all characters (e.g. only control/formatting characters).","commonSituations":"Submitting an empty rename form, sending {\"title\": \"   \"} to the HTTP API, or a title consisting solely of characters the sanitizer removes.","solutions":["Provide a non-empty title with at least one visible character after trimming.","If sanitization strips the content, choose characters the sanitizer preserves (letters, digits, common punctuation).","On the API/UI side, validate client-side that the trimmed title is non-empty before calling rename."],"exampleFix":"// before\nlet title = normalize_session_title(\"   \")?; // InvalidInput\n// after\nlet raw = input.trim();\nif raw.is_empty() { anyhow::bail!(\"please enter a session title\"); }\nlet title = normalize_session_title(raw)?;","handlingStrategy":"validation","validationCode":"fn title_ok(t: &str) -> bool {\n    !t.trim().is_empty()\n}","typeGuard":null,"tryCatchPattern":"match normalize_session_title(input) {\n    Err(e) if e.kind() == std::io::ErrorKind::InvalidInput => {\n        eprintln!(\"title rejected: {e}\");\n        Err(e)\n    }\n    other => other,\n}","preventionTips":["Trim and check non-empty in UI/API layers before calling rename.","Respect MAX_SESSION_TITLE_CHARS when collecting input.","Remember sanitization can strip characters — ensure at least one survives."],"tags":["session-title","validation","empty-input","rename"],"backgroundTag":"empty-required-field","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}