Skip to content

feat(issues): support Markdown and pasted images in new requirements - #1303

Open
Robert0622 wants to merge 3 commits into
mainfrom
codex/requirement-markdown
Open

Robert0622 wants to merge 3 commits into
mainfrom
codex/requirement-markdown

Conversation

@Robert0622

@Robert0622 Robert0622 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

What changed

  • Add a Markdown preview to the new requirement dialog and render the saved description as Markdown in the issue drawer.
  • Let users paste clipboard images, preview and remove them before submission, and open them from the saved issue. The dialog keeps its draft when submission fails.
  • Save images and the issue together. TAPD and Gongfeng sync keep pasted files available on the LoopForge issue when the tracker assigns a new issue ID.

Scope

  • Platform core / API / runner

Compatibility

Markdown-only creation uses the existing JSON request. Creation with images uses multipart and stores files in a new issue_images table. 042_issue_images.sql is available for deployments that apply schema changes manually.

The dialog accepts up to eight PNG, JPEG, WebP or GIF images, with a 10 MiB per-image limit and a 20 MiB total limit. Pasted files stay in the open dialog until submission.

Validation

  • bash scripts/build-chatbot.sh passed (486 tests).
  • npm --prefix webtest test passed.
  • go test -p=2 ./web -count=1 -timeout=120s passed after the blank submission fix.
  • Focused Go tests in internal/httpapi, internal/repo, internal/tracker and web passed.
  • Chromium smoke test with a local LoopForge server passed clipboard PNG, Markdown preview, creation and reopening the saved image after reload.
  • go vet -p=2 ./..., python3 scripts/check-public.py and bash scripts/scan-secrets.sh passed.
  • The full go test -p=2 ./... -count=1 -timeout=180s run reached the package timeout in internal/engine and internal/httpapi, and reported a bubblewrap mount assertion failure in internal/runtime.
  • The engine timeout and bubblewrap assertion also reproduced on main in the same environment.

@cocofhu00

Copy link
Copy Markdown
Contributor

结论:建议合入

GitHub 拒绝了 Pull Request Review 接口(HTTP 403:Tencent 组织启用了 OAuth App 访问限制)。当前账号无法提交正式 Approve / Request changes。以下改为普通评论。

核对了新建需求的 Markdown 预览、粘贴图片和保存后的展示。图片与需求在同一事务里写入,格式、张数和大小都有服务端校验,未登录不能读取;关联 TAPD 或工蜂后会把图片复制到新编号。测试覆盖了非法图片整单回滚、复制后仍可读取,以及预览里脚本和 javascript 链接不会变成图片。CI 的 core 仍在跑,其余检查已通过,与 main 可合并。

@crispinhu27 crispinhu27 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approve at 5eacb140e660d1ce6a2bbf3e79544288ff45007b (base main@be35aff8). No open confirmed defects.

Scope: full diff against main. That covers the issue image upload/storage (issue_images model, migration 042), the GET /api/issues/:id/images/:imageId route, size/count/type limits, cleanup on issue delete and tracker ID change, the tracker save-error change in internal/tracker/service.go, and the composer/rendering changes in web/ and chatbot/.

Verification in an isolated sandbox (synthetic data, no credentials):

  • At 798844d6, TestIssueRoutesCoverRegisteredPaths failed (expected 13 issue sub-routes, got 14) and passed on base. 5eacb140 updates the expected count to 14, and that is its only change. I re-ran the test at this head: PASS.
  • go test ./internal/httpapi/ ./internal/repo/ ./internal/tracker/ -count=1 at this head: repo and tracker pass. In httpapi, the only failures are 5 browser/workspace tests that also fail on base in the sandbox (no Chromium / host tooling). They are not caused by this PR.
  • At 798844d6 (web/chatbot unchanged since): npm --prefix webtest test 259/259 passing, including the new composer test (draft text and images kept on a 503). Chatbot tests 486/486 passing, and the build succeeds.
  • Code review of security-relevant paths: the image GET uses the same auth dispatcher as GET /api/issues/:id, and the lookup is keyed on both issue ID and image ID. Upload is capped by MaxBytesReader plus per-image and count limits, and the content is sniffed (PNG/JPEG/WebP/GIF only, no SVG). Responses set nosniff and no-store. Description rendering escapes text and only allows http(s) URLs, and only same-origin URLs become <img>.
  • All 16 check runs on this head are green, including core and platform-required.

Non-blocking notes:

  • Migration number 042 collides with other open PRs (#1301, #1286), so renumber at merge time.
  • 042_issue_images.sql declares position INT, while gorm maps Go int to bigint. AutoMigrate may alter a hand-created table. This is harmless but inconsistent.
  • saveCreatedTrackerIssue now returns the local save error. If the remote item was already created, a retry could create a duplicate remote item. I did not reproduce this.

This review covers the head above only.

@Robert0622

Copy link
Copy Markdown
Collaborator Author

CR + 部署实测(head 5eacb140),没有发现阻塞问题

部署实测(本机原生部署,MySQL 8.4.7,全新库,表由 automigrate 创建)

  • 新建需求时带 2 张 PNG(multipart):返回 200。详情返回 images 列表(id 和名称),Markdown 原文保持不变。GET /api/issues/:id/images/:imageId 返回 image/png、nosniff、private, no-store,字节和上传的一致。
  • 未登录读图返回 401;用别的需求 id 读这张图返回 404;不存在的图片 id 返回 404。
  • 按内容判断类型:SVG 或 HTML 内容伪装成 image/png 都返回 400。
  • 数量和大小限制:9 张返回 400;单张超过 10 MiB 返回 413;略小于 10 MiB 返回 200;合计 21 MiB 返回 413。
  • 一张合法图加一张非法图:返回 400,issues 和 issue_images 的行数都不变(同一个事务,整体回滚)。
  • syncTarget=tapd 或已有 id 带图片:返回 400「图片只能随新需求一起保存到平台」。前端选 TAPD 时先在平台建单再推送,不会走到这个分支。
  • 只有图片、描述为空:可以建单,标题为「新工作项」。标题和描述都为空:仍返回 400(空白校验保留)。
  • 删除需求以后,这条需求的 issue_images 记录清零,再读图返回 404。
  • Chromium 实测前端:粘贴 PNG 后出现缩略图;Markdown 预览正确渲染 h2、列表、加粗和行内代码。<img onerror> 被转义;javascript: 链接变成 #;外链图片显示成链接,不会加载。建单请求是 multipart。保存后在详情里看到图片已加载(naturalWidth=4),页面没有 JS 报错。

和最新 main 合并:可以干净合并。合并后的 internal/repo、internal/tracker、web,httpapi 里的 Issue/Route 测试,以及 webtest 都已复跑,结果见文末。main 上也有 042_* 迁移文件,编号重复在这个仓库里很常见(041 等也有重复),不影响。

不阻塞的提示:已有需求的描述现在也按 Markdown 渲染,所以 *x* 会显示成斜体,行首缩进不再保留。线上 MySQL 的 max_allowed_packet 如果小于 10 MiB,接近 10 MiB 的单张图会存不进去。

合并 main(9617f94e)后复跑:go vet 通过;internal/repo、internal/tracker、web 和 httpapi 的 Issue/Tracker/Route 测试全部通过;webtest 283/283 通过。

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