Skip to content

feat(tui): confirm before the prompt editor's Discard button closes it - #120

Merged
openjiuwen-release-bot[bot] merged 1 commit into
openJiuwen-ai:mainfrom
0x7c13:dev/0x7c13/editor-discard-confirm
Oct 25, 2026
Merged

openjiuwen-release-bot[bot] merged 1 commit into
openJiuwen-ai:mainfrom
0x7c13:dev/0x7c13/editor-discard-confirm

Conversation

@0x7c13

@0x7c13 0x7c13 commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Paired: GitHub #120 ↔ GitCode !87

Summary

The prompt editor's Discard button asks before it closes the editor.

  • Whenever the editor holds text, changed or not, Discard opens a "Discard prompt?" confirmation ("Close the editor without committing this content?"), translated for zh-Hans.
  • Discard closes the editor without committing, as the button did before. The chat draft stays as it was.
  • Cancel, Esc or a click outside returns to the editor with its text, cursor and undo history as they were, and clears an armed Esc ("Esc again discards").
  • An empty editor still closes at once. Esc, Esc again, and Vim's ZQ/:q! are unchanged.
  • The Discard button now uses the error variant instead of warning.

Confirmation dialogs are laid out before their first frame.

  • ConfirmDialog.on_mount now sets the width, the button row (stacked when narrow) and the scrolling body's height from app.size. Before, _size_dialog ran one refresh later, so the first frame could show the dialog at another width, its buttons below the screen, or empty task previews.
  • Later resizes and locale changes use the same width rule (_dialog_width).
  • on_mount returns early when the app is no longer running or the dialog is closing.

Test plan

  • New tests:
    • test_confirm_layout.py: every painted frame of the editor's confirmation (en and zh-Hans, four terminal sizes) and of six confirm/notice dialog shapes has the final width, height and button regions.
    • test_editor_dialog.py: the confirmation for unchanged and whitespace-only text in every keymap; Cancel by button, Esc and backdrop keeps the text, cursor and undo history; an empty editor closes without confirmation; the confirmation follows the app locale and a live locale switch.
  • Updated tests:
    • Tests that clicked Discard now also confirm.
    • The held-refresh tests in test_workflow_notices.py and test_background_task_modal.py now expect the final layout and filled previews before deferred callbacks run, and no change after them.
    • The populated-transcript overlay test now also opens and closes the confirmation with its no-restyle, no-recompose and no-relayout spies on the main screen.
  • Tests pass locally.
  • Gates: ruff check, ruff format --check, ty check (linux, darwin, win32) and scripts/i18n.py check.

No docs change: the guide doesn't describe the editor's Discard button.

The prompt editor's Discard button now asks "Discard prompt?" whenever the
editor holds text, changed or not. Discard closes the editor without
committing. Cancel, Esc or a click outside returns to the editor with its
text, cursor and undo history as they were, and clears an armed Esc. An
empty editor still closes at once. Esc, Esc again and Vim's ZQ/:q! are
unchanged. The button now uses the error style instead of the warning
style.

Confirmation dialogs now lay out before their first frame: on mount they
size their width, button row (stacked when narrow) and scrolling body from
the app's size, instead of one refresh later. A dialog no longer paints
once at another width and then jumps, and task previews show from the
first frame.
@openjiuwen-collaboration-bot

openjiuwen-collaboration-bot Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

head_sha: e10d4ff768c2c33909d9d805393189e486176a2a

变更摘要

本 PR 主要调整 TUI 中提示词编辑器 EditorDialog 的关闭行为:Discard 按钮在编辑器含有文本时不再直接关闭,而是先弹出 ConfirmDialog 进行二次确认,并按需清空已武装的 Esc 状态;同时将 ConfirmDialog 的尺寸计算提前到首次绘制之前,使对话框宽度、按钮行与滚动区域在首帧即为最终布局。配套新增了 tui.editor.discard_title、tui.editor.discard_message 两条文案及其 zh-Hans 翻译,并补充、更新了相关布局与交互测试。

