Skip to content

fix(chat): restore per-session reading positions - #723

Merged
agegr merged 3 commits into
agegr:mainfrom
Zhangs-11:fix/restore-session-scroll-position
Sep 5, 2026
Merged

agegr merged 3 commits into
agegr:mainfrom
Zhangs-11:fix/restore-session-scroll-position

Conversation

@Zhangs-11

@Zhangs-11 Zhangs-11 commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • remember each conversation's visible reading anchor while Pi Web remains open
  • restore the same paragraph offset when returning to that conversation, loading earlier history pages when necessary
  • keep tail-following conversations at the bottom and let explicit search-result navigation override remembered positions

The memory is page-local: refreshing or reopening Pi Web continues to start an existing conversation at the bottom.

Demo

A conversation returns to the same reading position after switching away

Recorded from commit 3f9c2c1706e1175f13da93449dae5755b20e520b on the PR branch, served from that tree at http://127.0.0.1:30153 with next dev because this repository prohibits running next build during development. The run used a fresh isolated Pi agent directory, workspace, and browser profile with the normal application transport. Real GPT-6-Astra model rounds created both demonstrated conversations; no fixtures, mock transports, synthetic application events, or test-only hooks were used.

Validation

  • npm test — 887 tests passed
  • tsc --noEmit
  • npm run lint
  • git diff --check
  • real browser QA: scroll a model-backed conversation to an older paragraph, switch conversations, return, and verify the same paragraph and pixel offset are restored
  • real browser QA: a conversation left at the bottom returns to the bottom; a full page reload clears the in-memory position

@agegr
agegr merged commit 430fe4d into agegr:main Sep 5, 2026
2 checks passed
heibai010011 pushed a commit to heibai010011/pi-web that referenced this pull request Sep 7, 2026
上游新功能:
- 内置终端面板(node-pty + xterm,API /api/terminal,工作区级进程复用)
- 划选文本分支对话(agegr#698)与会话搜索(/api/sessions/search)
- 聊天外观设置(agegr#704:字号/行宽/消息间距/气泡样式)
- 草稿保留与恢复(agegr#720)、阅读位置记忆(agegr#723)
- 窗口化会话列表(agegr#626)、插件更新检查(agegr#611)、Mermaid 预览
- Pi 依赖升级至 0.85.1,CI 工作流

本地特性在合并中保留:
- 会话文件夹组织(session-folder-drafts / session-folders)与树视图
- 权限插件内联卡片(InlinePermissionRequest)与扩展模态拆分
- 侧栏"当前工作"时间分段视图、删除会话的全局级联重挂载
- 响应状态胶囊、自定义语法高亮主题、dev Service Worker 清理

测试适配(--test-isolation=none 下共享进程环境):
- subagents profiles/settings/subagents 测试在测试体内重新指向各自的
  PI_CODING_AGENT_DIR 临时目录,避免跨文件 env 覆盖
- session-folder-drafts 的 CustomEvent 桩透传 init,恢复真实构造器
- FileViewer.state 通过 createRequire 加载 react-syntax-highlighter,
  与 jiti 的 CJS 通道一致,避免 realm 内重复加载
- terminal-manager 用命名管道探针检测 ConPTY 沙盒并跳过 PTY 测试
- worktree/pi-web-options/project-command-env 增加 PI_WEB_TEST_NO_SPAWN
  跳过开关;directory-browser/subagent-input 跳过需符号链接权限的用例
- useAgentSession/ChatInput 等源码正则断言适配 CRLF 与本地 UI 保留

验证:node --experimental-strip-types --test --test-isolation=none
全部 1031 项测试 1014 通过 / 0 失败 / 17 项沙盒环境跳过;
tsc --noEmit 无错误。
sleepinginsummer pushed a commit to sleepinginsummer/pi-web that referenced this pull request Sep 9, 2026
* fix(chat): restore session reading positions

* fix(chat): handle cancelled scroll restoration and collapsed details

---------

Co-authored-by: Alex Yang <agegcn@gmail.com>
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