Closed
Conversation
Add MesloLGLDZ Nerd Font as a built-in web font to ensure Powerlevel10k and other Nerd Font-dependent prompts render correctly in the web terminal, even on devices without local Nerd Fonts installed (e.g., mobile phones). Changes: - Add MesloLGLDZNerdFontMono-Regular.woff2 to web/public/fonts/ - Load font via FontFace API with BASE_URL support for subpath deployments - Merge font loading and terminal creation in same useEffect to ensure font is ready before terminal renders Fixes tiann#121 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Load MesloLGLDZ Nerd Font from jsDelivr CDN instead of bundling the 1.2MB font file. This reduces the bundle size significantly while still ensuring Nerd Font icons display correctly on all devices. CDN URL: https://cdn.jsdelivr.net/gh/mshaugh/nerdfont-webfonts@v3.3.0/build/fonts/MesloLGLDZNerdFontMono-Regular.woff2 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Owner
|
请把两个修复分开 PR |
When switching between sessions or loading paginated messages, old tool blocks from agentState.requests were being mixed with current messages, causing display order issues. Root cause: reduceChatBlocks creates tool blocks for all permissions in agentState, including those older than the current message page. These old blocks (with earlier createdAt) would appear mixed with newer messages. Fix: 1. In reducer.ts: Skip creating permission-only tool blocks if their createdAt is older than the oldest message in the current view 2. In SessionChat.tsx: Clear caches synchronously in useMemo when session changes, since useEffect runs after render Closes tiann#148 via [HAPI](https://hapi.run) Co-Authored-By: HAPI <noreply@hapi.run>
Root cause: agentState contains all historical permissions while messages are paginated (max 400). This caused old tool cards to appear mixed with current messages when switching sessions. Solution: Backend now returns permissions filtered by the time range of returned messages, ensuring permissions and messages stay in sync. - Add filterPermissionsByTimeRange() in messageService.ts - Return permissions field in GET /sessions/:id/messages response - Store and use filtered permissions in frontend message-window-store - Remove frontend time filtering workaround from reducer.ts via [HAPI](https://hapi.run) Co-Authored-By: HAPI <noreply@hapi.run>
Pending requests (requests) should use real-time SSE data from agentState, not the filtered API response. This ensures new permission requests appear immediately without needing to switch sessions. Only completed requests (completedRequests) use the filtered API data to avoid showing old tool cards. via [HAPI](https://hapi.run) Co-Authored-By: HAPI <noreply@hapi.run>
Remove the frontend permission filtering logic (oldestMessageTime check) since we now use backend filtering via the permissions field in the API response. This is the intended approach as described in the PR. via [HAPI](https://hapi.run) Co-Authored-By: HAPI <noreply@hapi.run>
3e05183 to
f3d3f16
Compare
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题描述
1. 消息排序问题
切换会话或加载分页消息时,旧的工具卡片会混入当前消息中,导致显示顺序混乱。
根本原因:
agentState包含整个 session 历史中的所有权限请求,而props.messages是分页的(最多 400 条)。2. 滚动位置问题
加载历史消息后,页面滚动位置跳到最顶部,而不是保持在加载前的位置。
根本原因:
assistant-ui库的autoScroll在内容变化时会自动滚动到底部messagesVersion变化时,新消息还没有渲染到 DOM,导致滚动位置计算错误与 #150 的关系
此 PR 是 #150 的改进版本:
reducer.ts中根据oldestMessageTime过滤权限(治标)此 PR 会移除 #150 中的前端过滤逻辑。
解决方案
消息排序修复
后端在返回消息时,同时返回该时间范围内的权限(
completedRequests),确保权限和消息的生命周期同步。后端改动:
hub/src/sync/messageService.ts:添加filterPermissionsByTimeRange()函数GET /sessions/:id/messages响应新增permissions字段前端改动:
requests):使用实时 SSE 数据,确保新权限立即显示completedRequests):使用 API 过滤后的数据,避免显示旧的工具卡片reducer.ts中的oldestMessageTime过滤逻辑滚动位置修复
在
HappyThread.tsx中:autoScroll,防止assistant-ui干扰requestAnimationFrame循环检查,等待新消息渲染到 DOM 后再恢复滚动位置autoScroll测试场景
关闭的 Issue
Closes #148