Skip to content

feat(draft): run an action on the draft before it is committed - #39

Open
neozheng-dev wants to merge 5 commits into
zoolapp:mainfrom
neozheng-dev:feat/draft-auto-action
Open

neozheng-dev wants to merge 5 commits into
zoolapp:mainfrom
neozheng-dev:feat/draft-auto-action

Conversation

@neozheng-dev

@neozheng-dev neozheng-dev commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #37: this branch contains its commit, because the setting reuses the action keys introduced there. Please review #37 first; the commits after it are this PR.

Problem and resulting behavior / 问题与改后行为

With 输入图层 on, people who translate or polish nearly everything they write still have to trigger the action by hand each time, with ⌃⌥P and a digit, or with a shortcut from #37.

开着输入图层、几乎每段话都要翻译或润色的人,每次仍要手动触发动作。

This PR adds 上屏前执行动作 under 设置 › AI 助手 › 输入图层. It is off by default (无) and shown only when AI actions are on. With translate, polish or a custom action chosen:

  • The action runs on the pending draft when its key is pressed, or when the auto-commit delay passes. The results are listed as usual: Return applies one, Esc commits the draft as typed.
  • 执行动作的键 is Return or Space. With Return, Esc commits as typed, and 原文上屏的键 can add Space for that. With Space, Return and Esc commit as typed, as they do today.
  • Space is taken over only after text that does not end in a Latin letter or digit, so "hello world" can still be typed in a draft.
  • If the request fails or cannot start (no consent for the endpoint, text too long), the reason is shown and the draft is committed as typed. The delay cannot start the same request again, so there is no retry loop.
  • The draft hint shows the keys in effect, for example ↩ 翻译 Esc 上屏.

Privacy / 隐私. This is the first path where text reaches the model without a key press for that action: with a delay configured, stopping typing is enough. It is opt-in, the settings text says so, and docs/privacy.md is updated in this PR. Consent for a remote endpoint (aiRemoteAllowed) still applies. If you would rather not have the delay trigger it at all, I can limit this to the key only.

Verification / 验证

  • Commands and results / 命令与结果:
    • swift test --package-path Packages/AIMEKit: all suites pass, including the new DraftAutoActionTests (off unless chosen and both features on, deleted custom action, Return/Space trigger, Space after Latin text, Space as commit key, decoding older and unknown values).
    • xcodebuild -project AIME.xcodeproj -scheme AIME -configuration Debug build (ad-hoc signing): BUILD SUCCEEDED.
    • swiftlint lint: the set of errors is the same as on main.
  • Manual checks or screenshots / 手动验证或截图: used daily-style in Claude desktop on macOS 27.2.1 with an OpenAI-compatible endpoint: Return triggers translation, the delay triggers it, Esc commits as typed. Settings screenshots are below. Space as trigger was not rechecked by hand after the last commit.
  • Remaining limitations / 剩余限制: C (copy) in a result list started this way also commits the draft as typed, so the delay cannot fire again on the same draft.

Screenshots / 截图

Dark / 暗色: 执行动作的键 set to Space, so 原文上屏的键 reads 回车或 Esc.

输入图层 section with the new rows, dark

Light / 亮色

输入图层 section with the new rows, light

Narrowest window (900 pt), light / 最窄窗口(900pt),亮色. This build also contains #40, which adds the 写作记录 section shown below 输入图层.

输入图层 section at the minimum window width

Checklist / 检查清单

  • The change is focused; commits use Conventional Commits.
  • Relevant builds/tests passed with evidence above, or unavailable checks are explained.
  • English/Chinese documents stay aligned; the change is under Unreleased in both changelogs. docs/privacy.md exists in Chinese only.
  • No copied, translated, or adapted GPL source (including Squirrel) is included.
  • No keys, private input, user-frequency databases, or generated/vendor artifacts are committed.
  • AI consent: the existing checks in startAction are unchanged and still gate every request.
  • Input-path p99: the bench drives RimeKit only. On the key path this adds two feature lookups while a draft is pending. UI light/dark and narrow-window screenshots below.

🤖 Generated with Claude Code

zhugan and others added 5 commits November 27, 2026 14:48
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@foru17

foru17 commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

感谢 @neozheng-dev,这个方向很实用。我们的意见:

按键触发可以接受,停顿自动触发我们不打算要。 AIME 的隐私约定是:只有用户主动执行动作时,那段文字才交给模型。按回车或空格执行还算主动操作;停止打字一段时间就自动发出去,越过了这条线,即使默认关闭、需要用户开启也一样。你在 PR 里也提过可以去掉,麻烦按这个方向改:

改好后我们再看。

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