Skip to content

fix(polish): 调整热词注入提示措辞#135

Merged
H-Chris233 merged 5 commits into
Open-Less:mainfrom
H-Chris233:main
May 1, 2026
Merged

fix(polish): 调整热词注入提示措辞#135
H-Chris233 merged 5 commits into
Open-Less:mainfrom
H-Chris233:main

Conversation

@H-Chris233
Copy link
Copy Markdown
Collaborator

摘要

Fixes #63

本 PR 按最小改动调整 polish 热词注入提示词措辞。

此前 compose_system_prompt 中热词列表的说明是“仅当原始转写明显是其误识别时才纠正”,语气偏保守,容易让模型把用户词汇本理解成“错了才改”,而不是“这些是用户希望优先保持准确的写法”。

本次改动将热词提示改为更主动的表达:用户希望这些写法在输出中保持准确;当转写中出现这些词的同音 / 近形误识别时,优先按上述写法输出。同时继续保留“不做无关词机械替换”的约束,避免扩大到无关文本替换。

修复 / 新增 / 改进

  • 调整 polish.rs::compose_system_prompt 中热词注入文案。

  • 将热词说明从偏被动的“仅当明显误识别时才纠正”调整为:

    • 用户希望以下写法在输出中保持准确
    • 遇到同音 / 近形误识别时,优先按上述写法输出
    • 不做无关词的机械替换
  • 保持现有 prompt 结构不变。

  • 不新增 prompt 段落。

  • 不扩大 polish 提示词架构。

  • 新增测试覆盖:

    • 验证 prompt 包含新的主动热词说明
    • 验证 prompt 包含同音 / 近形误识别优先写法说明
    • 验证热词条目仍按 bullet 注入

兼容

  • 不包含:

    • 不重写 polish system prompt。
    • 不新增热词处理模块。
    • 不改变热词存储结构。
    • 不改变 polish API。
    • 不改变 provider 请求逻辑。
    • 不做机械替换实现。
    • 不引入新依赖。
  • 对现有用户 / 本地环境 / 构建流程的影响:

    • 使用热词 / 词汇本时,模型会更倾向于主动保持用户指定写法。
    • 对未配置热词的 polish 流程无影响。
    • 仍避免把热词规则扩大成无关词的全局机械替换。
    • 构建流程无变化。

测试计划

  • 命令:cargo test --manifest-path openless-all/app/src-tauri/Cargo.toml polish::tests -- --nocapture

  • 结果:通过

  • 证据路径:本地测试输出

  • 命令:cargo check --manifest-path openless-all/app/src-tauri/Cargo.toml

  • 结果:通过

  • 证据路径:本地检查输出

主要改动文件

  • openless-all/app/src-tauri/src/polish.rs

备注

本 PR 只调整热词注入提示词的措辞强度,没有改变 surrounding prompt architecture。真实 LLM 输出质量仍需要后续用实际模型回归观察。

The hotword injection copy now tells the model to prefer the user's spelling proactively while still avoiding unrelated mechanical replacements. That keeps the intent of issue Open-Less#63 aligned with the existing prompt structure and only changes the wording that users see indirectly through polish behavior.

Constraint: Keep the change minimal and avoid changing the surrounding prompt architecture.
Rejected: Broaden the prompt or add new prompt sections | unnecessary for this issue.
Confidence: high
Scope-risk: narrow
Directive: Keep future hotword guidance user-facing and proactive, but still avoid blanket replacement language.
Tested: cargo test --manifest-path src-tauri/Cargo.toml polish::tests -- --nocapture; cargo check --manifest-path src-tauri/Cargo.toml
Not-tested: Live LLM output quality against the updated prompt wording.
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @H-Chris233, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@H-Chris233 H-Chris233 self-assigned this May 1, 2026
@H-Chris233
Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

The capsule window used a fixed oversized frame even when only the pill was visible, so transparent padding could block clicks on underlying apps. The runtime now resizes and repositions the capsule to the actual visible content, expanding only when the translation badge is shown.

