goal: warn before sending an objective over 4,000 characters

未關閉
#308 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
50/100
Issue 類型
功能
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
android, kotlin
領域
api, mobile

研究方向

Start in server/src/main/kotlin/ai/opencode/server/live/LiveCatalog.kt (lines 61-109), where commands like goal are loaded, and in SessionFeatureState.kt to find where the composer draft is sent. The 4,000-character limit is defined in packages/core/src/plugin/goal.ts on the server side. Read LiveTransport.kt (lines 144-153 and 313-318) to see why non-2xx bodies are dropped. Done means a 4,001-character objective shows a warning before the request, a 4,000-character one sends, the draft is kept, and a server rejection shows its own message.

由索引模型根據 Issue 內容生成。

描述

Summary

Android does not validate the /goal objective length before sending. An objective over the server's 4,000-character limit is submitted to /api/session/{id}/command; the server rejects it with CommandExecutionError (HTTP 500), but Android discards the response body and shows only “The server returned HTTP 500.” The user gets no warning that the input exceeded the limit.

Environment

  • Android app: reporter's build not provided; behavior confirmed in v0.8.8 (c2311a60337e2a2128baba7c6eccb61b22bdb3f7) and dev (cab26e54c453fbaf8683ec456e628539d64b325f) source.
  • OpenCode server: version not provided; requires a server that advertises goal in /api/command.
  • Device/OS: not provided.
  • Terminal/shell: not applicable; reproduced through the Android composer.
  • Active plugins: none required; uses the server's built-in /goal command.

Reproduction

  1. Pair the Android app with an OpenCode server whose /api/command response includes goal.
  2. Start a session draft, type /, and select the goal command chip.
  3. Paste an objective longer than 4,000 characters into the draft.
  4. Tap Send without shortening it.

Expected Behavior

Before the network request, the composer warns that the objective exceeds 4,000 characters, keeps the draft intact, and lets the user edit it. If the server still rejects the command, Android shows the server's specific validation message instead of a generic HTTP status.

Actual Behavior

No pre-send warning appears. The command request is sent, the server returns HTTP 500, and the composer reports “The server returned HTTP 500.” The response explaining the 4,000-character limit is not shown.

Additional Context

  • The server limit is defined in packages/core/src/plugin/goal.ts and enforced when the command runs.
  • Android loads commands dynamically in server/src/main/kotlin/ai/opencode/server/live/LiveCatalog.kt:61-109; there is no /goal-specific validation or state UI.
  • The context gauge cannot provide this warning: SessionFeatureState.kt:451-463 calculates it from the last assistant token usage, not the current composer draft.
  • Non-2xx response bodies are discarded by server/src/main/kotlin/ai/opencode/server/live/LiveTransport.kt:144-153,313-318, so command validation details are lost.
  • Suggested acceptance checks: 4,000 and 4,001 characters, draft preservation, accessible warning text, and a command failure that preserves the server's error message.
  • Static source reproduction only; no device screenshot or log was provided.
主要語言
Kotlin
星號
146
分支
35
平均合併
7 小時 41 分鐘
30 天內合併 PR
221

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

anomalyco/opencode-android 的其他 Issue

查看 anomalyco/opencode-android 的全部 Issue

相似的 Issue

更多 Kotlin Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。