Skip to content

feat(gemini): add status / history / detail / read commands#1838

Merged
jackwener merged 3 commits into
jackwener:mainfrom
LeoLin990405:feat/gemini-read-commands
Jun 4, 2026
Merged

feat(gemini): add status / history / detail / read commands#1838
jackwener merged 3 commits into
jackwener:mainfrom
LeoLin990405:feat/gemini-read-commands

Conversation

@LeoLin990405
Copy link
Copy Markdown
Contributor

ChatGPT and Claude already expose status / history / detail / read; Gemini was missing all four. The helpers needed to back them (getGeminiPageState, getGeminiConversationList, resolveGeminiConversationForQuery, getGeminiVisibleTurns) are already implemented in clis/gemini/utils.js — this PR is just the cli() wire-up plus an extractGeminiId parser shared between history and detail.

Commands added

Command Source helper Notes
gemini status getGeminiPageState Treats isSignedIn=null (composer present but no explicit Sign-in CTA) as logged in.
gemini history [--limit N] getGeminiConversationList Filters out the sidebar's "New chat" affordance (URL = /app, no id) so callers get a clean conversation list. --limit clamped to [1, 200].
gemini detail <id> getGeminiConversationList + resolveGeminiConversationForQuery + getGeminiVisibleTurns Accepts a bare 16-hex id, /app/<id> path, full URL, or a sidebar title (exact or substring).
gemini read getGeminiVisibleTurns Current-conversation turns.

detail only short-circuits the sidebar lookup when the input is unambiguously id-shaped (URL / /app/<id> / 16-hex bare id). Generic alphanumeric strings like "Empire study" go through title-matching first so a chat doesn't get treated as a literal conversation id.

Verification

  • clis/gemini/commands.test.js18 cases:
    • extractGeminiId (bare id / path / URL / garbage)
    • status (connected / signed-out CTA / ambiguous-null treated as logged in)
    • history (rows / --limit / --limit validation / empty sidebar)
    • detail (direct-id nav / title resolution / missing id / no-match / zero turns)
    • read (happy / zero turns)
  • npm run test:adapter380 files / 3732 tests pass
  • npm run build-manifest — clean, +4 entries (gemini/status, gemini/history, gemini/detail, gemini/read)

Live smoke test against a real signed-in Gemini account:

$ opencli gemini status
- Status: Connected   Login: Yes   Url: https://gemini.google.com/app

$ opencli gemini history --limit 5
- Index: 1   Id: b8368a89d4242e5f   Title: Gemini's New Features from I/O
              Url: https://gemini.google.com/app/b8368a89d4242e5f

$ opencli gemini detail b8368a89d4242e5f
- Index: 1   Role: User       Text: What's the latest with Gemini from Google I/O?
- Index: 2   Role: Assistant  Text: …

$ opencli gemini read
# same turns as detail, no navigation

LeoLin990405 and others added 3 commits June 3, 2026 14:48
ChatGPT and Claude already expose `status` / `history` / `detail` / `read`;
Gemini was missing all four. The helpers needed to back them
(`getGeminiPageState`, `getGeminiConversationList`,
`resolveGeminiConversationForQuery`, `getGeminiVisibleTurns`) are already
implemented in `clis/gemini/utils.js` — this PR is the cli() wire-up.

## Commands

- `gemini status` — uses `getGeminiPageState`; treats `isSignedIn=null`
  (composer present but no explicit Sign-in CTA) as logged in.
- `gemini history [--limit N]` — uses `getGeminiConversationList`; filters
  out the sidebar's "New chat" affordance (URL = `/app`, no id) so callers
  get a clean conversation list. `--limit` clamped to `[1, 200]`.
- `gemini detail <id>` — accepts a bare 16-hex id, a `/app/<id>` path, a
  full `https://gemini.google.com/app/<id>` URL, or a sidebar title (exact
  or substring). Title lookup wins for generic alphanumeric strings so a
  chat called "Empire study" doesn't get treated as the literal id
  "Empire study".
- `gemini read` — current-conversation `getGeminiVisibleTurns`.

## Tests

- `clis/gemini/commands.test.js`, 18 cases:
  - 4× `extractGeminiId` (bare id / path / URL / garbage)
  - 3× `status` (connected / signed-out CTA / ambiguous-null treated as
    logged in)
  - 4× `history` (rows / `--limit` / `--limit` validation / empty sidebar)
  - 4× `detail` (direct id nav / title resolution / missing id /
    no-match / zero turns)
  - 2× `read` (happy / zero turns)
- `npx vitest run clis/gemini/commands.test.js` — 18/18 pass.
- `npm run test:adapter` — 380 files / 3732 tests pass.

Live smoke-tested against a real signed-in Gemini account: all four
commands return real data end-to-end via the Browser Bridge.
@jackwener jackwener merged commit c08d0e2 into jackwener:main Jun 4, 2026
11 checks passed
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.

2 participants