mirror of
https://github.com/NanmiCoder/claude-code-haha.git
synced 2026-10-10 03:43:11 +08:00
feat(im): resume project session history (#1286)
Add shared project and session selection across IM adapters, preserve bindings on failed restoration, and synchronize permissions with desktop clients. Fixes #1286
This commit is contained in:
@@ -16,6 +16,7 @@ The chat partner is a bot or account you bound yourself. Messages reach your loc
|
||||
## What you get
|
||||
|
||||
- **The same session, continued.** Messages sent from your phone enter the Claude Code session on your computer, where file edits, commands, and reads really happen.
|
||||
- **Resume history.** `/sessions` lists history in the current project; `/sessions <project name or absolute path>` opens another project. Use `/resume <number>` to continue, including sessions created on Desktop.
|
||||
- **Project switching.** `/projects` lists recent projects and switches to the one you pick; `/new` starts a fresh session.
|
||||
- **Permission approval.** When Claude wants to write a file or run a risky command, the request is pushed to the chat. Feishu and DingTalk send interactive cards, Telegram sends buttons, and every other platform expects a text reply.
|
||||
- **Status and stop.** `/status` reports the current project, model, and run state; `/stop` interrupts the current turn.
|
||||
@@ -63,6 +64,16 @@ Paired accounts appear under **Paired Users**, where **Unbind** revokes one of t
|
||||
|
||||
Later messages in the same chat reuse that session, and the mapping survives a Desktop restart. `/new` changes the directory; `/clear` empties the context while keeping the project binding.
|
||||
|
||||
## Find an old session from your phone
|
||||
|
||||
Send `/sessions` to list history for your current project. Without a session binding, it starts with a project picker. Use `/sessions projects` to choose a different project, or `/sessions <project name or absolute path>` to open one directly. Ambiguous names show a list to choose from.
|
||||
|
||||
Each page shows eight sessions with their title, update time, message count, and a marker for the current session. Reply with a number shown on that page or send `/resume <number>` to continue the selected conversation. Use `/sessions next` and `/sessions prev` to turn pages. Accessible worktree sessions are grouped under their project and resume in their original working directory.
|
||||
|
||||
Browsing preserves the current binding. `/cancel` exits selection; ordinary chat text also leaves the history picker and continues your current conversation. Lists expire after 15 minutes. Finish pending approvals or send `/stop` and wait for the current turn to stop before switching. If a session was deleted, its directory is unavailable, or connecting fails, the original binding is retained.
|
||||
|
||||
Telegram also keeps its `/resume` project and session button menu. The text commands above work on all platforms.
|
||||
|
||||
## Common commands
|
||||
|
||||
Entry points differ slightly per platform — Feishu can expose commands as a bot menu — but these work everywhere:
|
||||
@@ -71,6 +82,9 @@ Entry points differ slightly per platform — Feishu can expose commands as a bo
|
||||
- `/status` — current project, model, and run state
|
||||
- `/projects` — list recent projects and switch
|
||||
- `/new` — start a new session, optionally with a project number or path
|
||||
- `/sessions [project]` — list old sessions; `/sessions projects` chooses another project
|
||||
- `/resume <number>` — continue a session from the list
|
||||
- `/cancel` — exit selection and keep the current session
|
||||
- `/clear` — clear context, keep the project binding
|
||||
- `/stop` — stop the current generation
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ order: 0
|
||||
## 接进来之后能做什么
|
||||
|
||||
- **接着聊同一条会话**:手机上发的消息进的是本机的 Claude Code 会话,改文件、跑命令、读代码都在你电脑上真实发生。
|
||||
- **恢复旧会话**:发 `/sessions` 查看当前项目的历史,或 `/sessions <项目名或绝对路径>` 找到其他项目,再用 `/resume <编号>` 接着聊。桌面端创建的会话也能选。
|
||||
- **换项目**:发 `/projects` 列出最近用过的项目,回复编号或路径就切过去;`/new` 直接开一条新会话。
|
||||
- **批权限**:Claude 要写文件或执行高风险命令时,会把请求推到 IM 里。飞书和钉钉是可点的卡片,Telegram 是按钮,其余平台回复一条文本命令。
|
||||
- **看状态、叫停**:`/status` 看当前项目、模型和运行状态,`/stop` 中断正在跑的这一轮。
|
||||
@@ -63,6 +64,16 @@ order: 0
|
||||
|
||||
同一个 IM 聊天窗口后续的消息会复用同一条会话,桌面端重启后也能接回去。想换目录发 `/new`,想清空上下文但保留项目发 `/clear`。
|
||||
|
||||
## 在手机上找回旧会话
|
||||
|
||||
发 `/sessions` 查看当前绑定项目的历史。如果还没有绑定会话,会先显示项目列表;已经绑定时,也可以发 `/sessions projects` 选择其他项目。发 `/sessions <项目名或绝对路径>` 可以直接查看指定项目,重名项目会列出来让你选。
|
||||
|
||||
会话列表显示标题、更新时间、消息数和当前会话标记,每页 8 条。回复当前页的编号,或发 `/resume <编号>`,之后的消息就会继续那条旧会话。用 `/sessions next` 和 `/sessions prev` 翻页。列表包含同一项目下可访问的 worktree 会话,选中后仍在原工作目录继续。
|
||||
|
||||
查看列表不会打断当前会话;发 `/cancel` 退出选择,直接发普通聊天文字也会退出历史选择并继续当前对话。列表 15 分钟后过期,需要重新查询。会话正在生成或等待审批时,请先处理审批或 `/stop`,等停止后再切换。旧会话已删除、目录已移除或无法连接时,原来的绑定会保留。
|
||||
|
||||
Telegram 还保留 `/resume` 的项目、会话按钮菜单;各平台都支持上面的文本命令。
|
||||
|
||||
## 允许访问的项目目录决定它能碰哪些项目
|
||||
|
||||
「默认项目」只决定新会话开在哪,**不是**访问边界。真正的边界是「允许访问的项目目录」:机器人只能列出、打开并在这些目录内的项目里开会话,`/projects`、`/sessions` 和按名字、绝对路径选项目都受它约束。
|
||||
@@ -98,6 +109,9 @@ order: 0
|
||||
- `/status` — 当前项目、模型、运行状态
|
||||
- `/projects` — 列出最近项目并切换
|
||||
- `/new` — 开一条新会话,可带项目编号或路径
|
||||
- `/sessions [项目]` — 查看旧会话;`/sessions projects` 选择其他项目
|
||||
- `/resume <编号>` — 继续列表中的旧会话
|
||||
- `/cancel` — 退出选择,保留当前会话
|
||||
- `/clear` — 清空上下文,保留项目绑定
|
||||
- `/stop` — 停止本轮生成
|
||||
|
||||
|
||||
Reference in New Issue
Block a user