fix(playtest): eliminate request fan-out - #315
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
There was a problem hiding this comment.
已检查固定提交范围 8821b192c43700083850559eadf7419950c96abc...ddd067a8970c9ee5349c000f266d56c226675498,覆盖角色接口/服务归属与分页、PlayTest 跨项目装配、项目/资产入口以及共享布局令牌迁移。后端跨项目查询通过项目归属 join 限定当前用户,前端也改为按项目页与角色页读取并在本地分组;现有按项目读取、状态过滤与分页路径保持独立。
未发现满足审查标准且置信度达到阈值的新增正确性、性能或安全问题。git diff --check 通过;本地未能执行定向测试,因为环境没有 uv,且前端 vitest 二进制不可执行。
The project center needs a calmer asset-first browsing surface. Render the create entrance, project previews, and empty pixel canvases while resolving real character preview images. Existing project creation, deletion, pagination, and navigation behavior stays intact.
The redesigned gallery must keep its real API and navigation boundaries explicit. Cover character preview requests, empty canvases, creation links, deletion, and pagination. The tests now assert user-visible behavior instead of styling internals.
The workspace heading needs the same concise context used across the product surfaces. Add the approved tagline directly beneath the existing page title. No workspace navigation or data-loading behavior changes.
The approved workspace context line should remain part of the rendered heading area. Assert the tagline alongside the existing navigation behavior. The focused coverage protects the copy without expanding workspace scope.
ddd067a to
d99aec5
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Codecov exposed untested project preview fallback branches. Exercise reference images, first frames, and isolated request failures. Keep gallery previews resilient without changing production behavior.
Project and Playtest entries need the same visual behavior without duplicated styling. Extract the editorial entry card with asset-specific artwork and reuse it for project creation. Both entry points now share sizing, color, tilt, and hover behavior.
The project creation entry must keep its established artwork and accessible link contract. Assert that the rendered link comes from the shared editorial entry component. The test protects the project entry while Playtest reuses the same component.
The global Playtest entry should surface real outfits before decorative scene content. Replace the hero with a filterable cross-project gallery and reuse the shared empty-state entry card. Cards now expose project context, playable actions, frame totals, and disabled states.
The entry must preserve routing, filtering, pagination, empty states, and truthful playback metadata. Cover the gallery states and add a zero-frame action fixture that must stay out of playable summaries. The regression protects both the frozen layout and the workbench playback contract.
Reviewers need stable visual evidence for the frozen Playtest entry design. Add desktop and narrow-screen captures of the populated global outfit gallery. The images document the responsive states used for Issue 304 acceptance.
Zero-frame actions are visible metadata but cannot enter Playtest. Count only actions with real frames in the Workspace outfit summary. Keep the displayed action total aligned with the playable frame contract.
d99aec5 to
412f8f6
Compare
The shared asset fixture now includes one zero-frame draft action. Expect character detail and asset library views to render all three actions. Align both tests with the existing asset display behavior.
PlayTest needs one paginated character source instead of one request per project. Add a user-scoped query path while preserving project-scoped authorization. This bounds character loading and keeps ownership and status filters intact.
The new list mode must not cross user boundaries or lose pagination semantics. Exercise two owned projects, another user, paging, and published status filtering. The regression locks the authorization and filtering contract for PlayTest.
The gallery previously fetched characters once for every loaded project. Load projects and the owned character collection in parallel, then group in memory. Character traffic now scales with pagination instead of project count.
The frontend needs a typed client for the owned cross-project character endpoint. Verify page, page size, and status mapping without a project identifier. The test protects the request contract used by the PlayTest gallery.
Project fan-out can silently return when the gallery data fixture grows. Model unscoped character pagination and count requests across 101 characters. The regression requires two character pages regardless of project count.
CharacterApis now includes the owned cross-project list method. Extend the mutable Quick Start fixture with a compatible paginated result. Existing Quick Start service tests keep exercising the complete interface.
Codecov counted three formatting-only slice lines as uncovered patch code. Restore the existing main-branch spacing on those expressions. Keep the request fan-out diff limited to functional changes.
412f8f6 to
f9db517
Compare
|
这种需要读取多个图的情况,一般行业是怎么做的呀? |
结论一般会把“读取多个图”拆成两层处理:资产元数据请求和图片二进制加载,不会把所有事情都交给一次大请求。
对这次 PR 的对应关系这次 PR 主要解决的是第一层的 API fan-out:原来按项目逐个请求角色,现在项目和角色各自按页读取,再在前端按 但它并不等于图片本身只会发两次请求:PlayTest 卡片仍会为每个
项目详情主图已经采用 |
@huyanxius 可以参考一下,一般在面对陌生的问题、没有解决方案的时候,可以问一下 AI 行业的做法是什么。 |
🫡 |
修复 PlayTest 预览台按项目逐个拉取角色造成的请求放大,将角色读取收敛为按页请求,并保持用户归属、分页与发布状态过滤边界。
Why
原实现先读取全部项目,再为每个项目请求一次角色列表;项目数量增长时会形成 N+1 请求,开发环境的 StrictMode 重放还会进一步放大请求量,最终触发全局限流。
Changes
GET /characters增加当前用户全部项目范围的分页读取模式,同时保留原有按项目读取与归属校验。characterApis增加跨项目分页接口,PlayTest 并行读取项目与角色后在本地按projectId分组。Implementation
Character与Projectjoin 限定Project.user_id,不暴露其他用户的角色。Verification
cd backend && uv run pytest tests/test_character_api.py:18 passed。cd frontend && npm test -- src/entities/character/index.test.ts src/pages/playtest/entry.test.tsx src/pages/quick-start/service.test.ts:29 passed。cd frontend && npm run typecheck:通过。cd frontend && npm run build:通过。Scope
Related Issues
Closes #314
Refs #313