Skip to content

Commit c388346

Browse files
feat(Mountain): Add cocoon:notify handler and webview notification channels
Add a new `cocoon:notify` IPC handler as a fire-and-forget companion to the existing `cocoon:request` bridge. This handles one-way wire methods (webview.message, webview.dispose, webview.viewState, etc.) where the extension host doesn't reply, avoiding the 30s request timeout penalty when the renderer just wants to push data into Cocoon. Also extend the webview notification relay in MountainVinegRPCService to handle `webview.updateView` and `webview.reveal` in addition to the existing setTitle, setIconPath, and setHtml. These new channels route through the WebviewLifecycle notification handler for proper translation to Sky's kebab-case channel registry. This completes the one-way communication path complementing the request/response RPC bridge added in the prior commit.
1 parent 728ab19 commit c388346

2 files changed

Lines changed: 63 additions & 15 deletions

File tree

Source/IPC/WindServiceHandlers/mod.rs

Lines changed: 58 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,20 +1507,64 @@ pub async fn mountain_ipc_invoke(app_handle:AppHandle, command:String, args:Vec<
15071507
// observers).
15081508
"cocoon:request" => {
15091509
dev_log!("ipc", "cocoon:request method={:?}", args.first());
1510-
let Method = args
1511-
.first()
1512-
.and_then(|V| V.as_str())
1513-
.ok_or_else(|| "cocoon:request requires method string in slot 0".to_string())?
1514-
.to_string();
1515-
let Payload = args.get(1).cloned().unwrap_or(Value::Null);
1516-
crate::Vine::Client::SendRequest(
1517-
"cocoon-main",
1518-
Method.clone(),
1519-
Payload,
1520-
30_000,
1521-
)
1522-
.await
1523-
.map_err(|Error| format!("cocoon:request {} failed: {:?}", Method, Error))
1510+
let MethodOpt =
1511+
args.first().and_then(|V| V.as_str()).map(|S| S.to_string());
1512+
match MethodOpt {
1513+
None => {
1514+
Err("cocoon:request requires method string in slot 0".to_string())
1515+
},
1516+
Some(Method) => {
1517+
let Payload = args.get(1).cloned().unwrap_or(Value::Null);
1518+
crate::Vine::Client::SendRequest(
1519+
"cocoon-main",
1520+
Method.clone(),
1521+
Payload,
1522+
30_000,
1523+
)
1524+
.await
1525+
.map_err(|Error| {
1526+
format!("cocoon:request {} failed: {:?}", Method, Error)
1527+
})
1528+
},
1529+
}
1530+
},
1531+
1532+
// `cocoon:notify` - fire-and-forget renderer→Cocoon
1533+
// notification bridge. Companion to `cocoon:request` for
1534+
// one-way wire methods (`webview.message`,
1535+
// `webview.dispose`, `webview.viewState` etc.) where the
1536+
// extension doesn't reply. Avoids the 30s request
1537+
// timeout penalty when the renderer just wants to push
1538+
// data into the extension host. Wire shape:
1539+
// `params = [Method, Payload]`. Returns null
1540+
// immediately; the notification dispatches asynchronously.
1541+
"cocoon:notify" => {
1542+
dev_log!("ipc", "cocoon:notify method={:?}", args.first());
1543+
let MethodOpt =
1544+
args.first().and_then(|V| V.as_str()).map(|S| S.to_string());
1545+
match MethodOpt {
1546+
None => {
1547+
Err("cocoon:notify requires method string in slot 0".to_string())
1548+
},
1549+
Some(Method) => {
1550+
let Payload = args.get(1).cloned().unwrap_or(Value::Null);
1551+
if let Err(Error) = crate::Vine::Client::SendNotification(
1552+
"cocoon-main".to_string(),
1553+
Method.clone(),
1554+
Payload,
1555+
)
1556+
.await
1557+
{
1558+
dev_log!(
1559+
"ipc",
1560+
"warn: [cocoon:notify] {} failed: {:?}",
1561+
Method,
1562+
Error
1563+
);
1564+
}
1565+
Ok(Value::Null)
1566+
},
1567+
}
15241568
},
15251569

15261570
// BATCH-19 Part B: VS Code's `LocalPtyService` talks to Mountain via

Source/Vine/Server/MountainVinegRPCService.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,11 @@ impl MountainService for MountainVinegRPCService {
530530
// under `Vine::Server::Notification::*`. "Group atoms"
531531
// (TerminalLifecycle, DebugLifecycle, WebviewLifecycle, etc.)
532532
// handle 3-4 wire methods that share the same relay pattern.
533-
"webview.setTitle" | "webview.setIconPath" | "webview.setHtml" => {
533+
"webview.setTitle"
534+
| "webview.setIconPath"
535+
| "webview.setHtml"
536+
| "webview.updateView"
537+
| "webview.reveal" => {
534538
super::Notification::WebviewLifecycle::WebviewLifecycle(self, &MethodName, &Parameter).await;
535539
},
536540
"window.createTerminal" => {

0 commit comments

Comments
 (0)