Skip to content

feat: --page launch argument to open the app on a given page (e.g. --page quota) - #209

Open
ahmed-khaire wants to merge 1 commit into
router-for-me:mainfrom
ahmed-khaire:feat/launch-page
Open

feat: --page launch argument to open the app on a given page (e.g. --page quota)#209
ahmed-khaire wants to merge 1 commit into
router-for-me:mainfrom
ahmed-khaire:feat/launch-page

Conversation

@ahmed-khaire

@ahmed-khaire ahmed-khaire commented Sep 5, 2026

Copy link
Copy Markdown

What

Adds a --page <id> launch argument so EasyCLIProxyAPI can be opened directly on a page instead of Home, e.g. EasyCLIProxyAPI --page quota for OAuth → Quota Lookup. When an instance is already running, the running window is raised and switched to that page; no second window.

Motivation: tray helpers / launchers that want to jump straight to quota details. Today there is no deep link, and driving the page through the accessibility layer crashes the WebKit view on Linux.

How

Rust (src-tauri/src/launch_navigation.rs, main.rs)

  • --page <id> and --page=<id> are parsed before the instance guard.
  • Single instance: value is kept in managed LaunchPageState; the frontend reads it once via the take_launch_page command.
  • Second launch: if the instance lock is held, the request is written to <tmp>/EasyCLIProxyAPI-navigate-<instance key>.txt and the process exits. The running instance polls that file (500 ms), consumes it, reveals the main window (tray helper on macOS/Windows, show/unminimize/set_focus elsewhere) and emits navigate-page.
  • Values are sanitised to [A-Za-z0-9/-], max 64 chars; anything unknown is ignored by the frontend.

Frontend (src/launchNavigation.ts, App.tsx, ManagementPages.tsx)

  • parseLaunchTarget accepts sidebar page ids, oauth/<subpage>, and the bare OAuth subpage aliases quota / authFiles / login.
  • The target is held as pending and applied only once canOpenAppPage(page, coreRunning) is true, because pages other than Home/Usage/… unlock when the core is running and the existing reset-to-home effect would otherwise win.
  • OAuthManagementPage accepts a requestedSubpage and switches its tab.

Docs: README "Launch arguments" section.

Tests

  • tests/launchNavigation.test.ts (parser) and src-tauri/src/tests/launch_navigation.rs (argument parsing, sanitising, request file round-trip): all pass.
  • bun run check clean. bun test: 148 pass, 1 pre-existing failure (i18n > keeps both locale dictionaries structurally aligned) that also fails on main.
  • cargo test: 329 pass; agent_probe_command_stops_at_timeout fails on my Ubuntu 24.04 host on main as well (timing), unrelated.
  • Manual on Linux (debug build with embedded frontend): --page usage-records on first launch → Usage; --page home from a second launch → forwarded, one window, request file consumed; --page quota → held while the core was starting, then OAuth / Quota Lookup selected.

Not tested on macOS/Windows; the reveal path there reuses the existing tray::show_main_window.

Lets launchers, tray helpers and scripts open EasyCLIProxyAPI directly on a page
(for example `--page quota` for OAuth > Quota Lookup) instead of always landing
on Home.

- Rust: parse `--page <id>` / `--page=<id>`; keep it in managed state and expose
  `take_launch_page` for the first render. If another instance already holds the
  instance lock, write the request next to the lock and exit, and let the running
  instance pick it up (500 ms poll), reveal its window and emit `navigate-page`.
  Values are restricted to `[A-Za-z0-9/-]` and 64 chars; the frontend validates
  the actual target.
- Frontend: `parseLaunchTarget` accepts page ids plus `oauth/<subpage>` and the
  bare OAuth subpage aliases (`quota`, `authFiles`, `login`). The target is held
  until `canOpenAppPage` allows it, since non-Home pages unlock only once the core
  runs; the OAuth page accepts a requested subpage.
- README: document the argument.

Tested on Linux: `--page usage-records` on first launch, `--page home` forwarded
to a running instance (single window, request consumed), and `--page quota`
landing on Quota Lookup once the core was running.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant