copyWith method

CliConfig copyWith({
  1. String? providerKind,
  2. String? modelId,
  3. String? baseUrl,
  4. String? mode,
  5. String? approvalMode,
  6. List<String>? allowedTools,
  7. Map<String, String>? promptOverrides,
  8. ModelRolesConfig? modelRoles,
  9. TtsrConfig? ttsr,
  10. int? contextWindowCap,
  11. StuckToolConfig? stuckTool,
  12. String? agentLoadMode,
  13. List<CustomProviderEntry>? customProviders,
  14. ModelsConfig? models,
  15. McpConfig? mcp,
  16. A2aConfig? a2a,
  17. ProviderTimeoutsOverride? providerTimeouts,
  18. SkillsAccess? skillsAccess,
  19. bool? skillsDisableShellExecution,
  20. bool? skillsLiveRediscovery,
  21. Map<String, bool>? skillToggles,
  22. MemoryConfig? memory,
  23. FabricConfig? fabric,
  24. CubeSettings? cube,
  25. ToolsConfig? tools,
  26. RedactionConfig? redact,
  27. SpillsConfig? spills,
  28. CompactionEngine? compactionEngine,
  29. int? compactionJudgeBudgetSeconds,
  30. bool? wireDump,
  31. ImageRegistryConfig? images,
  32. String? agentMode,
  33. bool? misuseBreaker,
  34. SubagentsConfig? subagents,
  35. WaitingConfig? waiting,
  36. JobsConfig? jobs,
  37. HeadlessConfig? headless,
  38. PowerAssertionLevel? powerSleepPrevention,
  39. PowerAssertionHold? powerHold,
  40. QuotaSection? quota,
  41. String? tuiTheme,
  42. bool? tuiClassic,
  43. StatusLineConfig? statusLine,
  44. LinksConfig? links,
  45. bool? streamThinking,
  46. AutoUpdateMode? autoUpdate,
})

Returns a copy with the given fields replaced; every omitted field carries over (null = keep). The base for the boot's persistConfig save (gh-1572): the loaded config is the base, only the session-live overlays are passed, so a save can never reset a section the caller did not mention. Nullable sections model absence as null — a copyWith cannot CLEAR one (pass the parsed value or keep it).

Implementation

CliConfig copyWith({
  String? providerKind,
  String? modelId,
  String? baseUrl,
  String? mode,
  String? approvalMode,
  List<String>? allowedTools,
  Map<String, String>? promptOverrides,
  ModelRolesConfig? modelRoles,
  TtsrConfig? ttsr,
  int? contextWindowCap,
  StuckToolConfig? stuckTool,
  String? agentLoadMode,
  List<CustomProviderEntry>? customProviders,
  ModelsConfig? models,
  McpConfig? mcp,
  A2aConfig? a2a,
  ProviderTimeoutsOverride? providerTimeouts,
  SkillsAccess? skillsAccess,
  bool? skillsDisableShellExecution,
  bool? skillsLiveRediscovery,
  Map<String, bool>? skillToggles,
  MemoryConfig? memory,
  FabricConfig? fabric,
  CubeSettings? cube,
  ToolsConfig? tools,
  RedactionConfig? redact,
  SpillsConfig? spills,
  CompactionEngine? compactionEngine,
  int? compactionJudgeBudgetSeconds,
  bool? wireDump,
  ImageRegistryConfig? images,
  String? agentMode,
  bool? misuseBreaker,
  SubagentsConfig? subagents,
  WaitingConfig? waiting,
  JobsConfig? jobs,
  HeadlessConfig? headless,
  PowerAssertionLevel? powerSleepPrevention,
  PowerAssertionHold? powerHold,
  QuotaSection? quota,
  String? tuiTheme,
  bool? tuiClassic,
  StatusLineConfig? statusLine,
  LinksConfig? links,
  bool? streamThinking,
  AutoUpdateMode? autoUpdate,
}) {
  return CliConfig(
    providerKind: providerKind ?? this.providerKind,
    modelId: modelId ?? this.modelId,
    baseUrl: baseUrl ?? this.baseUrl,
    mode: mode ?? this.mode,
    approvalMode: approvalMode ?? this.approvalMode,
    allowedTools: allowedTools ?? this.allowedTools,
    promptOverrides: promptOverrides ?? this.promptOverrides,
    modelRoles: modelRoles ?? this.modelRoles,
    ttsr: ttsr ?? this.ttsr,
    contextWindowCap: contextWindowCap ?? this.contextWindowCap,
    stuckTool: stuckTool ?? this.stuckTool,
    agentLoadMode: agentLoadMode ?? this.agentLoadMode,
    customProviders: customProviders ?? this.customProviders,
    models: models ?? this.models,
    mcp: mcp ?? this.mcp,
    a2a: a2a ?? this.a2a,
    providerTimeouts: providerTimeouts ?? this.providerTimeouts,
    skillsAccess: skillsAccess ?? this.skillsAccess,
    skillsDisableShellExecution:
        skillsDisableShellExecution ?? this.skillsDisableShellExecution,
    skillsLiveRediscovery:
        skillsLiveRediscovery ?? this.skillsLiveRediscovery,
    skillToggles: skillToggles ?? this.skillToggles,
    memory: memory ?? this.memory,
    fabric: fabric ?? this.fabric,
    cube: cube ?? this.cube,
    tools: tools ?? this.tools,
    redact: redact ?? this.redact,
    spills: spills ?? this.spills,
    compactionEngine: compactionEngine ?? this.compactionEngine,
    compactionJudgeBudgetSeconds:
        compactionJudgeBudgetSeconds ?? this.compactionJudgeBudgetSeconds,
    wireDump: wireDump ?? this.wireDump,
    images: images ?? this.images,
    agentMode: agentMode ?? this.agentMode,
    misuseBreaker: misuseBreaker ?? this.misuseBreaker,
    subagents: subagents ?? this.subagents,
    waiting: waiting ?? this.waiting,
    jobs: jobs ?? this.jobs,
    headless: headless ?? this.headless,
    powerSleepPrevention: powerSleepPrevention ?? this.powerSleepPrevention,
    powerHold: powerHold ?? this.powerHold,
    quota: quota ?? this.quota,
    tuiTheme: tuiTheme ?? this.tuiTheme,
    tuiClassic: tuiClassic ?? this.tuiClassic,
    statusLine: statusLine ?? this.statusLine,
    links: links ?? this.links,
    streamThinking: streamThinking ?? this.streamThinking,
    autoUpdate: autoUpdate ?? this.autoUpdate,
  );
}