Skip to content
Open
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
53 changes: 53 additions & 0 deletions surfaces/gui/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions surfaces/gui/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = ["tray-icon"] }
tauri-plugin-dialog = "2"
tauri-plugin-opener = "2"
tauri-plugin-autostart = "2"
tauri-plugin-single-instance = "2"
tauri-plugin-updater = "2"
Expand Down
3 changes: 2 additions & 1 deletion surfaces/gui/src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"core:window:allow-set-focus",
"core:window:allow-unminimize",
"dialog:default",
"autostart:default"
"autostart:default",
"opener:default"
]
}
9 changes: 9 additions & 0 deletions surfaces/gui/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,13 @@ fn start_keep_awake() -> Option<KeepAwakeGuard> {

// -- native commands (invoked from the SPA via window.__TAURI__.core.invoke) -----------------

/// Opens a URL in the user's default system browser.
#[tauri::command]
fn open_url(app: tauri::AppHandle, url: String) -> Result<(), String> {
use tauri_plugin_opener::OpenerExt;
app.opener().open_url(&url, None::<&str>).map_err(|e| e.to_string())
}

/// Native macOS folder picker for the workspace gate.
#[tauri::command]
async fn pick_folder(app: tauri::AppHandle) -> Option<String> {
Expand Down Expand Up @@ -717,12 +724,14 @@ pub fn run() {
show_main(app);
}))
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_opener::init())
.plugin(tauri_plugin_updater::Builder::new().build())
.plugin(tauri_plugin_autostart::init(
tauri_plugin_autostart::MacosLauncher::LaunchAgent,
None,
))
.invoke_handler(tauri::generate_handler![
open_url,
pick_folder,
get_autostart,
set_autostart,
Expand Down
14 changes: 13 additions & 1 deletion surfaces/gui/src/components/Markdown.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ReactMarkdown, { defaultUrlTransform } from "react-markdown";
import { useTranslation } from "react-i18next";
import remarkGfm from "remark-gfm";
import { openExternal } from "../tauri";
import { Icon } from "./Icon";

// §34 (UX-016): the agent ends a deliverable turn with plain markdown —
Expand Down Expand Up @@ -77,7 +78,18 @@ export function Markdown({ text }: { text: string }) {
return <BoardChip label={label} />;
}
return (
<a href={href} {...props} target="_blank" rel="noreferrer">
<a
href={href}
{...props}
target="_blank"
rel="noreferrer"
onClick={(e) => {
if (href) {
e.preventDefault();
openExternal(href);
}
}}
>
{children}
</a>
);
Expand Down
18 changes: 14 additions & 4 deletions surfaces/gui/src/tauri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,23 @@ export const clearPendingUpdate = () => invokeStrict<void>("clear_pending_update
* Windows hands off to the installer). */
export const installUpdate = () => invokeStrict<void>("install_update");

/** Best-effort open a URL in the user's browser. Uses the Tauri opener plugin if present, else
* `window.open`. The caller should also render the raw URL so it stays copyable if both no-op
* (the desktop webview has no opener plugin wired yet). */
/** Best-effort open a URL in the user's browser. Uses the Tauri opener plugin if present,
* native open_url command, or `window.open`. The caller should also render the raw URL so it stays copyable
* if both no-op. */
export function openExternal(url: string): void {
const opener = (globalThis as any).__TAURI__?.opener;
if (opener?.openUrl) {
opener.openUrl(url).catch(() => window.open(url, "_blank", "noopener,noreferrer"));
opener.openUrl(url).catch(() => {
invoke<void>("open_url", { url }).catch(() => {
window.open(url, "_blank", "noopener,noreferrer");
});
});
return;
}
if (isTauri()) {
invoke<void>("open_url", { url }).catch(() => {
window.open(url, "_blank", "noopener,noreferrer");
});
return;
}
window.open(url, "_blank", "noopener,noreferrer");
Expand Down