Conversation
There was a problem hiding this comment.
Hey - 我发现了 1 个问题,并留下了一些整体反馈:
- 建议将
document.getElementById('logs-panel')替换为传入LogsPanel的 Reactref,这样滚动行为就能保持在 React 的数据流中,并避免依赖硬编码的 DOM id。 - 新增的悬浮纯图标按钮应当显式添加
type="button",并设置aria-label={t('logs.scrollToLogs')},以避免意外触发表单提交,同时提升屏幕阅读器的可访问性。
给 AI 代理的提示词
Please address the comments from this code review:
## Overall Comments
- Consider replacing `document.getElementById('logs-panel')` with a React `ref` passed into `LogsPanel` so the scroll behavior stays within React’s data flow and avoids relying on a hard-coded DOM id.
- The new floating icon-only button should include `type="button"` and an `aria-label={t('logs.scrollToLogs')}` to avoid unintended form submission and improve accessibility for screen readers.
## Individual Comments
### Comment 1
<location path="src/App.tsx" line_range="1833-1840" />
<code_context>
</div>
+
+ {/* 浮动按钮:定位到运行日志 */}
+ <button
+ onClick={() =>
+ document.getElementById('logs-panel')?.scrollIntoView({ behavior: 'smooth' })
+ }
+ className="fixed bottom-4 right-4 z-50 p-3 rounded-full bg-accent text-white shadow-lg active:bg-accent-hover transition-colors"
+ title={t('logs.scrollToLogs')}
+ >
+ <ScrollText className="w-5 h-5" />
+ </button>
</div>
</code_context>
<issue_to_address>
**issue (bug_risk):** Specify button type to avoid unintended form submissions when nested in a form
Without an explicit `type`, this button defaults to `type="submit"` when rendered inside a `<form>`, which can cause accidental form submissions. Set `type="button"` to ensure it only triggers the scroll behavior:
```tsx
<button
type="button"
onClick={() =>
document.getElementById('logs-panel')?.scrollIntoView({ behavior: 'smooth' })
}
className="fixed bottom-4 right-4 z-50 p-3 rounded-full bg-accent text-white shadow-lg active:bg-accent-hover transition-colors"
title={t('logs.scrollToLogs')}
>
<ScrollText className="w-5 h-5" />
</button>
```
</issue_to_address>帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进之后的评审。
Original comment in English
Hey - I've found 1 issue, and left some high level feedback:
- Consider replacing
document.getElementById('logs-panel')with a Reactrefpassed intoLogsPanelso the scroll behavior stays within React’s data flow and avoids relying on a hard-coded DOM id. - The new floating icon-only button should include
type="button"and anaria-label={t('logs.scrollToLogs')}to avoid unintended form submission and improve accessibility for screen readers.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider replacing `document.getElementById('logs-panel')` with a React `ref` passed into `LogsPanel` so the scroll behavior stays within React’s data flow and avoids relying on a hard-coded DOM id.
- The new floating icon-only button should include `type="button"` and an `aria-label={t('logs.scrollToLogs')}` to avoid unintended form submission and improve accessibility for screen readers.
## Individual Comments
### Comment 1
<location path="src/App.tsx" line_range="1833-1840" />
<code_context>
</div>
+
+ {/* 浮动按钮:定位到运行日志 */}
+ <button
+ onClick={() =>
+ document.getElementById('logs-panel')?.scrollIntoView({ behavior: 'smooth' })
+ }
+ className="fixed bottom-4 right-4 z-50 p-3 rounded-full bg-accent text-white shadow-lg active:bg-accent-hover transition-colors"
+ title={t('logs.scrollToLogs')}
+ >
+ <ScrollText className="w-5 h-5" />
+ </button>
</div>
</code_context>
<issue_to_address>
**issue (bug_risk):** Specify button type to avoid unintended form submissions when nested in a form
Without an explicit `type`, this button defaults to `type="submit"` when rendered inside a `<form>`, which can cause accidental form submissions. Set `type="button"` to ensure it only triggers the scroll behavior:
```tsx
<button
type="button"
onClick={() =>
document.getElementById('logs-panel')?.scrollIntoView({ behavior: 'smooth' })
}
className="fixed bottom-4 right-4 z-50 p-3 rounded-full bg-accent text-white shadow-lg active:bg-accent-hover transition-colors"
title={t('logs.scrollToLogs')}
>
<ScrollText className="w-5 h-5" />
</button>
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Pull request overview
本 PR 为移动端界面新增“定位到运行日志”的浮动按钮,并配套调整日志面板布局与多语言文案,使用户在移动端长页面中可快速跳转到运行日志区域。
Changes:
- 为日志模块新增
logs.scrollToLogsi18n 文案(多语言)。 - 调整
LogsPanel的容器布局(增加锚点id,并优化移动端高度/滚动行为)。 - 在移动端主视图新增浮动按钮,点击后平滑滚动到日志面板。
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/i18n/locales/zh-TW.ts | 增加“查看日誌”按钮文案键值 |
| src/i18n/locales/zh-CN.ts | 增加“查看日志”按钮文案键值 |
| src/i18n/locales/ko-KR.ts | 增加“로그 보기”按钮文案键值 |
| src/i18n/locales/ja-JP.ts | 增加“ログを表示”按钮文案键值 |
| src/i18n/locales/en-US.ts | 增加“View logs”按钮文案键值 |
| src/components/LogsPanel.tsx | 为滚动定位提供 id,并调整移动端高度策略 |
| src/App.tsx | 移动端新增“跳转到运行日志”的浮动按钮入口 |
| src-tauri/src/web_server.rs | 调整 CORS 相关 import 以匹配当前用法 |
| <button | ||
| onClick={() => | ||
| document.getElementById('logs-panel')?.scrollIntoView({ behavior: 'smooth' }) | ||
| } | ||
| className="fixed bottom-4 right-4 z-50 p-3 rounded-full bg-accent text-white shadow-lg active:bg-accent-hover transition-colors" | ||
| title={t('logs.scrollToLogs')} | ||
| > | ||
| <ScrollText className="w-5 h-5" /> | ||
| </button> |
There was a problem hiding this comment.
This icon-only floating button relies on title for its label, which isn’t reliably announced by screen readers and isn’t accessible on touch devices. Add an explicit aria-label (and consider type="button") so the control is accessible and doesn’t accidentally act as a submit button if rendered within a form.
| <div | ||
| id="logs-panel" | ||
| className={clsx( | ||
| 'flex flex-col bg-bg-secondary rounded-lg ring-1 ring-inset ring-border overflow-hidden', | ||
| isMobile ? 'h-[calc(100dvh-2.5rem)]' : 'flex-1 min-h-50', | ||
| )} |
There was a problem hiding this comment.
The mobile height uses a hard-coded 2.5rem offset (h-[calc(100dvh-2.5rem)]), which implicitly depends on the TabBar height (currently h-10). If TabBar height changes, this will silently break layout. Consider deriving this from a shared constant/CSS variable or documenting the coupling to avoid drift.
Summary by Sourcery
添加适配移动端的浮动按钮,用于快速滚动到日志面板,并为移动端视图调整日志面板布局。
新功能:
增强改进:
Original summary in English
Summary by Sourcery
Add a mobile-friendly floating button to quickly scroll to the logs panel and adjust the logs panel layout for mobile view.
New Features:
Enhancements: