Conversation
* fix(island): 修正季节餐优先制作开关语义 - 将有鱼餐馆双笋开关调整为季节餐优先制作总开关 - 按当前季节动态注册餐馆季节餐,避免跨季节识别非当前季节餐品 - 更新有鱼餐馆与白熊饮品季节优先制作配置翻译 * fix(island): 修复岛屿任务冷启动卡死 - 每日互动、珍珠售卖、每日订单、货运筹备入口先进入岛屿页面检查链 - 农场、牧场在读取仓库前先走 ui_ensure,避免游戏未启动时直接 ui_goto 卡住 - 复用 ui_get_current_page 的 app_check 和上层 Restart 恢复逻辑,不新增业务侧运行检查
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Code Review
This pull request updates LLM configurations, refactors seasonal dish and drink prioritization in the island restaurant module (including i18n updates), and ensures the correct island page state across various island tasks. Feedback on the changes highlights two key issues: first, popping the error hash from the cache on LLM analysis failure can cause redundant API retries and log spam; second, a potential bug in the restaurant's product selection logic could trigger unintended clicks if both the product selection and normal selection are None.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| except ImportError: | ||
| logger.error('未安装 openai 库。请运行: pip install openai') | ||
| _analyzed_errors_cache.pop(error_hash, None) | ||
| logger.error('未安装 openai 库,无法进行 LLM 错误分析。') | ||
| except Exception as ex: | ||
| _analyzed_errors_cache.pop(error_hash, None) | ||
| # 避免循环日志问题,LLM 本身失败时使用简化的错误日志 | ||
| logger.error(f'LLM 分析调用失败(严禁提交此模块的相关日志 群内机器人检测到将自动移出群聊): {ex}') | ||
| logger.warning(LLM_CONFIG_WARNING) |
There was a problem hiding this comment.
Popping error_hash from _analyzed_errors_cache on failure will cause subsequent occurrences of the same error to trigger the LLM API call again. If the failure is due to a persistent issue (e.g., invalid API key, network issues, or missing openai library), this can lead to repeated slow API calls, potential application lag, and log spam. Consider caching the failure state (e.g., setting the cache value to a failure message) instead of removing the hash, to prevent redundant retries.
| except ImportError: | |
| logger.error('未安装 openai 库。请运行: pip install openai') | |
| _analyzed_errors_cache.pop(error_hash, None) | |
| logger.error('未安装 openai 库,无法进行 LLM 错误分析。') | |
| except Exception as ex: | |
| _analyzed_errors_cache.pop(error_hash, None) | |
| # 避免循环日志问题,LLM 本身失败时使用简化的错误日志 | |
| logger.error(f'LLM 分析调用失败(严禁提交此模块的相关日志 群内机器人检测到将自动移出群聊): {ex}') | |
| logger.warning(LLM_CONFIG_WARNING) | |
| except ImportError: | |
| _analyzed_errors_cache[error_hash] = '未安装 openai 库,无法进行 LLM 错误分析。' | |
| logger.error('未安装 openai 库,无法进行 LLM 错误分析。') | |
| except Exception as ex: | |
| _analyzed_errors_cache[error_hash] = f'LLM 分析调用失败: {ex}' | |
| # 避免循环日志问题,LLM 本身失败时使用简化的错误日志 | |
| logger.error(f'LLM 分析调用失败(严禁提交此模块的相关日志 群内机器人检测到将自动移出群聊): {ex}') | |
| logger.warning(LLM_CONFIG_WARNING) |
| if self.seasonal_dish_slot: | ||
| dish_name = self.seasonal_dish_slot['name'] | ||
| fixed_selection = self.seasonal_dish_slot['selection'] | ||
| normal_selection = self.name_to_config.get(dish_name, {}).get('selection') | ||
| if product_selection in (fixed_selection, normal_selection): | ||
| self.device.click(FIXED_SELECT_DOUBLE_BAMBOO_SHOOTS) | ||
| self.device.sleep(0.5) | ||
| return True |
There was a problem hiding this comment.
If product_selection is None and normal_selection is also None (which can happen if dish_name is not found in name_to_config), the membership check product_selection in (fixed_selection, normal_selection) will evaluate to True because None in (fixed_selection, None) is True. This will cause an unintended click on FIXED_SELECT_DOUBLE_BAMBOO_SHOOTS. Adding a None check for product_selection prevents this issue.
| if self.seasonal_dish_slot: | |
| dish_name = self.seasonal_dish_slot['name'] | |
| fixed_selection = self.seasonal_dish_slot['selection'] | |
| normal_selection = self.name_to_config.get(dish_name, {}).get('selection') | |
| if product_selection in (fixed_selection, normal_selection): | |
| self.device.click(FIXED_SELECT_DOUBLE_BAMBOO_SHOOTS) | |
| self.device.sleep(0.5) | |
| return True | |
| if self.seasonal_dish_slot: | |
| dish_name = self.seasonal_dish_slot['name'] | |
| fixed_selection = self.seasonal_dish_slot['selection'] | |
| normal_selection = self.name_to_config.get(dish_name, {}).get('selection') | |
| if product_selection is not None and product_selection in (fixed_selection, normal_selection): | |
| self.device.click(FIXED_SELECT_DOUBLE_BAMBOO_SHOOTS) | |
| self.device.sleep(0.5) | |
| return True |
Reviewer's Guide重构了岛屿餐厅的季节菜品处理逻辑,加固了 LLM 错误分析的配置与响应处理,更新了默认 LLM 配置值,并在多个岛屿任务中加入统一的 UI 预热步骤以避免冷启动问题。 Sequence diagram for LLM error analysis with improved config and response handlingsequenceDiagram
participant Config
participant LlmModule as module.llm
participant OpenAIAPI as OpenAI_compatible_API
participant Logger
Config->>LlmModule: analyze_exception(config, e)
LlmModule->>LlmModule: truncate(str(e), 4000)
LlmModule->>LlmModule: hashlib.md5(...) -> error_hash
LlmModule->>LlmModule: check _analyzed_errors_cache
alt no api_key
LlmModule->>Logger: warning(LLM 错误分析已启用,但 API Key 未配置。)
LlmModule->>Logger: warning(LLM_CONFIG_WARNING)
LlmModule-->>Config: return
else api_key present
LlmModule->>LlmModule: set _analyzed_errors_cache[error_hash]
LlmModule->>Logger: hr/ info 调用 LLM 分析
LlmModule->>OpenAIAPI: client.chat.completions.create(...)
OpenAIAPI-->>LlmModule: response
LlmModule->>LlmModule: _get_analysis_from_response(response)
alt analysis empty
LlmModule->>LlmModule: _analyzed_errors_cache.pop(error_hash)
LlmModule->>Logger: warning(LLM_EMPTY_RESULT_WARNING)
LlmModule->>Logger: warning(LLM_CONFIG_WARNING)
LlmModule->>Logger: hr 分析结束
else analysis nonempty
LlmModule->>LlmModule: set _analyzed_errors_cache[error_hash]
LlmModule->>Logger: info 打印分析报告
LlmModule->>Logger: hr 分析结束
end
end
note over LlmModule,Logger: On ImportError/Exception: pop cache, log error and LLM_CONFIG_WARNING
Sequence diagram for island tasks cold-start fix with ui_ensuresequenceDiagram
actor User
participant Task as IslandTask.run
participant UI as ui_ensure
participant Nav as ui_goto
User->>Task: run()
Task->>UI: ui_ensure(page_island)
UI-->>Task: ensured on page_island
alt task navigates to phone
Task->>Nav: ui_goto(page_island_phone, get_ship=False)
Nav-->>Task: on page_island_phone
end
Task-->>User: continue task-specific logic
Flow diagram for updated seasonal dish handling in IslandRestaurantflowchart TD
A[IslandRestaurant.__init__] --> B[_init_season_config]
B --> C[_get_high_priority_seasonal_dish]
C -->|returns dish or None| D[seasonal_dish_slot]
B --> E[_get_current_seasonal_shop_items]
E --> F[shop_items initial seasonal dishes]
D --> G{seasonal_dish_slot exists?}
G -->|yes| H[logger.info 高优先级季节菜品]
G -->|no| I[skip]
F --> J[append regular dishes]
subgraph SelectProduct
K[select_product] --> L{seasonal_dish_slot exists?}
L -->|no| M[super.select_product]
L -->|yes| N[get dish_name and selections]
N --> O{product_selection matches fixed or normal?}
O -->|yes| P[device.click FIXED_SELECT_DOUBLE_BAMBOO_SHOOTS]
P --> Q[device.sleep]
O -->|no| M
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your Experience访问你的 dashboard 以:
Getting HelpOriginal review guide in EnglishReviewer's GuideRefactors island restaurant seasonal dish handling, hardens LLM error analysis configuration and response handling, updates default LLM config values, and adds a consistent UI warm-up step to several island tasks to avoid cold-start issues. Sequence diagram for LLM error analysis with improved config and response handlingsequenceDiagram
participant Config
participant LlmModule as module.llm
participant OpenAIAPI as OpenAI_compatible_API
participant Logger
Config->>LlmModule: analyze_exception(config, e)
LlmModule->>LlmModule: truncate(str(e), 4000)
LlmModule->>LlmModule: hashlib.md5(...) -> error_hash
LlmModule->>LlmModule: check _analyzed_errors_cache
alt no api_key
LlmModule->>Logger: warning(LLM 错误分析已启用,但 API Key 未配置。)
LlmModule->>Logger: warning(LLM_CONFIG_WARNING)
LlmModule-->>Config: return
else api_key present
LlmModule->>LlmModule: set _analyzed_errors_cache[error_hash]
LlmModule->>Logger: hr/ info 调用 LLM 分析
LlmModule->>OpenAIAPI: client.chat.completions.create(...)
OpenAIAPI-->>LlmModule: response
LlmModule->>LlmModule: _get_analysis_from_response(response)
alt analysis empty
LlmModule->>LlmModule: _analyzed_errors_cache.pop(error_hash)
LlmModule->>Logger: warning(LLM_EMPTY_RESULT_WARNING)
LlmModule->>Logger: warning(LLM_CONFIG_WARNING)
LlmModule->>Logger: hr 分析结束
else analysis nonempty
LlmModule->>LlmModule: set _analyzed_errors_cache[error_hash]
LlmModule->>Logger: info 打印分析报告
LlmModule->>Logger: hr 分析结束
end
end
note over LlmModule,Logger: On ImportError/Exception: pop cache, log error and LLM_CONFIG_WARNING
Sequence diagram for island tasks cold-start fix with ui_ensuresequenceDiagram
actor User
participant Task as IslandTask.run
participant UI as ui_ensure
participant Nav as ui_goto
User->>Task: run()
Task->>UI: ui_ensure(page_island)
UI-->>Task: ensured on page_island
alt task navigates to phone
Task->>Nav: ui_goto(page_island_phone, get_ship=False)
Nav-->>Task: on page_island_phone
end
Task-->>User: continue task-specific logic
Flow diagram for updated seasonal dish handling in IslandRestaurantflowchart TD
A[IslandRestaurant.__init__] --> B[_init_season_config]
B --> C[_get_high_priority_seasonal_dish]
C -->|returns dish or None| D[seasonal_dish_slot]
B --> E[_get_current_seasonal_shop_items]
E --> F[shop_items initial seasonal dishes]
D --> G{seasonal_dish_slot exists?}
G -->|yes| H[logger.info 高优先级季节菜品]
G -->|no| I[skip]
F --> J[append regular dishes]
subgraph SelectProduct
K[select_product] --> L{seasonal_dish_slot exists?}
L -->|no| M[super.select_product]
L -->|yes| N[get dish_name and selections]
N --> O{product_selection matches fixed or normal?}
O -->|yes| P[device.click FIXED_SELECT_DOUBLE_BAMBOO_SHOOTS]
P --> Q[device.sleep]
O -->|no| M
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - 我在这里给出一些总体反馈:
- 在
RESTAURANT_SEASONAL_DISHES和HIGH_PRIORITY_SEASONAL_DISHES中,季节菜品条目不再定义var_name,这可能会破坏任何依赖这些产品的name_to_config/var_name的逻辑;建议把var_name加回来,以保持与其他shop_items条目的一致性。 - 新的
_get_high_priority_seasonal_dish现在始终要求启用IslandRestaurant_DoubleBambooShoots并且存在season_config,而之前seasonal_dish_slot可以仅基于季节菜品或old_double_enabled来设置;请仔细确认这种更严格的控制是否符合期望行为,并且不会导致旧配置退化。
给 AI 代理的提示
Please address the comments from this code review:
## Overall Comments
- 在 `RESTAURANT_SEASONAL_DISHES` 和 `HIGH_PRIORITY_SEASONAL_DISHES` 中,季节菜品条目不再定义 `var_name`,这可能会破坏任何依赖这些产品的 `name_to_config`/`var_name` 的逻辑;建议把 `var_name` 加回来,以保持与其他 `shop_items` 条目的一致性。
- 新的 `_get_high_priority_seasonal_dish` 现在始终要求启用 `IslandRestaurant_DoubleBambooShoots` 并且存在 `season_config`,而之前 `seasonal_dish_slot` 可以仅基于季节菜品或 `old_double_enabled` 来设置;请仔细确认这种更严格的控制是否符合期望行为,并且不会导致旧配置退化。帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据这些反馈改进后续的代码审查。
Original comment in English
Hey - I've left some high level feedback:
- In
RESTAURANT_SEASONAL_DISHESandHIGH_PRIORITY_SEASONAL_DISHES, the seasonal dish entries no longer definevar_name, which may break any logic that relies onname_to_config/var_namefor these products; consider addingvar_nameback for consistency with othershop_itemsentries. - The new
_get_high_priority_seasonal_dishnow always requiresIslandRestaurant_DoubleBambooShootsto be enabled andseason_configto be present, whereas previouslyseasonal_dish_slotcould be set based solely on seasonal items orold_double_enabled; double-check that this stricter gating matches the desired behavior and doesn’t regress older configurations.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `RESTAURANT_SEASONAL_DISHES` and `HIGH_PRIORITY_SEASONAL_DISHES`, the seasonal dish entries no longer define `var_name`, which may break any logic that relies on `name_to_config`/`var_name` for these products; consider adding `var_name` back for consistency with other `shop_items` entries.
- The new `_get_high_priority_seasonal_dish` now always requires `IslandRestaurant_DoubleBambooShoots` to be enabled and `season_config` to be present, whereas previously `seasonal_dish_slot` could be set based solely on seasonal items or `old_double_enabled`; double-check that this stricter gating matches the desired behavior and doesn’t regress older configurations.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
由 Sourcery 提供的摘要
优化海岛餐厅的季节菜品处理方式,改进海岛任务 UI 初始化以减少冷启动问题,并加强 LLM 错误分析的配置与响应逻辑。
新功能:
错误修复:
增强改进:
Original summary in English
Summary by Sourcery
Refine island restaurant seasonal dish handling, improve island task UI initialization to reduce cold-start issues, and harden LLM error-analysis configuration and responses.
New Features:
Bug Fixes:
Enhancements: