Skip to content
7 changes: 4 additions & 3 deletions scripts/shortcuts/review/fix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ else
conflict_block=""
fi

prompt=$(awk -v pr="$REVIEW_PR" -v repo="$REVIEW_REPO_RESOLVED" \
-v head_repo="$REVIEW_HEAD_REPO" -v head_branch="$REVIEW_HEAD_BRANCH" \
-v conflict="$conflict_block" '
prompt=$(REVIEW_CONFLICT_BLOCK="$conflict_block" \
awk -v pr="$REVIEW_PR" -v repo="$REVIEW_REPO_RESOLVED" \
-v head_repo="$REVIEW_HEAD_REPO" -v head_branch="$REVIEW_HEAD_BRANCH" '
BEGIN { conflict = ENVIRON["REVIEW_CONFLICT_BLOCK"] }
{
gsub(/__PR__/, pr);
gsub(/__REPO__/, repo);
Expand Down
5 changes: 3 additions & 2 deletions scripts/shortcuts/review/review.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ else
conflict_block=""
fi

prompt=$(awk -v pr="$REVIEW_PR" -v repo="$REVIEW_REPO_RESOLVED" \
-v conflict="$conflict_block" '
prompt=$(REVIEW_CONFLICT_BLOCK="$conflict_block" \
awk -v pr="$REVIEW_PR" -v repo="$REVIEW_REPO_RESOLVED" '
BEGIN { conflict = ENVIRON["REVIEW_CONFLICT_BLOCK"] }
{ gsub(/__PR__/, pr); gsub(/__REPO__/, repo); gsub(/__CONFLICT_BLOCK__/, conflict); print }
' "$template")

Expand Down
130 changes: 0 additions & 130 deletions src/core/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,6 @@ pub async fn dispatch(
method: &str,
params: serde_json::Value,
) -> Result<serde_json::Value, String> {
let method = if let Some(canonical) = normalize_legacy_method(method) {
log::debug!(
"[rpc] legacy method '{}' rewritten to '{}'",
method,
canonical
);
canonical
} else {
method
};

log::trace!(
"[rpc:dispatch] enter method={} params={}",
method,
Expand Down Expand Up @@ -97,44 +86,6 @@ pub async fn dispatch(
Err(format!("unknown method: {method}"))
}

/// Normalizes legacy un-namespaced method names to their canonical equivalents.
///
/// This provides defense-in-depth against stale or unbalanced callers that may
/// still be using old method names.
///
/// Source of truth: `app/src/services/rpcMethods.ts` (`LEGACY_METHOD_ALIASES`)
fn normalize_legacy_method(method: &str) -> Option<&'static str> {
match method {
"openhuman.get_analytics_settings" => Some("openhuman.config_get_analytics_settings"),
"openhuman.get_composio_trigger_settings" => {
Some("openhuman.config_get_composio_trigger_settings")
}
"openhuman.get_config" => Some("openhuman.config_get"),
"openhuman.get_runtime_flags" => Some("openhuman.config_get_runtime_flags"),
"openhuman.ping" => Some("core.ping"),
"openhuman.set_browser_allow_all" => Some("openhuman.config_set_browser_allow_all"),
"openhuman.update_analytics_settings" => Some("openhuman.config_update_analytics_settings"),
"openhuman.update_browser_settings" => Some("openhuman.config_update_browser_settings"),
"openhuman.update_composio_trigger_settings" => {
Some("openhuman.config_update_composio_trigger_settings")
}
"openhuman.update_local_ai_settings" => Some("openhuman.config_update_local_ai_settings"),
"openhuman.update_memory_settings" => Some("openhuman.config_update_memory_settings"),
"openhuman.update_model_settings" => Some("openhuman.config_update_model_settings"),
"openhuman.update_runtime_settings" => Some("openhuman.config_update_runtime_settings"),
"openhuman.update_screen_intelligence_settings" => {
Some("openhuman.config_update_screen_intelligence_settings")
}
"openhuman.workspace_onboarding_flag_exists" => {
Some("openhuman.config_workspace_onboarding_flag_exists")
}
"openhuman.workspace_onboarding_flag_set" => {
Some("openhuman.config_workspace_onboarding_flag_set")
}
_ => None,
}
}

/// Handles internal core-level RPC methods.
///
/// These methods provide basic information about the server and its version.
Expand Down Expand Up @@ -298,87 +249,6 @@ mod tests {
assert!(result.logs.is_empty());
}

#[test]
fn test_normalize_legacy_method_all_aliases() {
let cases = vec![
(
"openhuman.get_analytics_settings",
"openhuman.config_get_analytics_settings",
),
(
"openhuman.get_composio_trigger_settings",
"openhuman.config_get_composio_trigger_settings",
),
("openhuman.get_config", "openhuman.config_get"),
(
"openhuman.get_runtime_flags",
"openhuman.config_get_runtime_flags",
),
("openhuman.ping", "core.ping"),
(
"openhuman.set_browser_allow_all",
"openhuman.config_set_browser_allow_all",
),
(
"openhuman.update_analytics_settings",
"openhuman.config_update_analytics_settings",
),
(
"openhuman.update_browser_settings",
"openhuman.config_update_browser_settings",
),
(
"openhuman.update_composio_trigger_settings",
"openhuman.config_update_composio_trigger_settings",
),
(
"openhuman.update_local_ai_settings",
"openhuman.config_update_local_ai_settings",
),
(
"openhuman.update_memory_settings",
"openhuman.config_update_memory_settings",
),
(
"openhuman.update_model_settings",
"openhuman.config_update_model_settings",
),
(
"openhuman.update_runtime_settings",
"openhuman.config_update_runtime_settings",
),
(
"openhuman.update_screen_intelligence_settings",
"openhuman.config_update_screen_intelligence_settings",
),
(
"openhuman.workspace_onboarding_flag_exists",
"openhuman.config_workspace_onboarding_flag_exists",
),
(
"openhuman.workspace_onboarding_flag_set",
"openhuman.config_workspace_onboarding_flag_set",
),
];

for (legacy, canonical) in cases {
assert_eq!(
normalize_legacy_method(legacy),
Some(canonical),
"Legacy method {} should normalize to {}",
legacy,
canonical
);
}
}

#[test]
fn test_normalize_legacy_method_none_for_unknown_or_canonical() {
assert!(normalize_legacy_method("core.ping").is_none());
assert!(normalize_legacy_method("openhuman.config_get").is_none());
assert!(normalize_legacy_method("unknown.method").is_none());
}

#[tokio::test]
async fn dispatch_legacy_ping_rewrites_and_succeeds() {
let out = dispatch(test_state(), "openhuman.ping", json!({}))
Expand Down
Loading
Loading