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
4 changes: 2 additions & 2 deletions docs/interactive-capabilities/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ OpenBitFun Playbook currently contains **22 features**, **22 settings pages**, a
- Generated per-item interaction audit: `docs/interactive-capabilities/technical/product-control-open-audit.json`
- Generated low-level audit map: `docs/interactive-capabilities/technical/tauri-command-map.json`

说明书、网站、搜索和智能体只看“功能 + 设置 + 子能力”。每项子能力都必须引用已注册 Tauri Command 或可解析的源码标记;这些证据不会进入公开目录。当前 **705** 个 Tauri 命令只用于实现覆盖审计。产品 UI 交互源码会在生成和检查时扫描并校验,但不会保存成随普通 UI 改动频繁变化的版本化快照。
说明书、网站、搜索和智能体只看“功能 + 设置 + 子能力”。每项子能力都必须引用已注册 Tauri Command 或可解析的源码标记;这些证据不会进入公开目录。当前 **706** 个 Tauri 命令只用于实现覆盖审计。产品 UI 交互源码会在生成和检查时扫描并校验,但不会保存成随普通 UI 改动频繁变化的版本化快照。

Docs, website, search, and agents see only features, settings, and documented sub-capabilities. Every sub-capability must reference a registered Tauri command or a resolvable source marker; evidence is stripped from public projections. The **705** Tauri commands remain implementation-audit evidence only. Product UI interaction sources are scanned and validated during generation and checks, but are not stored as a versioned snapshot that churns with ordinary UI changes.
Docs, website, search, and agents see only features, settings, and documented sub-capabilities. Every sub-capability must reference a registered Tauri command or a resolvable source marker; evidence is stripped from public projections. The **706** Tauri commands remain implementation-audit evidence only. Product UI interaction sources are scanned and validated during generation and checks, but are not stored as a versioned snapshot that churns with ordinary UI changes.

## 控制边界 / Control boundary

