Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/agent_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}

CLI_MIN_UNTITLED_MESSAGE_COUNT = 6
CLI_MIN_UNTITLED_USER_MESSAGE_COUNT = 2
CLI_MIN_UNTITLED_USER_MESSAGE_COUNT = 1

SOURCE_LABELS = {
'api_server': 'API',
Expand Down
22 changes: 11 additions & 11 deletions api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1918,7 +1918,7 @@ def _get_provider_base_url(provider_id):

Returns the URL stripped of trailing ``/`` if configured, otherwise None.
"""
prov_cfg = cfg.get("providers", {}).get(provider_id, {}) or {}
prov_cfg = (cfg.get("providers") or {}).get(provider_id, {}) or {}
explicit = (prov_cfg.get("base_url") or "").strip().rstrip("/")
if explicit:
return explicit
Expand Down Expand Up @@ -4181,7 +4181,7 @@ def _build_configured_model_badges() -> dict[str, dict[str, str]]:
# and a phantom ``Opencode_Go`` group for the config-key form (#1568).
# The same applies to mixed-case ids like ``OpenCode-Go`` and to
# legitimate aliases like ``z-ai`` → ``zai``.
_cfg_providers = cfg.get("providers", {})
_cfg_providers = (cfg.get("providers") or {})
# Map canonical provider IDs back to raw config keys so the
# generic-provider branch can preserve mixed-case/underscore
# provider_cfg values (#2245).
Expand Down Expand Up @@ -4224,7 +4224,7 @@ def _configured_provider_for_base_url(base_url: object) -> str:
if provider_hint:
return str(provider_hint).strip().lower()

providers_cfg = cfg.get("providers", {})
providers_cfg = (cfg.get("providers") or {})
if isinstance(providers_cfg, dict):
for provider_key, provider_cfg in providers_cfg.items():
if not isinstance(provider_cfg, dict):
Expand Down Expand Up @@ -4418,7 +4418,7 @@ def _read_custom_endpoint_models(
if isinstance(model_cfg, dict):
api_key = (model_cfg.get("api_key") or "").strip()
if not api_key:
providers_cfg = cfg.get("providers", {})
providers_cfg = (cfg.get("providers") or {})
if isinstance(providers_cfg, dict):
for provider_key in filter(None, [active_provider, "custom"]):
provider_cfg = providers_cfg.get(provider_key, {})
Expand Down Expand Up @@ -4578,7 +4578,7 @@ def _read_custom_endpoint_models(
isinstance(_cp, dict) and not (_cp.get("name") or "").strip()
for _cp in _custom_providers_cfg
)
if not _has_unnamed:
if not _has_unnamed and not auto_detected_models:
detected_providers.discard("custom")
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved

_named_custom_slugs = _named_custom_provider_slugs(cfg)
Expand All @@ -4590,13 +4590,13 @@ def _read_custom_endpoint_models(
detected_providers.discard(_pid)

# Filter providers if providers.only_configured is set
providers_cfg = cfg.get("providers", {})
providers_cfg = (cfg.get("providers") or {})
only_show_configured = providers_cfg.get("only_configured", False) if isinstance(providers_cfg, dict) else False
if only_show_configured:
configured_providers = set()
if active_provider:
configured_providers.add(active_provider)
cfg_providers = cfg.get("providers", {})
cfg_providers = (cfg.get("providers") or {})
if isinstance(cfg_providers, dict):
# Canonicalise here too — same rationale as #1568 detection
# path. Without this, only_show_configured mode could
Expand Down Expand Up @@ -4927,7 +4927,7 @@ def _read_custom_endpoint_models(
# `cfg["providers"]["lmstudio"]["base_url"]` or
# `cfg["model"]["base_url"]` (via _get_provider_base_url),
# so the historical model-block config shape still works.
lm_cfg = cfg.get("providers", {}).get("lmstudio", {}) or {}
lm_cfg = (cfg.get("providers") or {}).get("lmstudio", {}) or {}
lm_base_url = _get_provider_base_url("lmstudio") or ""
lm_api_key = str(lm_cfg.get("api_key") or "").strip() if isinstance(lm_cfg, dict) else ""
if lm_base_url:
Expand Down Expand Up @@ -4968,7 +4968,7 @@ def _read_custom_endpoint_models(
# (#2245). Fall back to the canonical pid for providers
# that appear in _PROVIDER_MODELS but not in cfg.
_raw_key = _canonical_to_raw_provider_key.get(pid, pid)
provider_cfg = cfg.get("providers", {}).get(_raw_key, {})
provider_cfg = (cfg.get("providers") or {}).get(_raw_key, {})
raw_models = []

# User-configured model allowlists are explicit local
Expand Down Expand Up @@ -5009,7 +5009,7 @@ def _read_custom_endpoint_models(
detected_models = auto_detected_models_by_provider.get(pid)
if detected_models:
models_for_group = copy.deepcopy(detected_models)
elif auto_detected_models:
elif pid in ("custom", "local") and auto_detected_models:
# Don't fall back to the global auto_detected_models
# list for the bare "custom" PID when the active
# provider is something concrete (e.g. ai-gateway,
Expand Down Expand Up @@ -5134,7 +5134,7 @@ def _read_custom_endpoint_models(
except Exception:
pass
try:
_cfg_providers = cfg.get("providers", {})
_cfg_providers = (cfg.get("providers") or {})
if isinstance(_cfg_providers, dict):
for _pk, _pv in _cfg_providers.items():
if isinstance(_pv, dict) and (_pv.get("api_key") or _pv.get("key_env")):
Expand Down
2 changes: 1 addition & 1 deletion api/onboarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ def _provider_api_key_present(
if isinstance(model_cfg, dict) and str(model_cfg.get("api_key") or "").strip():
return True

providers_cfg = cfg.get("providers", {})
providers_cfg = (cfg.get("providers") or {})
if isinstance(providers_cfg, dict):
provider_cfg = providers_cfg.get(provider, {})
if (
Expand Down
10 changes: 5 additions & 5 deletions api/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ def _provider_has_shadowed_codex_oauth_value(provider_id: str) -> bool:
active_provider = str(model_cfg.get("provider") or "").strip().lower()
if active_provider == provider_id:
values.append(model_cfg.get("api_key"))
providers_cfg = cfg.get("providers", {})
providers_cfg = (cfg.get("providers") or {})
if isinstance(providers_cfg, dict):
provider_cfg = providers_cfg.get(provider_id, {})
if isinstance(provider_cfg, dict):
Expand Down Expand Up @@ -1000,7 +1000,7 @@ def _provider_has_key(provider_id: str) -> bool:
if _provider_value_counts_as_api_key(provider_id, model_cfg.get("api_key")):
return True
# Check providers.<id>.api_key
providers_cfg = cfg.get("providers", {})
providers_cfg = (cfg.get("providers") or {})
if isinstance(providers_cfg, dict):
provider_cfg = providers_cfg.get(provider_id, {})
if isinstance(provider_cfg, dict) and str(provider_cfg.get("api_key") or "").strip():
Expand Down Expand Up @@ -1046,7 +1046,7 @@ def _get_provider_api_key(provider_id: str) -> str | None:
if model_key and active_provider == provider_id and _provider_value_counts_as_api_key(provider_id, model_key):
return model_key

providers_cfg = cfg.get("providers", {})
providers_cfg = (cfg.get("providers") or {})
if isinstance(providers_cfg, dict):
provider_cfg = providers_cfg.get(provider_id, {})
if isinstance(provider_cfg, dict):
Expand Down Expand Up @@ -2024,7 +2024,7 @@ def get_providers() -> dict[str, Any]:

# Also detect providers from config.yaml providers section
cfg = get_config()
providers_cfg = cfg.get("providers", {})
providers_cfg = (cfg.get("providers") or {})
if isinstance(providers_cfg, dict):
known_ids.update(providers_cfg.keys())

Expand Down Expand Up @@ -2449,7 +2449,7 @@ def _clean_provider_key_from_config(provider_id: str) -> None:
return

# 1. Clean providers.<id>.api_key
providers_cfg = cfg.get("providers", {})
providers_cfg = (cfg.get("providers") or {})
if isinstance(providers_cfg, dict):
provider_cfg = providers_cfg.get(provider_id, {})
if isinstance(provider_cfg, dict) and provider_cfg.get("api_key"):
Expand Down
4 changes: 2 additions & 2 deletions api/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2340,7 +2340,7 @@ def _context_length_lookup_inputs_for_model(
custom_providers = None

provider_context_length = None
providers_cfg = cfg.get("providers", {}) if isinstance(cfg, dict) else {}
providers_cfg = (cfg.get("providers") or {}) if isinstance(cfg, dict) else {}
if isinstance(providers_cfg, dict):
for provider_key, provider_cfg in providers_cfg.items():
if not isinstance(provider_cfg, dict):
Expand Down Expand Up @@ -11405,7 +11405,7 @@ def _custom_provider_api_key(_cp):
if _ep:
try:
import urllib.request
_providers_cfg = cfg.get("providers", {})
_providers_cfg = (cfg.get("providers") or {})
_prov = _providers_cfg.get(provider, {}) if isinstance(_providers_cfg, dict) else {}
# Only use provider-scoped key — never fall back to a top-level
# api_key which may belong to a different provider.
Expand Down
23 changes: 22 additions & 1 deletion static/panels.js
Original file line number Diff line number Diff line change
Expand Up @@ -5626,16 +5626,37 @@ async function switchToProfile(name) {
await renderSessionList();
showToast(t('profile_switched_new_conversation', name));
} else {
// No messages yet — just refresh the list and topbar in place
// No messages yet — but if we're holding a session from the old profile,
// start a new one so subsequent operations (workspace switch, send) don't
// operate on a cross-profile session (#2535).
const stale = S.session && (S.session.profile ? S.session.profile !== name : name !== 'default');
if (stale) {
await newSession(false);
if (S._profileDefaultWorkspace && S.session) {
try {
await api('/api/session/update', { method: 'POST', body: JSON.stringify({
session_id: S.session.session_id,
workspace: S._profileDefaultWorkspace,
model: S.session.model,
model_provider: S.session.model_provider||null,
})});
S.session.workspace = S._profileDefaultWorkspace;
} catch (_) {}
}
}
await renderSessionList();
if (_switchGen !== _profileSwitchGeneration) return;
syncTopbar();
<<<<<<< Updated upstream
// Refresh workspace file tree so the right panel shows the new
// profile's workspace, not the previous one (#1214).
if (S.session && S.session.workspace) {
const dirLoad = loadDir('.');
if (typeof _workspacePanelMode !== 'undefined' && _workspacePanelMode !== 'closed') await dirLoad;
}
=======
if (S.session && S.session.workspace) loadDir('.');
>>>>>>> Stashed changes
Comment on lines +5650 to +5659

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.

P0 Unresolved Git merge conflict

The file contains raw conflict markers (<<<<<<< Updated upstream, =======, >>>>>>> Stashed changes) at lines 5650–5659. When a browser parses this file, it will throw a syntax error the moment it reaches <<<<<<< Updated upstream, breaking the entire switchToProfile function and everything that follows. The two conflicting versions differ on whether loadDir('.') is awaited conditionally (the upstream version, which also respects _workspacePanelMode) or fired-and-forgotten (the stashed version). One of these must be chosen and the conflict markers removed before merging.

showToast(t('profile_switched', name));
}

Expand Down