Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3dc6bb8

Browse filesBrowse files
authored
feat(session-stream): enhance approval request handling and message state updates (MoonshotAI#910)
1 parent 295217a commit 3dc6bb8
Copy full SHA for 3dc6bb8

6 files changed

+101-8Lines changed: 101 additions & 8 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎CHANGELOG.md‎

Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Only write entries that are worth mentioning to users.
1111

1212
## Unreleased
1313

14+
- Web: Fix approval request states not updating when session is interrupted or cancelled
1415
## 1.8.0 (2026-02-05)
1516

1617
- CLI: Fix startup errors (e.g. invalid config files) being silently swallowed instead of displayed
Collapse file

‎docs/en/reference/kimi-web.md‎

Copy file name to clipboardExpand all lines: docs/en/reference/kimi-web.md
+2-2Lines changed: 2 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ Web UI provides a convenient session management interface:
168168

169169
- **Session list**: View all historical sessions, including session title and working directory
170170
- **Session search**: Quickly filter sessions by title or working directory
171-
- **Create session**: Create a new session with a specified working directory
171+
- **Create session**: Create a new session with a specified working directory; if the specified path doesn't exist, you will be prompted to confirm creating the directory
172172
- **Switch session**: Switch to different sessions with one click
173173

174174
::: info Added
175-
Session search feature added in version 1.5.
175+
Session search feature added in version 1.5. Directory auto-creation prompt added in version 1.7.
176176
:::
177177

178178
### Git status bar
Collapse file

‎docs/en/release-notes/changelog.md‎

Copy file name to clipboardExpand all lines: docs/en/release-notes/changelog.md
+1Lines changed: 1 addition & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ This page documents the changes in each Kimi Code CLI release.
44

55
## Unreleased
66

7+
- Web: Fix approval request states not updating when session is interrupted or cancelled
78
## 1.8.0 (2026-02-05)
89

910
- CLI: Fix startup errors (e.g. invalid config files) being silently swallowed instead of displayed
Collapse file

‎docs/zh/reference/kimi-web.md‎

Copy file name to clipboardExpand all lines: docs/zh/reference/kimi-web.md
+2-2Lines changed: 2 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ Web UI 提供了便捷的会话管理界面:
168168

169169
- **会话列表**:查看所有历史会话,包括会话标题和工作目录
170170
- **会话搜索**:通过标题或工作目录快速筛选会话
171-
- **创建会话**:指定工作目录创建新会话
171+
- **创建会话**:指定工作目录创建新会话;如果指定的路径不存在,会提示确认是否创建目录
172172
- **切换会话**:一键切换到不同的会话
173173

174174
::: info 新增
175-
会话搜索功能新增于 1.5 版本。
175+
会话搜索功能新增于 1.5 版本。目录自动创建提示新增于 1.7 版本。
176176
:::
177177

178178
### Git 状态栏
Collapse file

‎docs/zh/release-notes/changelog.md‎

Copy file name to clipboardExpand all lines: docs/zh/release-notes/changelog.md
+1Lines changed: 1 addition & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
## 未发布
66

7+
- Web:修复会话中断或取消时审批请求状态未更新的问题
78
## 1.8.0 (2026-02-05)
89

910
- CLI:修复启动错误(如无效的配置文件)被静默吞掉而不显示的问题
Collapse file

‎web/src/hooks/useSessionStream.ts‎

Copy file name to clipboardExpand all lines: web/src/hooks/useSessionStream.ts
+94-4Lines changed: 94 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,10 +1237,39 @@ export function useSessionStream(
12371237
}
12381238

12391239
case "StepInterrupted": {
1240+
// Clear pending approval requests
1241+
pendingApprovalRequestsRef.current.clear();
1242+
12401243
setMessages((prev) =>
1241-
prev.map((msg) =>
1242-
msg.isStreaming ? { ...msg, isStreaming: false } : msg,
1243-
),
1244+
prev.map((msg) => {
1245+
let updated = msg;
1246+
if (msg.isStreaming) {
1247+
updated = { ...updated, isStreaming: false };
1248+
}
1249+
// Update pending approval tool states to denied
1250+
if (
1251+
msg.variant === "tool" &&
1252+
msg.toolCall?.state === "approval-requested"
1253+
) {
1254+
return {
1255+
...updated,
1256+
toolCall: {
1257+
...msg.toolCall,
1258+
state: "output-denied",
1259+
approval: msg.toolCall.approval
1260+
? {
1261+
...msg.toolCall.approval,
1262+
submitted: true,
1263+
resolved: true,
1264+
approved: false,
1265+
response: "reject",
1266+
}
1267+
: undefined,
1268+
},
1269+
};
1270+
}
1271+
return updated;
1272+
}),
12441273
);
12451274
setAwaitingFirstResponse(false);
12461275
if (awaitingIdleRef.current) {
@@ -1734,10 +1763,71 @@ export function useSessionStream(
17341763
);
17351764
awaitingIdleRef.current = false;
17361765
pendingMessageRef.current = null;
1766+
// Clear pending approval requests and update message states
1767+
pendingApprovalRequestsRef.current.clear();
1768+
setMessages((prev) =>
1769+
prev.map((msg) => {
1770+
if (
1771+
msg.variant === "tool" &&
1772+
msg.toolCall?.state === "approval-requested"
1773+
) {
1774+
return {
1775+
...msg,
1776+
isStreaming: false,
1777+
toolCall: {
1778+
...msg.toolCall,
1779+
state: "output-denied",
1780+
approval: msg.toolCall.approval
1781+
? {
1782+
...msg.toolCall.approval,
1783+
submitted: true,
1784+
resolved: true,
1785+
approved: false,
1786+
response: "reject",
1787+
}
1788+
: undefined,
1789+
},
1790+
};
1791+
}
1792+
return msg;
1793+
}),
1794+
);
17371795
disconnect();
17381796
return;
17391797
}
17401798

1799+
// Clear all pending approval requests and update message states
1800+
pendingApprovalRequestsRef.current.clear();
1801+
1802+
// Always update messages (consistent with StepInterrupted handler)
1803+
setMessages((prev) =>
1804+
prev.map((msg) => {
1805+
if (
1806+
msg.variant === "tool" &&
1807+
msg.toolCall?.state === "approval-requested"
1808+
) {
1809+
return {
1810+
...msg,
1811+
isStreaming: false,
1812+
toolCall: {
1813+
...msg.toolCall,
1814+
state: "output-denied",
1815+
approval: msg.toolCall.approval
1816+
? {
1817+
...msg.toolCall.approval,
1818+
submitted: true,
1819+
resolved: true,
1820+
approved: false,
1821+
response: "reject",
1822+
}
1823+
: undefined,
1824+
},
1825+
};
1826+
}
1827+
return msg;
1828+
}),
1829+
);
1830+
17411831
const cancelMessage: JsonRpcRequest = {
17421832
jsonrpc: "2.0",
17431833
method: "cancel",
@@ -1756,7 +1846,7 @@ export function useSessionStream(
17561846
} catch (err) {
17571847
console.error("[SessionStream] Failed to send cancel request:", err);
17581848
}
1759-
}, [status, disconnect, setAwaitingFirstResponse]);
1849+
}, [status, disconnect, setAwaitingFirstResponse, setMessages]);
17601850

17611851
// Reconnect
17621852
const reconnect = useCallback(() => {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.