Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@

:is([data-flow-item-stack], .explore-region__content, .flow-group-content-segment):has(
> .flowchat-flow-item > .flow-tool-card-wrapper [data-openbitfun-tool-card='agent-control']
) > * {
) > :where(.flowchat-flow-item, .flow-text-block, .flow-thinking-item,
.subagent-projection-text--truncated, .flowchat-capsule-row-break,
.explore-region, .flow-group-content-segment, .model-round-item__meta,
.model-round-item__continuation, .model-round-item__retry-history, .model-round-item__footer) {
/* The stack renderers own these children. An unqualified child after :has()
registered subtree invalidation on unrelated shell ancestors during row
recycling. :where() keeps the original rule's specificity and geometry. */
flex: 0 0 100%;
min-inline-size: 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3781,7 +3781,7 @@
"visibility": "documented",
"rustPath": "get_mode_skill_configs",
"sourceFile": "src/apps/desktop/src/api/skill_api.rs",
"signature": "fn get_mode_skill_configs( state: State<'_, AppState>, mode_id: String, force_refresh: Option<bool>, include_diagnostics: Option<bool>, workspace_id: Option<String>, workspace_path: Option<String>, ) -> Result<Value, String>",
"signature": "fn get_mode_skill_configs( state: State<'_, AppState>, mode_id: String, force_refresh: Option<bool>, include_diagnostics: Option<bool>, workspace_id: Option<String>, workspace_path: Option<String>, summary_mode_ids: Option<Vec<String>>, ) -> Result<Value, String>",
"remoteWorkspacePolicy": "LegacyUnaudited"
},
{
Expand Down
3 changes: 2 additions & 1 deletion scripts/generate-miniapp-chat-styles.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export async function buildMiniAppChatStyles() {
const style = output.find(file => file.type === 'asset' && file.fileName.endsWith('.css'));
if (!script || !style || script.imports.length || script.dynamicImports.length) throw new Error('MiniApp chat projection must contain only CSS and static class names');
const header = '/* Generated from the Hi and FlowChat style owners by scripts/generate-miniapp-chat-styles.mjs. */\n';
return { 'chat-style-classes.js': header + script.code, 'chat-styles.css': header + style.source };
// Vite preserves imported CSS line endings; generated projections use LF on every host.
return { 'chat-style-classes.js': header + script.code, 'chat-styles.css': header + String(style.source).replace(/\r\n?/g, '\n') };
}

if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
Expand Down
1 change: 1 addition & 0 deletions src/apps/cli/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ Run the smallest checks matching the changed path:
cargo check -p openbitfun-cli
cargo test -p openbitfun-cli
cargo test -p openbitfun-cli --bin openbitfun peer_host::
cargo test --locked -p openbitfun-cli --bin openbitfun peer_host::commands::skills::tests
cargo test -p openbitfun-cli --bin openbitfun system_info_home_contract
```

Expand Down
39 changes: 37 additions & 2 deletions src/apps/cli/src/peer_host/commands/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1007,14 +1007,43 @@ pub(crate) async fn get_available_modes(
let mode_infos = get_agent_registry()
.get_modes_info_for_workspace(workspace_id.as_deref(), workspace_id.is_some())
.await;
let include_counts = request
.get("includeSubagentCounts")
.and_then(Value::as_bool)
.unwrap_or(false);
let counts = if include_counts {
let local_scope = match workspace_id.as_deref() {
Some(id) => {
state
.workspace_service
.require_workspace(id)
.await
.map_err(|error| error.to_string())?
.workspace_kind
!= openbitfun_core::service::workspace::WorkspaceKind::Remote
}
None => false,
};
Some(
get_agent_registry()
.mode_manageable_subagent_counts(&mode_infos, workspace_id.as_deref(), local_scope)
.await,
)
} else {
None
};
let dtos: Vec<Value> = mode_infos
.into_iter()
.map(|info| {
let config_profile_id = info
.config_profile_id
.clone()
.unwrap_or_else(|| info.id.clone());
json!({
let count = counts
.as_ref()
.and_then(|counts| counts.get(&config_profile_id))
.copied();
let mut dto = json!({
"id": info.id,
"name": info.name,
"description": info.description,
Expand All @@ -1028,7 +1057,13 @@ pub(crate) async fn get_available_modes(
"source": info.source,
"path": info.path,
"model": info.model,
})
});
if let Some(count) = count {
dto.as_object_mut()
.unwrap()
.insert("manageableSubagentCount".into(), Value::from(count));
}
dto
})
.collect();
Ok(Value::Array(dtos))
Expand Down
94 changes: 86 additions & 8 deletions src/apps/cli/src/peer_host/commands/skills.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,28 +128,70 @@ pub(crate) async fn get_skill_configs(args: &Value) -> Result<Value, String> {
pub(crate) async fn get_mode_skill_configs(args: &Value) -> Result<Value, String> {
let request = request_value(args);
let mode_id = get_string(request, "modeId")?;
let summary_ids = request
.get("summaryModeIds")
.filter(|value| !value.is_null())
.map(|value| {
serde_json::from_value::<Vec<String>>(value.clone())
.map_err(|error| format!("Invalid summaryModeIds: {error}"))
})
.transpose()?;
let include_diagnostics = optional_bool(request, "includeDiagnostics").unwrap_or(false);
let summary = include_diagnostics && summary_ids.is_some();
let mut mode_ids = if summary {
summary_ids.unwrap_or_default()
} else {
Vec::new()
};
if !mode_ids.contains(&mode_id) {
mode_ids.push(mode_id.clone());
}
let workspace = resolve_workspace(request).await?;
let registry = SkillRegistry::global();
if optional_bool(request, "forceRefresh").unwrap_or(false) {
registry.refresh().await;
}
let report = if let Some((root, fs)) = remote_workspace_fs(workspace.as_ref()).await? {
let mut reports = if let Some((root, fs)) = remote_workspace_fs(workspace.as_ref()).await? {
within_remote_deadline(
registry.get_mode_skill_scan_report_for_remote_workspace(&fs, &root, &mode_id),
registry.get_mode_skill_scan_reports_for_remote_workspace(&fs, &root, &mode_ids),
)
.await?
} else {
registry
.get_mode_skill_scan_report_for_workspace(
.get_mode_skill_scan_reports_for_workspace(
workspace.as_ref().map(SkillPolicyWorkspace::from_record),
&mode_id,
&mode_ids,
)
.await
};
scan_response(
report,
optional_bool(request, "includeDiagnostics").unwrap_or(false),
)
let counts: std::collections::HashMap<String, usize> = reports
.iter()
.map(|(id, report)| {
(
id.clone(),
report
.skills
.iter()
.filter(|skill| skill.effective_enabled)
.count(),
)
})
.collect();
let report = reports
.remove(&mode_id)
.expect("The anchor mode is included in the summary");
let mut response = scan_response(report, include_diagnostics)?;
if summary {
let object = response
.as_object_mut()
.expect("Diagnostics responses are objects");
object.insert("skillCountsVersion".into(), Value::from(1));
object.insert(
"enabledSkillCounts".into(),
serde_json::to_value(counts).map_err(|error| error.to_string())?,
);
}
Ok(response)
}

/// Read-only availability settings. Version 0 tells the controller that direct
Expand Down Expand Up @@ -189,6 +231,42 @@ mod tests {
assert!(error.contains("modeId"), "{error}");
}

#[tokio::test]
async fn invalid_summary_ids_fail_before_discovery() {
let error = get_mode_skill_configs(
&json!({"modeId":"Cowork","includeDiagnostics":true,"summaryModeIds":[1]}),
)
.await
.unwrap_err();
assert!(error.contains("summaryModeIds"));
}

#[tokio::test]
async fn mode_summary_preserves_legacy_payloads() {
let legacy = get_mode_skill_configs(&json!({"modeId":"Cowork"}))
.await
.unwrap();
let diagnostic =
get_mode_skill_configs(&json!({"modeId":"Cowork","includeDiagnostics":true}))
.await
.unwrap();
assert_eq!(legacy, diagnostic["skills"]);
assert!(diagnostic.get("skillCountsVersion").is_none());
let summary = get_mode_skill_configs(&json!({"modeId":"Cowork","includeDiagnostics":true,"summaryModeIds":["Cowork","review","Cowork"]})).await.unwrap();
assert_eq!(legacy, summary["skills"]);
assert_eq!(summary["skillCountsVersion"], 1);
assert_eq!(
summary["enabledSkillCounts"]["Cowork"].as_u64().unwrap(),
legacy
.as_array()
.unwrap()
.iter()
.filter(|skill| skill["effectiveEnabled"] == true)
.count() as u64
);
assert!(summary["enabledSkillCounts"]["review"].is_number());
}

#[test]
fn global_settings_are_read_only_on_this_host() {
let settings = global_settings_value(vec!["user::a".into()], Vec::new());
Expand Down
34 changes: 34 additions & 0 deletions src/apps/desktop/src/api/agentic_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4256,6 +4256,20 @@ pub async fn get_available_modes(
)
.await;

let counts = if request.include_subagent_counts == Some(true) {
Some(
state
.agent_registry
.mode_manageable_subagent_counts(
&mode_infos,
workspace.as_ref().map(|record| record.id.as_str()),
external_sources_supported,
)
.await,
)
} else {
None
};
let dtos: Vec<ModeInfoDTO> = mode_infos
.into_iter()
.map(|info| {
Expand All @@ -4264,6 +4278,10 @@ pub async fn get_available_modes(
.clone()
.unwrap_or_else(|| info.id.clone());
ModeInfoDTO {
manageable_subagent_count: counts
.as_ref()
.and_then(|counts| counts.get(&config_profile_id))
.copied(),
id: info.id,
name: info.name,
description: info.description,
Expand All @@ -4288,6 +4306,7 @@ pub async fn get_available_modes(
#[derive(Debug, Clone, Default, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GetAvailableModesRequest {
pub include_subagent_counts: Option<bool>,
pub workspace_id: Option<String>,
pub workspace_path: Option<String>,
pub remote_connection_id: Option<String>,
Expand Down Expand Up @@ -4316,6 +4335,8 @@ pub async fn get_default_review_team_definition() -> Result<ReviewTeamDefinition
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ModeInfoDTO {
#[serde(skip_serializing_if = "Option::is_none")]
pub manageable_subagent_count: Option<usize>,
pub id: String,
pub name: String,
pub description: String,
Expand Down Expand Up @@ -4426,6 +4447,19 @@ mod tests {
use openbitfun_product_domains::tool_permissions::{PermissionEffect, PermissionRule};
use serde_json::json;

#[test]
fn legacy_mode_catalog_requests_do_not_require_summary_fields() {
let old: GetAvailableModesRequest =
serde_json::from_value(json!({"workspaceId":"workspace-1"})).unwrap();
assert_eq!(old.include_subagent_counts, None);
assert_eq!(old.workspace_id.as_deref(), Some("workspace-1"));
let new: GetAvailableModesRequest = serde_json::from_value(
json!({"workspaceId":"workspace-1","includeSubagentCounts":true}),
)
.unwrap();
assert_eq!(new.include_subagent_counts, Some(true));
}

#[tokio::test]
async fn mode_catalog_uses_record_kind_even_when_local_and_remote_paths_are_identical() {
use openbitfun_core::service::workspace::{
Expand Down
66 changes: 66 additions & 0 deletions src/apps/desktop/src/api/skill_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ pub async fn get_mode_skill_configs(
include_diagnostics: Option<bool>,
workspace_id: Option<String>,
workspace_path: Option<String>,
summary_mode_ids: Option<Vec<String>>,
) -> Result<Value, String> {
let workspace =
resolve_skill_workspace(workspace_id.as_deref(), workspace_path.as_deref()).await?;
Expand All @@ -764,6 +765,71 @@ pub async fn get_mode_skill_configs(
registry.refresh().await;
}

// Additive projection on the existing diagnostics response. Older hosts
// ignore the optional argument; controllers check skillCountsVersion before
// using the summary and retain the single-mode compatibility path.
if let Some(mut mode_ids) = summary_mode_ids.filter(|_| include_diagnostics == Some(true)) {
if !mode_ids.contains(&mode_id) {
mode_ids.push(mode_id.clone());
}
let mut reports = if let Some((remote_root, entry)) =
resolve_remote_workspace(workspace.as_ref()).await?
{
await_remote_skill_discovery(
async {
let remote_fs = state
.get_remote_file_service_async()
.await
.map_err(|error| format!("Remote file service not available: {error}"))?;
let fs = RemoteWorkspaceFs::new(entry, remote_fs);
Ok(registry
.get_mode_skill_scan_reports_for_remote_workspace(
&fs,
&remote_root,
&mode_ids,
)
.await)
},
REMOTE_SKILL_DISCOVERY_TIMEOUT,
)
.await?
} else {
registry
.get_mode_skill_scan_reports_for_workspace(
workspace.as_ref().map(SkillPolicyWorkspace::from_record),
&mode_ids,
)
.await
};
let counts: HashMap<String, usize> = reports
.iter()
.map(|(id, report)| {
(
id.clone(),
report
.skills
.iter()
.filter(|skill| skill.effective_enabled)
.count(),
)
})
.collect();
let report = reports
.remove(&mode_id)
.expect("The anchor mode is included in the summary");
let mut response =
serialize_skill_scan_response(report, true).map_err(|error| error.to_string())?;
let object = response
.as_object_mut()
.expect("Diagnostics responses are objects");
object.insert("skillCountsVersion".into(), Value::from(1));
object.insert(
"enabledSkillCounts".into(),
serde_json::to_value(counts).map_err(|error| error.to_string())?,
);
return Ok(response);
}

let mode_skill_infos = get_mode_skill_scan_report_for_workspace_input(
&state,
registry,
Expand Down
2 changes: 1 addition & 1 deletion src/crates/assembly/core/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ cargo test --locked -p openbitfun-core --no-default-features --features agent-ru
Skill discovery, installation provenance, and local/remote registry regressions:

```bash
cargo test --locked -p openbitfun-core --no-default-features --features agent-runtime,git --lib agentic::tools::implementations::skills::
cargo test --locked -p openbitfun-core --no-default-features --features agent-runtime,git,file-watch --lib agentic::tools::implementations::skills::
```

SessionControl workspace selection, remote routing, and session-targeted actions:
Expand Down
Loading
Loading