Skip to content
Closed
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
5 changes: 5 additions & 0 deletions desktop/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ pub fn run() {
.build(tauri::generate_context!())
.expect("error while building OpenCodex desktop shell")
.run(|app, event| {
// Dock/Finder reopening an existing macOS app does not launch a second instance.
#[cfg(target_os = "macos")]
if let tauri::RunEvent::Reopen { .. } = event {
show_dashboard(app.clone());
}
// Window close and the platform quit gesture arrive here as an exit request, and until
// this handler existed they went straight through to a SIGKILL of the runtime. D2 makes
// them hide; only the tray's Quit, and an update's coordinated restart, get past.
Expand Down
2 changes: 2 additions & 0 deletions docs-site/src/content/docs/fr/guides/desktop-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ L’application demande à son CLI intégré d’exécuter `ocx resolve --json`

Utilisez l’action **Open dashboard** ou **Open in browser** de la zone de notification pour passer du tableau de bord intégré à votre navigateur habituel. Le menu permet aussi de rechercher les mises à jour.

Sur macOS, fermer le tableau de bord laisse l’application active dans la barre des menus. Ouvrez à nouveau OpenCodex depuis le Dock ou le Finder pour réafficher le tableau de bord sans redémarrer le proxy.

## Utilisation dans la zone de notification

Sur macOS et Windows, cliquez sur l’icône pour ouvrir un panneau compact d’utilisation. L’action **Show usage** l’ouvre également, notamment sous Linux lorsque la zone de notification ne transmet pas les clics. Sous Linux, le tableau de bord s’ouvre au démarrage, même si l’environnement de bureau n’affiche pas d’icône.
Expand Down
2 changes: 2 additions & 0 deletions docs-site/src/content/docs/guides/desktop-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ it from the tray or launch the app again.
Use the tray's **Open dashboard** or **Open in browser** action to move between the
embedded dashboard and your normal browser. The tray also provides update checks.

On macOS, closing the dashboard keeps the app running in the menu bar. Open OpenCodex again from Dock or Finder to restore the dashboard without restarting the proxy.

## Usage in the tray

On macOS and Windows, click the tray icon to open a compact usage window. The tray's
Expand Down
2 changes: 2 additions & 0 deletions docs-site/src/content/docs/ja/guides/desktop-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ sudo apt install ./OpenCodex-<version>-linux-amd64.deb

トレイの **Open dashboard** または **Open in browser** で、埋め込みダッシュボードと通常のブラウザを切り替えられます。トレイから更新の確認もできます。

macOS では、ダッシュボードを閉じてもアプリはメニューバーで動作し続けます。Dock または Finder から OpenCodex を再度開くと、プロキシを再起動せずにダッシュボードが再表示されます。

## トレイでの使用量表示

macOS と Windows ではトレイアイコンをクリックするとコンパクトな使用量ウィンドウが開きます。トレイの **Show usage** 操作でも開けます。これはトレイのクリックイベントを転送しない Linux デスクトップでも使えます。Linux では、デスクトップ環境にトレイアイコンが表示されなくても起動時にダッシュボードが開きます。
Expand Down
2 changes: 2 additions & 0 deletions docs-site/src/content/docs/ko/guides/desktop-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ sudo apt install ./OpenCodex-<version>-linux-amd64.deb

트레이의 **Open dashboard** 또는 **Open in browser**를 사용하면 내장 대시보드와 일반 브라우저를 오갈 수 있습니다. 트레이에서는 업데이트도 확인할 수 있습니다.

macOS에서는 대시보드를 닫아도 앱이 메뉴 막대에서 계속 실행됩니다. Dock 또는 Finder에서 OpenCodex를 다시 열면 프록시를 재시작하지 않고 대시보드가 다시 표시됩니다.

## 트레이에서 사용량 보기

macOS와 Windows에서는 트레이 아이콘을 클릭하면 작은 사용량 창이 열립니다. 트레이의 **Show usage**로도 열 수 있으며, 트레이 클릭 이벤트를 전달하지 않는 Linux 데스크톱에서도 사용할 수 있습니다. Linux에서는 트레이 아이콘이 표시되지 않는 환경을 포함해 시작할 때 대시보드가 열립니다.
Expand Down
2 changes: 2 additions & 0 deletions docs-site/src/content/docs/ru/guides/desktop-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ CLI подтвердил отсутствие прокси; неопределё
Используйте действия **Open dashboard** или **Open in browser** в системной панели, чтобы
переключаться между встроенным дашбордом и обычным браузером. Там же доступны проверки обновлений.

В macOS после закрытия дашборда приложение продолжает работать в строке меню. Откройте OpenCodex снова через Dock или Finder, чтобы вернуть дашборд без перезапуска прокси.

## Использование в системной панели

На macOS и Windows нажмите значок в системной панели, чтобы открыть компактное окно использования.
Expand Down
2 changes: 2 additions & 0 deletions docs-site/src/content/docs/tr/guides/desktop-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Uygulama, paketindeki CLI'dan `ocx resolve --json` çalıştırmasını ister ve

Gömülü kontrol paneli ile normal tarayıcınız arasında geçmek için tepsideki **Open dashboard** veya **Open in browser** eylemini kullanın. Tepsi, güncelleme denetimlerini de sunar.

macOS’te kontrol panelini kapattığınızda uygulama menü çubuğunda çalışmaya devam eder. Proxy’yi yeniden başlatmadan kontrol panelini geri getirmek için OpenCodex’i Dock veya Finder üzerinden yeniden açın.

## Tepside kullanım

macOS ve Windows'ta küçük kullanım penceresini açmak için tepsi simgesine tıklayın. Tepsideki **Show usage** eylemi de pencereyi açar; tıklama olaylarını iletmeyen Linux tepsilerinde de çalışır. Linux'ta masaüstü ortamı tepsi simgesi göstermese bile kontrol paneli başlangıçta açılır.
Expand Down
2 changes: 2 additions & 0 deletions docs-site/src/content/docs/zh-cn/guides/desktop-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ sudo apt install ./OpenCodex-<version>-linux-amd64.deb

使用托盘中的 **Open dashboard** 或 **Open in browser**,可在内嵌仪表盘与常用浏览器之间切换。托盘也提供更新检查。

在 macOS 上,关闭仪表盘后,应用会继续在菜单栏中运行。从 Dock 或 Finder 再次打开 OpenCodex 即可恢复仪表盘,无需重启代理。

## 在托盘中查看用量

在 macOS 和 Windows 上,点击托盘图标即可打开紧凑的用量窗口。托盘中的 **Show usage** 也能打开它,包括在不转发点击事件的 Linux 桌面上。在 Linux 上,仪表盘会在启动时打开,即使桌面环境没有显示托盘图标也是如此。
Expand Down
2 changes: 2 additions & 0 deletions docs-site/src/content/docs/zh-tw/guides/desktop-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ sudo apt install ./OpenCodex-<version>-linux-amd64.deb

透過系統匣的 **Open dashboard** 或 **Open in browser**,可以在內嵌儀表板與一般瀏覽器間切換。系統匣也提供更新檢查。

在 macOS 上,關閉儀表板後,應用程式會繼續在選單列中執行。從 Dock 或 Finder 再次開啟 OpenCodex 即可恢復儀表板,無須重新啟動代理。

## 系統匣中的用量資訊

在 macOS 與 Windows 上,點擊系統匣圖示可開啟精簡用量視窗。系統匣的 **Show usage** 也能開啟它,包括不會轉送點擊事件的 Linux 桌面環境。Linux 會在啟動時開啟儀表板,即使桌面環境不顯示系統匣圖示也一樣。
Expand Down
5 changes: 5 additions & 0 deletions structure/desktop-shell.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ is the quit. macOS needs one thing beyond the event loop: Tauri's default menu c
Quit wired to Cocoa's `terminate:` and the pinned tao raises no cancellable event for it, so
`desktop/src-tauri/src/menu.rs` rebuilds that menu with an ordinary item on the same accelerator.

On macOS, the event loop in `desktop/src-tauri/src/lib.rs` handles `RunEvent::Reopen` through the
existing dashboard entry point. Opening the running app from Dock or Finder restores its main
window and loads a deferred dashboard, including when a usage popup is visible. This is separate
from the single-instance callback, which handles a second process notifying the existing one.

Every ending drains first, and so does the tray's Stop, which is not an ending: all of them take the
same phase, so Stop pressed twice, Stop then Quit, and Stop during an update are one execution over
one child rather than several racing. Ownership is re-established at the start of each drain rather
Expand Down
12 changes: 12 additions & 0 deletions tests/clients/desktop-exit-ownership.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ function shellSources(directory: string = SRC): string[] {
}

describe("desktop exit ownership", () => {
test("macOS reopen reaches the existing dashboard entry point", () => {
// Wiring guard only; the native close/reopen gesture needs a macOS app session.
const lib = code(LIB);
const run = lib.slice(lib.indexOf(".run(|app, event|"));
expect(run).toMatch(
/#\[cfg\(target_os = "macos"\)\]\s*if let tauri::RunEvent::Reopen \{ \.\. \} = event \{\s*show_dashboard\(app\.clone\(\)\);\s*\}/,
);
const show = lib.slice(lib.indexOf("fn show_dashboard("), lib.indexOf("fn hide_dashboard("));
expect(show).toContain("popup::hide(&app)");
expect(show).toContain("startup::open_dashboard(&app)");
});

test("the event loop intercepts the exit request instead of letting it through", () => {
const lib = code(LIB);
expect(lib).toContain("RunEvent::ExitRequested");
Expand Down
Loading