Skip to content

fix(ui): PhoneFrame sizing + iframe containment#76

Merged
hqhq1025 merged 1 commit intomainfrom
wt/loop-fix-phoneframe-sizing
Apr 19, 2026
Merged

fix(ui): PhoneFrame sizing + iframe containment#76
hqhq1025 merged 1 commit intomainfrom
wt/loop-fix-phoneframe-sizing

Conversation

@hqhq1025
Copy link
Copy Markdown
Collaborator

Summary

用户截图显示 mobile preview 视觉灾难:frame 超大、内容溢出、iframe 露在 frame 外。本 PR 修复 PhoneFrame fixed pixel sizing + iframe containment + canvas centering。

Fixes

  • iframe 不再溢出 bezel:mobile 模式下 iframe 不再设置 inline width/height 像素值;交由 PhoneFrame 的 screen-area (375x812 via tokens) 单一来源控制。同时 border-0 干掉浏览器默认 2px frameborder,避免 4px 溢出 PhoneFrame overflow:hidden 边界。
  • PhoneFrame 不再被 flex 压扁:outer container 加 flexShrink:0 + boxSizing:'content-box',frame 始终保持 391x828 (375 + 8px border × 2),符合 iPhone 参考尺寸 ~396x844。
  • 画布居中:mobile 包装从 justify-start 改为 justify-center + min-h-full + p-6,frame 在画布中央,留出 padding。
  • 加 home indicator:底部 134x5 圆角条,视觉上更像真机。
  • 可测的 sizing contract:导出 PHONE_FRAME_SIZING 常量,单测验证 375x812 屏 + 8px bezel = 391x828 整机。

Test plan

  • pnpm --filter @open-codesign/desktop test — 227 passed (含新增 PhoneFrame.test.ts 3 cases)
  • pnpm typecheck — 10/10 packages green
  • pnpm lint — 0 new warnings
  • 手测:切到 Mobile viewport,确认 frame 居中、iframe 完整裹住、artifact 内可滚动

PRINCIPLES §5b

  • Compatibility ✅ — 仅 UI sizing 修复,无 schema/IPC 变化
  • Upgradeability ✅ — sizing 从 token 取值,调单一变量即生效
  • No bloat ✅ — 净增 ~58 行 (含测试),无新依赖
  • Elegance ✅ — single source of truth (PhoneFrame screen-area),iframe 不再重复设宽高

- Drop redundant inline pixel sizing on the iframe in mobile mode; let
  PhoneFrame's screen-area (375x812 via tokens) be the single source of
  truth so the iframe's default 2px frameborder cannot overflow the bezel.
- Add flexShrink:0 + content-box on PhoneFrame outer so the frame keeps
  its 391x828 footprint when nested in flex layouts.
- Strip the iframe browser border (border-0) and use block display in
  mobile mode so the rendered artifact fills the screen-area cleanly.
- Add a home indicator stripe to match the iPhone-style bezel.
- Center the PhoneFrame in the canvas (justify-center, min-h-full)
  with p-6 padding so it never butts against the toolbar.
- Unit-test the sizing contract via PHONE_FRAME_SIZING constants.
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Findings

  • No high-confidence issues found in added/modified lines.

Summary

  • Review mode: initial
  • No blocking/major/minor issues found in this diff.
  • Residual risk: runtime visual/layout behavior for mobile preview centering and phone-frame overlays is only covered by a non-DOM unit test; no Playwright coverage added.
  • Context note: docs/VISION.md and docs/PRINCIPLES.md were requested but are unavailable in this checkout (Not found in repo/docs).

Testing

  • Not run (automation)
  • Suggested tests: add a Playwright assertion for mobile preview viewport frame dimensions, notch/home-indicator overlap, and inline-comment hint/composer positioning.

open-codesign Bot

@hqhq1025 hqhq1025 merged commit 268cee8 into main Apr 19, 2026
5 of 6 checks passed
@hqhq1025 hqhq1025 deleted the wt/loop-fix-phoneframe-sizing branch April 19, 2026 04:32
hqhq1025 added a commit that referenced this pull request Apr 19, 2026
…ner bezel

User feedback on #76: sizing was correct but the device still looked melted
into the cream canvas, the bezel was thick enough to clip iframe content,
and the notch read as a bump rather than a real iPhone cut-out.

Changes:
- New tokens (--color-phone-body / --color-phone-island /
  --border-width-phone-bezel / --size-preview-mobile-island-{w,h}),
  light + dark variants
- Single-layer deep space-gray body (no more outer cream + inner black
  double bezel) with a 3px bezel so artifact corners are not eaten
- Centered Dynamic Island pill replaces the notch
- Hide the click-to-comment hint pill in mobile viewport — it was overlapping
  the device chrome and the user has already opted into the small frame
- Test contract updated: asserts body uses dedicated phone token (not
  --color-surface / --color-background) and exposes a stable test id +
  island token names
hqhq1025 added a commit that referenced this pull request Apr 19, 2026
…ner bezel (#80)

User feedback on #76: sizing was correct but the device still looked melted
into the cream canvas, the bezel was thick enough to clip iframe content,
and the notch read as a bump rather than a real iPhone cut-out.

Changes:
- New tokens (--color-phone-body / --color-phone-island /
  --border-width-phone-bezel / --size-preview-mobile-island-{w,h}),
  light + dark variants
- Single-layer deep space-gray body (no more outer cream + inner black
  double bezel) with a 3px bezel so artifact corners are not eaten
- Centered Dynamic Island pill replaces the notch
- Hide the click-to-comment hint pill in mobile viewport — it was overlapping
  the device chrome and the user has already opted into the small frame
- Test contract updated: asserts body uses dedicated phone token (not
  --color-surface / --color-background) and exposes a stable test id +
  island token names
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.

1 participant