{"record":{"id":"4765dd3e8a42c1b7","repo":"xai-org/grok-build","slug":"err","errorCode":null,"errorMessage":"{err}","messagePattern":"\\{err\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-pager/src/app/mod.rs","lineNumber":709,"sourceCode":"    }\n    if session_startup::chat_mode_conflicts_with_leader(args.chat(), use_leader) {\n        anyhow::bail!(\"{}\", session_startup::CHAT_MODE_LEADER_CONFLICT);\n    }\n    if args.trust {\n        match std::env::current_dir() {\n            Ok(cwd) => xai_grok_workspace::folder_trust::grant_folder_trust(&cwd),\n            Err(e) => {\n                tracing::warn!(error = %e, \"--trust: failed to resolve cwd; folder not trusted\")\n            }\n        }\n    }\n    if let Some(reason) = policy_disable_reason {\n        tokio::spawn(xai_grok_shell::leader::kill_stale_reachable_leaders(reason));\n    }\n    if let Some(err) =\n        session_startup::chat_mode_flag_conflict(args.chat(), args.fork_session, args.restore_code)\n    {\n        anyhow::bail!(\"{err}\");\n    }\n    #[cfg(feature = \"local-workspace\")]\n    {\n        let lw = session_startup::resolve_local_workspace_config(\n            args.chat(),\n            args.local_workspace(),\n            args.local_workspace_attach(),\n            args.local_workspace_cwd(),\n        )?;\n        if let Some(ref cfg) = lw {\n            session_startup::emit_local_workspace_startup_ux(cfg)?;\n        }\n        session_startup::set_active_local_workspace(lw)?;\n    }\n    let intent = args\n        .session_startup_intent()\n        .map_err(|e| anyhow::anyhow!(\"{e}\"))?;\n    let mut materialize_ctx = session_startup::MaterializeCtx::from_pager_args(&args);","sourceCodeStart":691,"sourceCodeEnd":727,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-pager/src/app/mod.rs#L691-L727","documentation":"During startup the CLI validates chat-mode flag combinations via `session_startup::chat_mode_flag_conflict(args.chat(), args.fork_session, args.restore_code)`; when `--chat` is combined with `--fork-session` or `--restore-code` (which operate on non-chat sessions), the returned Some(reason) is surfaced with `anyhow::bail!(\"{err}\")`.","triggerScenarios":"Invoking the binary with `--chat` plus `--fork-session`, or `--chat` plus `--restore-code`; any script passing all three flags together.","commonSituations":"Reusing a fork/restore command line and adding `--chat`; CI scripts templating flags where chat was toggled on without removing session-restore flags.","solutions":["Drop `--fork-session`/`--restore-code` when using `--chat`","Run fork/restore without the chat flag","Audit generated command lines in scripts to keep chat flags separate from session-management flags"],"exampleFix":"// before\ngrok-pager --chat --fork-session\n// after\ngrok-pager --fork-session   # or: grok-pager --chat","handlingStrategy":"validation","validationCode":"fn ensure_chat_flags_valid(chat: bool, fork: bool, restore: Option<String>) -> Result<(), String> {\n    if chat && (fork || restore.is_some()) {\n        Err(\"--fork-session/--restore-code cannot be used with --chat\".into())\n    } else { Ok(()) }\n}","typeGuard":"fn chat_without_session_flags(chat: bool, fork: bool, restore: bool) -> bool {\n    chat && !fork && !restore\n}","tryCatchPattern":"if let Err(e) = run_pager(args) {\n    let msg = e.to_string();\n    if msg.contains(\"fork\") || msg.contains(\"restore\") { eprintln!(\"conflicting session flags with --chat: {msg}\"); }\n    else { eprintln!(\"startup failed: {msg}\"); }\n}","preventionTips":["Never template --chat together with --fork-session/--restore-code","Validate CLI flag combinations in wrapper scripts before exec","Document chat mode as incompatible with session fork/restore"],"tags":["cli","startup","flag-conflict"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}