Constraint: Keep the fix minimal and preserve the translation badge when it is actually visible.
Rejected: Add click-through behavior to transparent pixels | too risky and platform-specific for this narrow fix.
Confidence: high
Scope-risk: moderate
Directive: Keep capsule window geometry in sync with rendered content; do not reintroduce a larger transparent hitbox without a matching click-through strategy.
Tested: cargo test --manifest-path src-tauri/Cargo.toml --lib -- --nocapture; npm ci; npm run build; git diff --check
Not-tested: Live mouse hit-testing on Windows/macOS/Linux after the resize change.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f62762a17f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread openless-all/app/src-tauri/src/lib.rs
QA positioning had kept its own fixed capsule height constant after the capsule window was resized to match the visible pill. Reusing the shared capsule height source keeps the documented gap intact without widening the change surface.

Constraint: Keep the change minimal and avoid a separate geometry model for QA.
Rejected: Keep the old QA constant | would drift from the new capsule geometry again.
Confidence: high
Scope-risk: narrow
Directive: If capsule geometry changes again, update QA anchoring from the shared capsule source instead of introducing another fixed constant.
Tested: cargo test --manifest-path src-tauri/Cargo.toml --lib -- --nocapture
Not-tested: Live QA window placement on each platform.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 320c97485c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

let show_capsule = inner.prefs.get().show_capsule;
if let Some(window) = app.get_webview_window("capsule") {
let visible = !matches!(state, CapsuleState::Idle);
let _ = crate::position_capsule_bottom_center(&window, payload.translation);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid resizing capsule on every level tick

emit_capsule now calls position_capsule_bottom_center unconditionally, which performs both set_size and set_position each time this function runs. In this codepath, recording level updates are emitted about every 33ms (see the LEVEL_EMIT_MIN_INTERVAL_MS throttled handlers in coordinator.rs), so this change turns steady-state recording into repeated native resize/reposition operations even when size/monitor/translation state has not changed. That can add avoidable compositor churn and visible jitter on long recordings; it would be safer to only resize/reposition when translation mode or monitor actually changes.

Useful? React with 👍 / 👎.

The capsule window now tracks its last applied geometry and only resizes/repositions when the monitor or translation state actually changes. That keeps steady-state level updates from churning the native window manager while preserving the current placement behavior when geometry really does change.

Constraint: Keep the fix minimal and avoid introducing a broader window-management abstraction.
Rejected: Leave the unconditional relayout in place | it adds avoidable compositor churn during recording.
Confidence: high
Scope-risk: narrow
Directive: Any future capsule geometry change should update the cached geometry key, not reintroduce unconditional relayout.
Tested: cargo test --manifest-path src-tauri/Cargo.toml --lib -- --nocapture
Not-tested: Live compositor/jitter behavior on Windows/macOS/Linux.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1dfcf7f302

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +2509 to +2511
*last = Some(next);
drop(last);
let _ = crate::position_capsule_bottom_center(window, translation_active);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Update layout cache only after successful reposition

maybe_position_capsule_bottom_center records last = Some(next) before attempting position_capsule_bottom_center, and then discards the result. If set_size/set_position fails once (for example during transient window-state/platform errors), later emits with the same monitor/translation state will be skipped forever because the cache says layout is already applied, leaving the capsule stuck at stale size/position until some unrelated state change occurs.

Useful? React with 👍 / 👎.

The capsule geometry cache must reflect only applied layout, otherwise a transient resize or position failure would permanently suppress future retries for the same monitor and translation state. The cache is now written only after the relayout call succeeds, so a failed attempt can be retried on later emits.

Constraint: Keep the fix local to the capsule relayout path.
Rejected: Cache before calling relayout | can strand the capsule on stale geometry after a transient failure.
Confidence: high
Scope-risk: narrow
Directive: Never treat capsule geometry as applied until the window manager has accepted the resize/reposition.
Tested: cargo test --manifest-path src-tauri/Cargo.toml --lib -- --nocapture
Not-tested: Live retry behavior under actual window-manager failures.
@H-Chris233 H-Chris233 merged commit 08e48cc into Open-Less:main May 1, 2026
2 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.

feat: polish 提示词词汇本注入措辞调整 — 当前太保守

1 participant