Skip to content

feat: 手机端添加运行日志按钮#170

Merged
MistEO merged 2 commits intomainfrom
feat/log_btn
Apr 12, 2026
Merged

feat: 手机端添加运行日志按钮#170
MistEO merged 2 commits intomainfrom
feat/log_btn

Conversation

@MistEO
Copy link
Copy Markdown
Owner

@MistEO MistEO commented Apr 12, 2026

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:

  • Introduce a floating action button on mobile to scroll directly to the logs panel.
  • Add localized tooltip text for the new scroll-to-logs button across supported languages.

Enhancements:

  • Adjust logs panel sizing behavior to better fit the mobile viewport height.

Copilot AI review requested due to automatic review settings April 12, 2026 12:40
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - 我发现了 1 个问题,并留下了一些整体反馈:

  • 建议将 document.getElementById('logs-panel') 替换为传入 LogsPanel 的 React ref,这样滚动行为就能保持在 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>

Sourcery 对开源项目免费——如果你觉得我们的评审有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进之后的评审。
Original comment in English

Hey - I've found 1 issue, and left some high level feedback:

  • 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.
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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/App.tsx
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

本 PR 为移动端界面新增“定位到运行日志”的浮动按钮,并配套调整日志面板布局与多语言文案,使用户在移动端长页面中可快速跳转到运行日志区域。

Changes:

  • 为日志模块新增 logs.scrollToLogs i18n 文案(多语言)。
  • 调整 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 以匹配当前用法

Comment thread src/App.tsx
Comment on lines +1833 to +1841
<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>
Copy link

Copilot AI Apr 12, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +127 to +132
<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',
)}
Copy link

Copilot AI Apr 12, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@MistEO MistEO merged commit e243bce into main Apr 12, 2026
15 checks passed
@MistEO MistEO deleted the feat/log_btn branch April 12, 2026 12:49
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.

2 participants