Skip to content

feat: Add non-interactive mode - #18

Merged
adamdotdevin merged 7 commits into
anomalyco:devfrom
mark3labs:non-interactive-mode
May 16, 2025
Merged

feat: Add non-interactive mode#18
adamdotdevin merged 7 commits into
anomalyco:devfrom
mark3labs:non-interactive-mode

Conversation

@ezynda3

@ezynda3 ezynda3 commented May 15, 2025

Copy link
Copy Markdown
Contributor

Summary

  • Adds non-interactive mode to OpenCode with the -p flag
  • Supports text and JSON output formats with the -f flag
  • Includes a loading spinner (can be disabled with -q flag)

Original implementation by @radutopala, adapted and enhanced for the current codebase.

Test plan

  • Run opencode -p "Hello, world" to test basic functionality
  • Run opencode -p "Hello, world" -f json to test JSON output
  • Run opencode -p "Hello, world" -q to test without spinner

🤖 Generated with opencode

@radutopala

Copy link
Copy Markdown

Hey @ezynda3 do you plan to bring this in the upstream opencode repo?

@ezynda3

ezynda3 commented May 16, 2025

Copy link
Copy Markdown
Contributor Author

@radutopala I was not planning to. Your PR is basically finished there, isn't it? The only thing I added was a spinner, which you're welcome to copy from here.

ezynda3 and others added 2 commits May 16, 2025 10:42
- Moved spinner from format package to tui/components/spinner
- Updated imports and references in root.go
- Added basic test for spinner component

🤖 Generated with opencode
Co-Authored-By: opencode <noreply@opencode.ai>
@ezynda3

ezynda3 commented May 16, 2025

Copy link
Copy Markdown
Contributor Author

@adamdottv ready to review

@adamdotdevin
adamdotdevin merged commit 623d132 into anomalyco:dev May 16, 2025
@adamdotdevin

Copy link
Copy Markdown
Member

thanks so much @ezynda3, so good

sauerdaniel added a commit to sauerdaniel/opencode that referenced this pull request Jan 17, 2026
Fixes memory leaks where LSP client maps grow indefinitely:
- Clear diagnostics Map on shutdown (Issue anomalyco#17)
- Clear files version tracking object on shutdown (Issue anomalyco#18)
nobane added a commit to nobane/opencode that referenced this pull request Jan 30, 2026
- Fix input token accumulation bug: use last step's input tokens instead
  of accumulating (each step's input includes full context, not incremental)
- Replace "opencode" with "Claude Code" in system prompts for Anthropic
  OAuth compatibility (PR anomalyco#18)

v69.0.19: System prompt branding fix
v69.0.20: Token over-counting fix

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
tamarazuk added a commit to tamarazuk/opencode that referenced this pull request Mar 3, 2026
- Log stderr from gh pr view instead of silently returning undefined (anomalyco#10)
- Cap pr-comments pagination at 10 pages to prevent runaway requests (anomalyco#18)
- Use resolveApiErrorMessage in delete-branch dialog for consistent error UX (anomalyco#19)
- Default remoteBranchExists to false while loading to avoid UI flash (anomalyco#20)
tamarazuk added a commit to tamarazuk/opencode that referenced this pull request Mar 21, 2026
- Log stderr from gh pr view instead of silently returning undefined (anomalyco#10)
- Cap pr-comments pagination at 10 pages to prevent runaway requests (anomalyco#18)
- Use resolveApiErrorMessage in delete-branch dialog for consistent error UX (anomalyco#19)
- Default remoteBranchExists to false while loading to avoid UI flash (anomalyco#20)
Rwanbt referenced this pull request in Rwanbt/unifia Apr 19, 2026
The audit flagged vcs/meta/icon caches per worktree as "no LRU
eviction", but the existing pickDirectoriesToEvict already LRU-prunes
both the store AND its three caches (disposeDirectory deletes them
together). What was actually loose was the idle window: 20 min is
long for a user bouncing between tabs on a laptop, so tabs closed
earlier in the session sit in RAM longer than they need to.

Drop DIR_IDLE_TTL_MS to 10 min. MAX_DIR_STORES stays at 30 — pinned
directories (active views) are never evicted, so the cap only
affects background worktrees, which should turn over faster.

Closes #18/21.
xywsxp pushed a commit to xywsxp/opencode that referenced this pull request Apr 24, 2026
Rwanbt referenced this pull request in Rwanbt/unifia May 5, 2026
The audit flagged vcs/meta/icon caches per worktree as "no LRU
eviction", but the existing pickDirectoriesToEvict already LRU-prunes
both the store AND its three caches (disposeDirectory deletes them
together). What was actually loose was the idle window: 20 min is
long for a user bouncing between tabs on a laptop, so tabs closed
earlier in the session sit in RAM longer than they need to.

Drop DIR_IDLE_TTL_MS to 10 min. MAX_DIR_STORES stays at 30 — pinned
directories (active views) are never evicted, so the cap only
affects background worktrees, which should turn over faster.

Closes #18/21.
avion23 pushed a commit to avion23/opencode that referenced this pull request Jun 10, 2026
Rwanbt referenced this pull request in Rwanbt/unifia Jun 14, 2026
The audit flagged vcs/meta/icon caches per worktree as "no LRU
eviction", but the existing pickDirectoriesToEvict already LRU-prunes
both the store AND its three caches (disposeDirectory deletes them
together). What was actually loose was the idle window: 20 min is
long for a user bouncing between tabs on a laptop, so tabs closed
earlier in the session sit in RAM longer than they need to.

Drop DIR_IDLE_TTL_MS to 10 min. MAX_DIR_STORES stays at 30 — pinned
directories (active views) are never evicted, so the cap only
affects background worktrees, which should turn over faster.

Closes #18/21.
danzeroum referenced this pull request in danzeroum/opencode Jun 15, 2026
…bles

PR #17: wire the event store into the request path and lay the persistence
groundwork the session/event route cutovers (PR #18+) depend on.

- DI: `AppContext` now carries `Arc<dyn EventStore>`, assembled in a single
  composition-root `build_app_context()` (opencode-bin) over ONE shared
  `sqlx::SqlitePool`. PRAGMAs mirror the TS server (WAL, synchronous=NORMAL,
  busy_timeout, 64 MiB cache, foreign_keys) applied per-connection via
  SqliteConnectOptions. `AppContext::in_memory()` for tests/ephemeral runs.
- `opencode-db::Database` owns the shared pool and mints the event store +
  session repos from it; `SqlxEventStore::from_pool` shares the pool.
- Migration-journal verification ("TS migrates, Rust verifies"): boot health
  check reads the `migration` journal (+ read-only `__drizzle_migrations`
  bridge) and diffs against EXPECTED_MIGRATIONS (mirrors migration.gen.ts).
  Behind+journal-present is fatal with a clear message; ahead/no-journal warns.
- Session-store models + repositories: `session_input` (event-sourced steering
  inbox) and `session_context_epoch` (per-session baseline/agent), DDL mirroring
  the final TS schema. Tables stay TS-owned (not auto-created).
- effect now depends on db; db re-exports the event contract types and adds
  serde. opencode-server test uses `AppContext::in_memory()`.

Verified: cargo build/clippy -D warnings/fmt/test (db 15, bin 2, server 16) and
openapi-diff all green. Owner decision on migration strictness recorded.

https://claude.ai/code/session_017Lo2jkGdTgRvsPG6tcwEqz
danzeroum referenced this pull request in danzeroum/opencode Jun 15, 2026
PR #18: first session read-route cutover, proving Rust reads TS-written data
from the shared SQLite.

- GET /api/session/{sessionID} (v2.session.get, group `session`) served
  natively → SessionV2Info, reading the shared `session` projection table via a
  new SessionStore wired through AppContext (State<AppContext>). Gated by
  OPENCODE_RUST_ROUTES=session, off by default; proxies to TS when disabled.
- Finding: V2 read routes read projection tables (the projector folds events on
  the write path), not the event log per request — so the faithful Rust read is
  a SELECT. session.status stays un-cuttable (per-process in-memory runner state,
  TS-owned until Phase 4).
- opencode-db: SessionStore trait + SqlxSessionStore (reads the `session` table
  by id) + MemorySessionStore (test double / in_memory context). Tests read a
  TS-shaped session row and externally-written event rows.
- opencode-proto: SessionV2Info (+ ModelRef/SessionTokens/TokenCache/SessionTime/
  LocationRef), SessionGetResponse, SessionNotFoundError, UnauthorizedError.
- AppContext gains a SessionStore (new(event_store, sessions) + in_memory()).
- openapi-diff: enforces /api/session/{sessionID}; normalizer now collapses
  anyOf[X,X] (the 404), drops the {type:null} member utoipa emits for
  Option<$ref>, and unwraps single-element allOf.

Verified: build/clippy -D warnings/fmt/test (db 18, server 20, bin 2) and
openapi-diff all green. No new external crates.

https://claude.ai/code/session_017Lo2jkGdTgRvsPG6tcwEqz
zoulukuang added a commit to zoulukuang/deskfox that referenced this pull request Aug 14, 2026
按 user「先把执行脚本调稳再继续推清单」的决定做的一轮。两处加固都来自本轮真实踩坑。

## 加固一:多 page target 时不能盲取第一个

[bug-repro: 测多窗口后留下第二个窗口,CDP 列表出现两个 page target;工具取到的是**后台窗口**,
 渲染器被浏览器节流,Runtime.evaluate 迟迟不返回,表现为「CDP 连接超时」]

这个坑害我绕了十几轮:先怀疑是自己改坏了 find_element,再怀疑 DOM 太大导致全表扫描慢,
又怀疑正则回退有问题 —— **三个方向全猜错**。最后回退到已提交版本发现**它也超时**,
才想到去看 target 列表。真因与我猜的都无关。

修法:_ws_url() 优先选前台窗口,并在多 target 时打印告警提示可能超时。

## 加固二:未命中要区分「不存在」与「存在但不可见」

[bug-repro: 通知面板入口 aria-label「Notifications (alt+T)」明明在 DOM 里,
 却因 height=0(折叠态)被可见性过滤掉,报成「未找到入口」→ 差点当成功能缺失]

二者的处置完全不同:不存在 = 可能真缺陷;不可见 = 需要先让它所在区域可见(环境前提)。
修法:find_element 未命中时二次查找(忽略可见性),命中则说明**为何不可见**
(height=0 / display:none / visibility:hidden / 滚出视口 / 在视口左右之外)。

## 清单执行脚本改三态

新增 run_group2.py(CHECKLIST 第 2 组 anomalyco#15/anomalyco#17/anomalyco#18/anomalyco#20/anomalyco#21 自动化),
结果分 OK / SKIP(环境前提不满足,不是缺陷)/ FAIL(需处理)三态。

教训:把「元素存在但未展开」「页面停在引导态」笼统报 FAIL,会让人误以为功能坏了,
反复排查后才发现是环境状态。必须在结果里就分开 —— 否则清单跑得越多,噪音越大。

实跑结果:通过 3(主区域无溢出 / rail 项目图标 / 前进返回按钮),
跳过 2(文件树 tab 需先打开会话;通知面板为折叠态),**待处理 0**。

自检:uiprobe_selftest 14/14 仍全过。
zoulukuang added a commit to zoulukuang/deskfox that referenced this pull request Aug 14, 2026
人工验收单第二节列的 8 条「本可自动化但未覆盖」全部补成脚本,现状:
第 2 组 7/7、第 3 组 16 通过 2 跳过、第 4 组 11/11、第 5~7 组 11 通过 2 跳过,**待处理 0**。
剩下的跳过项都是真的做不了(分享需逐次授权;飞书绑定/群消息需真实外部账号)。

## 新覆盖的条目

- **anomalyco#16 面板开关矩阵**:树/审查/终端 **8 种组合全跑**,每种都验不遮挡不溢出。
  价值最高的一条 —— `flex-row-reverse` 当初复发正是因为只测了「文件树+聊天」一种组合。
- **anomalyco#22 终端**:开/新建/关,判据是终端实例数真的变。
- **anomalyco#26 聊天引用**:选中 → 右键 → 添加到聊天窗口 → **再点浮层里的「加入聊天」** →
  卡片入输入区 → 点卡片不开空白预览页。
- **anomalyco#27 md 内链拦截**:内链跳转在应用内完成,且**没有浏览器被拉起**。
- **anomalyco#59 主题**:真切一次 Fox Blue —— `data-theme` onedarkpro → fox-blue,
  `--surface-base-active` `#e2e4e7` → **`#7295c452`**(正是清单要求的值),验完切回。
- **anomalyco#62 MCP**:真执行 ⌘; 开关一次并复位。
- **anomalyco#63**:如实报「只有一个本地服务器,无从切换」;workspace 切换由 anomalyco#19/anomalyco#18 覆盖。
- **anomalyco#55 飞书页**:开关翻转 + **落盘复核** + 复位。

## 被实测推翻的「想当然」(这一批)

- **审查不是独立面板,是中栏的一个 tab**(`[data-component="session-review"]` 从不出现)。
  按名字猜选择器,anomalyco#16 里这一档永远开不起来,矩阵只能跑 4/8。
- **终端判据不能带 `canvas`**:PDF/xlsx 预览也是 canvas,导致「没开终端」也被判成开着。
- **标签条会横向溢出**:被挤出可见区的 tab **仍能报出几何坐标**,照着点会落到别处 ——
  实撞点在会话标题上、**误触发了内联重命名**。坐标取得到 ≠ 那个位置真属于它。
  故 `open_readme` 一律走文件树节点。
- **「添加到聊天窗口」只是第一步**,它先弹提问浮层,要再点「加入聊天」才真入聊天。
  停在第一步找不到卡片,曾被记成「引用功能没生效」。
- **`data-theme` 是主题 id,命令面板显示的是主题名**(`onedarkpro` vs「One Dark Pro」)。
  拿 id 去搜命令必然搜不到 —— 复位连续失败,**界面被留在 Fox Blue 两次**。
  改为从主题定义文件读 id→名 映射,并轮询等主题真的生效。
- **搜索词与匹配词必须一致**:搜「使用主题:X」却取首个候选,点中的未必是 X。
- **持久化判据要具体到键+值**:第一版猜关键词 `caffeinate`,而真实键是
  `preventSleepConfig`(store-keys.ts),「落盘可见」恒为 False —— 等于这条根本没验到,
  只是没报错而已。
- **anomalyco#27 别拿「前台应用是谁」当判据**:探针自己的 osascript 就会打乱前台(实撞拿到 'Finder')。
  改看有没有浏览器进程被拉起。
- **anomalyco#30 撤销要有东西可撤**:会话状态随前面条目漂移,多次 13→13→13 不是撤销坏了,
  是没有可撤销的东西。改为先用 shell 造一条再验。

所有改全局状态的条目(主题 / 语言 / 权限自动接受 / 防休眠 / MCP)跑完都复位并复核。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wut6R6htBzR8fBN8gbJkWg
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.

3 participants