主要改动

  • Discard 二次确认流程:editor.py 新增 request_discard(),_on_cancel_pressed 改为调用它;编辑器无文本时仍走 cancel_immediately(),有文本时 push_screen 一个 ConfirmDialog(confirm_variant="error"),确认则放弃、取消则重新聚焦 MessageEditor,并通过 _clear_discard_armed() 清除已武装的 Esc 状态。
  • Discard 按钮样式与文案:editor-cancel 按钮的 variant 由 warning 改为 error;新增 _DISCARD_TITLE、_DISCARD_MESSAGE 两个 msg 常量绑定,并在 locales/chrys.pot、locales/zh-Hans/LC_MESSAGES/chrys.po 中新增 tui.editor.discard_title / tui.editor.discard_message 条目及中文译文。
  • 确认对话框首帧布局:confirm.py 抽出 _dialog_width(available_width) 统一宽度规则,新增 _apply_dialog_size(viewport) 并在 on_mount 中先按 app.size 应用尺寸(on_mount 在 app 已停止或对话框正在关闭时提前返回),compose 里提前渲染 _title / _message 并设置容器宽度,_size_dialog 复用同一方法处理后续 resize。
  • i18n 目录与校验同步:更新二进制 chrys.mo,并在 tests/foundation/i18n/_catalog_oracle_ids.py 中加入两个新消息 ID、在 test_catalog_oracle.py 中将期望消息数由 2405 调整为 2407。
  • 测试覆盖调整:test_confirm_layout.py 新增逐帧尺寸/按钮区域断言及多种对话框形态的宽度用例;test_editor_dialog.py 新增未修改文本、空白文本的确认、Cancel/Esc/背景点击保留文本与撤销历史、空编辑器直接关闭、本地化与运行时切换语言等用例;test_workflow_notices.py 与 test_background_task_modal.py 改为断言首帧即完成布局、预览已填充且后续回调不再改变布局。

@openjiuwen-collaboration-bot

openjiuwen-collaboration-bot Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

head_sha: e10d4ff768c2c33909d9d805393189e486176a2a

代码审查

✅ 未发现问题

@openjiuwen-collaboration-bot

Copy link
Copy Markdown
Contributor

head_sha: e10d4ff768c2c33909d9d805393189e486176a2a

任务名称 结果 日志操作
静态检查 ✅SUCCESS 点此跳转
禁用词扫描 ✅SUCCESS 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
UT测试 ✅SUCCESS 点此跳转
ST测试 N/A N/A
build 编译包 N/A N/A
ruff codecheck ✅SUCCESS N/A
issue关联检查 N/A N/A
pr size检查 N/A N/A

@openjiuwen-release-bot
openjiuwen-release-bot Bot merged commit c361b99 into openJiuwen-ai:main Oct 25, 2026
18 checks passed
@openjiuwen-release-bot

Copy link
Copy Markdown
Contributor

🤖 This pull request has been merged, and the target branch is up to date.

openjiuwen-release-bot Bot pushed a commit that referenced this pull request Oct 25, 2026
[mirror] #120: feat(tui): confirm before the prompt editor's Discard button closes it

