Skip to content

Conversation

@agassiz
Copy link

@agassiz agassiz commented Jun 29, 2025

今天刚更新了,修改一些优化,看是不是需不需采纳
1、添加打开新窗口,激活页面最有效;当启动音效时,还默认局部刷新 (人个觉得新会话时使用打开新窗口的方式(会关闭上个窗口)能真正激活浏览器,通过这个方式,会自动从vscode 切换到 反馈窗口 );弹窗被阻止了,会兼容使用局部刷新方式;只是多了一个选择
下面两个修改是在使用刷新时 会话历史没及时刷新的问题
2、前端 状态显示不一致问题
3、会话历史不刷新问题

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @agassiz, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily addresses issues related to the web page's session history not refreshing correctly and frontend status inconsistencies. It introduces a new strategy for handling feedback submission, which can now open a new browser window for better activation, with intelligent fallbacks to local page updates. Additionally, it refines the session management to ensure timely and accurate display of session states.

Highlights

  • Enhanced Feedback Submission Flow: Implemented a new mechanism where submitting feedback can trigger opening a new browser window and closing the current one for improved page activation. This includes a fallback to local page updates if audio notifications are enabled or if the new window is blocked by the browser.
  • Improved Session History Refresh: Added explicit calls to refresh the session list on the frontend (app.js) immediately after feedback submission and upon new session creation, ensuring the history is up-to-date.
  • Backend Session State Update: Modified the backend (main.py) to explicitly mark the old session as 'feedback processing complete' when a new session is created, ensuring consistent state tracking.
  • Optimized Session History UI Rendering: Introduced a more robust change detection mechanism for the session history list (session-ui-renderer.js) by calculating a hash based on session ID, status, and completion state. This prevents unnecessary re-renders and improves frontend performance and accuracy.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request addresses web page interaction issues related to session history refreshing. It includes changes to main.py and app.js, with a notable enhancement in session-ui-renderer.js using a hash for state change detection. However, there are areas for improvement, including a potential state transition issue in main.py and code redundancy in app.js.

old_websocket = old_session.websocket
debug_log("保存舊會話的 WebSocket 連接以發送更新通知")

old_session.next_step("反饋處理完成")

Choose a reason for hiding this comment

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

high

Calling old_session.next_step() here might lead to an incorrect state transition if the session is already in a submitted state. Consider checking the session's state before calling next_step() to avoid unintended side effects.

Comment on lines +867 to +931
if (audioNotificationEnabled) {
console.log('🔊 音效通知已啟用,使用局部更新策略');

// 使用局部更新方案
// 1. 更新會話資訊
if (data.session_info) {
self.currentSessionId = data.session_info.session_id;
console.log('📋 新會話 ID:', self.currentSessionId);
}

// 1. 更新會話資訊
if (data.session_info) {
self.currentSessionId = data.session_info.session_id;
console.log('📋 新會話 ID:', self.currentSessionId);
}
// 2. 刷新頁面內容(AI 摘要、表單等)
self.refreshPageContent();

// 3. 重置表單狀態
self.clearFeedback();

} else {
console.log('🔇 音效通知未啟用,使用 window.open 策略');

try {
// 嘗試打開新標籤頁
const newWindow = window.open(window.location.href, '_blank');

if (newWindow) {
console.log('✅ 新標籤頁打開成功,準備關閉當前標籤頁');

// 2. 刷新頁面內容(AI 摘要、表單等)
self.refreshPageContent();
// 短暫延遲後關閉當前標籤頁
setTimeout(function() {
console.log('🔄 關閉當前標籤頁');
window.close();
}, 800); // 給新標籤頁一些時間加載

} else {
console.warn('❌ window.open 被阻止,回退到局部更新');

// 回退到局部更新方案
// 1. 更新會話資訊
if (data.session_info) {
self.currentSessionId = data.session_info.session_id;
console.log('📋 新會話 ID:', self.currentSessionId);
}

// 2. 刷新頁面內容(AI 摘要、表單等)
self.refreshPageContent();

// 3. 重置表單狀態
self.clearFeedback();
}
} catch (error) {
console.error('❌ window.open 執行失敗:', error);

// 回退到局部更新方案
// 1. 更新會話資訊
if (data.session_info) {
self.currentSessionId = data.session_info.session_id;
console.log('📋 新會話 ID:', self.currentSessionId);
}

// 2. 刷新頁面內容(AI 摘要、表單等)
self.refreshPageContent();

// 3. 重置表單狀態
self.clearFeedback();
}
}

Choose a reason for hiding this comment

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

high

The partial page update logic is repeated in the if/else block. Extract this logic into a separate function to improve code maintainability and reduce redundancy. This will make the code easier to understand and modify in the future.


// 刷新會話列表以顯示最新狀態
console.log('🔄 反饋提交成功,刷新會話列表');
this.refreshSessionList();

Choose a reason for hiding this comment

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

medium

There's a duplicate call to this.refreshSessionList() on line 775. Remove this redundant call to prevent unnecessary reloads of the session list.

self.clearFeedback();
// 4. 強制刷新會話列表(新會話創建時)
console.log('🔄 新會話創建,強制刷新會話列表');
self.refreshSessionList(true);

Choose a reason for hiding this comment

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

medium

The refreshSessionList function doesn't accept any arguments. Remove the true argument from this call.

Suggested change
self.refreshSessionList(true);
self.refreshSessionList();

Comment on lines +400 to +401
if (self.lastRenderedData.historyLength === sessionHistory.length &&
self.lastRenderedData.historyHash === currentHistoryHash) {

Choose a reason for hiding this comment

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

medium

Consider adding a comment explaining why both historyLength and historyHash are checked. Clarifying the purpose of the hash check will improve code understanding.

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