Expand Down
22 changes: 19 additions & 3 deletions docs/interactive-capabilities/technical/tauri-command-map.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"schemaVersion": 2,
"generatedFrom": "src/shared/interactive-capabilities/catalog.json",
"catalogDigest": "8a02be2b328791ebb823e4b7a956bf0371c523caa7f881a6c778cbaa42d72575",
"commandCount": 705,
"commandCount": 706,
"coverage": {
"commandCount": 705,
"documentedCommandCount": 644,
"commandCount": 706,
"documentedCommandCount": 645,
"implementationCommandCount": 61,
"implementationDigest": "fdb6f78b009b95270d26834349aade36e0987553167f325a9c674a085b876a2d"
},
Expand Down Expand Up @@ -4806,6 +4806,22 @@
"signature": "fn git_get_status( state: State<'_, AppState>, mut request: GitRepositoryRequest, ) -> Result<GitStatus, String>",
"remoteWorkspacePolicy": "RemoteRouted"
},
{
"id": "git_get_tracked_change_count",
"moduleId": "git",
"capabilityId": "feature.git",
"capabilityIds": [
"feature.git"
],
"documentedItemIds": [
"feature.git:status-diff"
],
"visibility": "documented",
"rustPath": "git_get_tracked_change_count",
"sourceFile": "src/apps/desktop/src/api/git_api.rs",
"signature": "fn git_get_tracked_change_count( state: State<'_, AppState>, request: GitTrackedChangeCountRequest, ) -> Result<Option<usize>, String>",
"remoteWorkspacePolicy": "RemoteRouted"
},
{
"id": "git_is_repository",
"moduleId": "git",
Expand Down
12 changes: 12 additions & 0 deletions src/apps/cli/src/peer_host/commands/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ fn resolved_repository_path(
/// repository so an SSH workspace can never fall back to a same-named local path.
pub(crate) async fn read(command: &str, args: &Value) -> Result<Value, String> {
let request = request_value(args);
if command == "git_get_tracked_change_count"
&& optional_string(request, "workspaceId").is_none()
{
return Err("Workspace ID is required".into());
}
let path = repository_path_for_workspace(request).await?;
read_at_path(command, &path, request).await
}
Expand Down Expand Up @@ -80,6 +85,9 @@ async fn read_at_path(command: &str, path: &str, request: &Value) -> Result<Valu
git_result(command, GitService::get_repository_basic(path).await)
}
"git_get_status" => git_result(command, GitService::get_status(path).await),
"git_get_tracked_change_count" => {
git_result(command, GitService::get_tracked_change_count(path).await)
}
"git_get_branches" | "git_get_enhanced_branches" => {
let options: BranchOptions = serde_json::from_value(request.clone())
.map_err(|error| format!("Invalid Git branch request: {error}"))?;
Expand Down Expand Up @@ -211,6 +219,10 @@ mod tests {
.unwrap();
assert_eq!(status["unstaged"][0]["path"], "tracked.txt");
assert_eq!(status["untracked"][0], "untracked.txt");
let count = read_at_path("git_get_tracked_change_count", path, &json!({}))
.await
.unwrap();
assert_eq!(count, 1);
for command in ["git_get_branches", "git_get_enhanced_branches"] {
let branches = read_at_path(command, path, &json!({"includeRemote": false}))
.await
Expand Down
2 changes: 2 additions & 0 deletions src/apps/cli/src/peer_host/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ pub(crate) fn dispatch<'a>(
"git_get_repository"
| "git_get_repository_basic"
| "git_get_status"
| "git_get_tracked_change_count"
| "git_get_branches"
| "git_get_enhanced_branches"
| "git_get_commits"
Expand Down Expand Up @@ -374,6 +375,7 @@ pub(crate) const HANDLED_COMMANDS: &[&str] = &[
"git_get_repository",
"git_get_repository_basic",
"git_get_status",
"git_get_tracked_change_count",
"git_get_branches",
"git_get_enhanced_branches",
"git_get_commits",
Expand Down
75 changes: 73 additions & 2 deletions src/apps/desktop/src/api/git_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ use openbitfun_core::service::git::{
use openbitfun_core::service::remote_ssh::{
build_remote_git_command as build_remote_git_command_shared, normalize_remote_workspace_path,
};
use openbitfun_core::service::workspace::WorktreeTopologyFreshness;
use openbitfun_core::service::workspace::{
WorkspaceInfo, WorkspaceKind, WorktreeTopologyFreshness,
};
use openbitfun_services_integrations::remote_ssh::{
build_remote_git_tracked_change_count_command, SSHCommandOptions,
};
use serde::{Deserialize, Serialize};
use std::time::Instant;
use tauri::State;
Expand Down Expand Up @@ -67,7 +72,14 @@ async fn resolve_remote_git_target(
.require_workspace(workspace_id)
.await
.map_err(|e| e.to_string())?;
if workspace.workspace_kind != openbitfun_core::service::workspace::WorkspaceKind::Remote {
remote_git_target_for_workspace(&workspace, repository_path)
}

fn remote_git_target_for_workspace(
workspace: &WorkspaceInfo,
repository_path: &str,
) -> Result<Option<RemoteGitTarget>, String> {
if workspace.workspace_kind != WorkspaceKind::Remote {
return Ok(None);
}
let connection_id = workspace
Expand Down Expand Up @@ -431,6 +443,12 @@ pub struct GitRepositoryRequest {
pub repository_path: String,
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GitTrackedChangeCountRequest {
pub workspace_id: String,
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GitResolveRevisionRequest {
Expand Down Expand Up @@ -997,6 +1015,59 @@ pub async fn git_resolve_revision(
.map_err(|e| git_error_message("Failed to resolve Git revision", &e))
}

#[tauri::command]
pub async fn git_get_tracked_change_count(
state: State<'_, AppState>,
request: GitTrackedChangeCountRequest,
) -> Result<Option<usize>, String> {
let workspace = openbitfun_core::service::workspace::get_global_workspace_service()
.ok_or("Workspace service is unavailable")?
.require_workspace(&request.workspace_id)
.await
.map_err(|e| e.to_string())?;
if let Some(target) =
remote_git_target_for_workspace(&workspace, &workspace.root_path.to_string_lossy())?
{
let manager = state
.get_ssh_manager_async()
.await
.map_err(|e| e.to_string())?;
let command = build_remote_git_tracked_change_count_command(&target.repository_path);
let output = manager
.execute_command_with_options(
&target.connection_id,
&command,
SSHCommandOptions {
timeout_ms: Some(5_000),
..Default::default()
},
)
.await
.map_err(|e| e.to_string())?;
if output.timed_out || output.interrupted {
return Err("Remote Git change count was interrupted".into());
}
if output.exit_code != 0 {
if trust::is_missing_repository_message(&output.stderr) {
return Ok(None);
}
return Err(remote_git_error_message(
&target.repository_path,
format!("Failed to count tracked changes: {}", output.stderr.trim()),
));
}
return output
.stdout
.trim()
.parse()
.map(Some)
.map_err(|_| "Invalid remote Git change count".into());
}
GitService::get_tracked_change_count(&workspace.root_path)
.await
.map_err(|error| git_error_message("Failed to count tracked changes", &error))
}

#[tauri::command]
pub async fn git_get_status(
state: State<'_, AppState>,
Expand Down
1 change: 1 addition & 0 deletions src/apps/desktop/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1683,6 +1683,7 @@ pub async fn run() {
review_platform_update_auth_token,
review_platform_clear_auth_token,
git_get_status,
git_get_tracked_change_count,
git_get_branches,
git_get_enhanced_branches,
git_get_commits,
Expand Down
Loading
Loading