Created-by: openjiuwen-sync
Commit-by: Jiaqi (0x7c13) Liu
Merged-by: Ox7c13
Description: Paired: [GitHub #120](#120) ↔ [GitCode !87](https://gitcode.com/openJiuwen/iCode/merge_requests/87)

<!-- bot1-mirror-meta -->
github_pr: 120
head_repo: 0x7c13/iCode
head_ref: dev/0x7c13/editor-discard-confirm
head_sha: e10d4ff
base_repo: openJiuwen-ai/iCode
base_ref: main
github_repo: openJiuwen-ai/iCode
base_branch: main
base_sha: fd3cbcc
github_user: 0x7c13
<!-- /bot1-mirror-meta -->

GitHub PR mirror for CodeArts CI.

<!-- bot1-source-body -->
## Summary

**The prompt editor's Discard button asks before it closes the editor.**
- Whenever the editor holds text, changed or not, Discard opens a "Discard prompt?" confirmation ("Close the editor without committing this content?"), translated for zh-Hans.
- **Discard** closes the editor without committing, as the button did before. The chat draft stays as it was.
- **Cancel**, Esc or a click outside returns to the editor with its text, cursor and undo history as they were, and clears an armed Esc ("Esc again discards").
- An empty editor still closes at once. Esc, Esc again, and Vim's `ZQ`/`:q!` are unchanged.
- The Discard button now uses the `error` variant instead of `warning`.

**Confirmation dialogs are laid out before their first frame.**
- `ConfirmDialog.on_mount` now sets the width, the button row (stacked when narrow) and the scrolling body's height from `app.size`. Before, `_size_dialog` ran one refresh later, so the first frame could show the dialog at another width, its buttons below the screen, or empty task previews.
- Later resizes and locale changes use the same width rule (`_dialog_width`).
- `on_mount` returns early when the app is no longer running or the dialog is closing.

## Test plan

- [x] **New tests:**
  - `test_confirm_layout.py`: every painted frame of the editor's confirmation (en and zh-Hans, four terminal sizes) and of six confirm/notice dialog shapes has the final width, height and button regions.
  - `test_editor_dialog.py`: the confirmation for unchanged and whitespace-only text in every keymap; Cancel by button, Esc and backdrop keeps the text, cursor and undo history; an empty editor closes without confirmation; the confirmation follows the app locale and a live locale switch.
- [x] **Updated tests:**
  - Tests that clicked Discard now also confirm.
  - The held-refresh tests in `test_workflow_notices.py` and `test_background_task_modal.py` now expect the final layout and filled previews before deferred callbacks run, and no change after them.
  - The populated-transcript overlay test now also opens and closes the confirmation with its no-restyle, no-recompose and no-relayout spies on the main screen.
- [x] Tests pass locally.
- [x] **Gates:** `ruff check`, `ruff format --check`, `ty check` (linux, darwin, win32) and `scripts/i18n.py check`.

No docs change: the guide doesn't describe the editor's Discard button.
<!-- /bot1-source-body -->

See merge request: openJiuwen/iCode!87
openjiuwen-release-bot Bot pushed a commit that referenced this pull request Oct 26, 2026
[mirror] #124: chore(release): bump version to 0.32.0

Created-by: openjiuwen-sync
Commit-by: Jiaqi (0x7c13) Liu
Merged-by: Ox7c13
Description: Paired: [GitHub #124](#124) ↔ [GitCode !91](https://gitcode.com/openJiuwen/iCode/merge_requests/91)

<!-- bot1-mirror-meta -->
github_pr: 124
head_repo: 0x7c13/iCode
head_ref: dev/release-0.32.0
head_sha: c9d1882
base_repo: openJiuwen-ai/iCode
base_ref: main
github_repo: openJiuwen-ai/iCode
base_branch: main
base_sha: e225cb1
github_user: 0x7c13
<!-- /bot1-mirror-meta -->

GitHub PR mirror for CodeArts CI.

<!-- bot1-source-body -->
Bump iCode to 0.32.0 so a release is cut from current `main`.

## Changes
- `pyproject.toml` and `uv.lock`: the package version moves from 0.31.0 to 0.32.0.
- i18n catalogs (`locales/chrys.pot`, `locales/zh-Hans/LC_MESSAGES/chrys.po`, the compiled `chrys.mo`): the `Project-Id-Version` header now says 0.32.0. No message changes.

## Release
Merging this changes the version in `pyproject.toml` on `main`, so `tag-release.yml` creates the `v0.32.0` tag and starts `cd.yml` for that tag.

This is the first release whose Linux offline binaries bundle Pillow 13.0.0, from the glibc 2.17 wheels published as `pillow-13.0.0-manylinux2014.1` (#122, #123).

## Included since 0.31.0
- #123 Pillow 13.0.0 and pypdf 6.21.2 (pypdf security fixes); the Linux offline binaries take the matching glibc 2.17 Pillow wheels
- #122 the manylinux2014 Pillow wheel workflow builds 13.0.0 on patched build images, with every source archive pinned by SHA-256 (build-only); hook indicator tests stabilized
- #121 completed turns fold into activity sections; the docs show how to request readable Claude thinking summaries
- #120 the prompt editor asks for confirmation before its Discard button closes it
- #111 a sidebar Hooks tab lists every hook run, and each run is recorded once
- GitCode !85 the main chat shows the model's thinking as it streams; a resumed session replays it folded, and `/fold` folds it too
- GitCode !84 the chat follows new content only while you are at the bottom
- GitCode !83 a hook run log cut to size keeps file paths that are not valid UTF-8 intact
- GitCode !82 faster startup: a loading screen with the logo paints before the main screen and agent load, and F12 works again once the agent is ready

## Verification
- `uv lock --check` passes.
- `scripts/i18n.py extract/update/compile/check` runs clean, and a second run changes nothing.
- Tests were not run locally; CI covers them.
<!-- /bot1-source-body -->

See merge request: openJiuwen/iCode!91
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant