Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): 入口纠正改为整个期间只认自身落点,离开后返回不再被拉走

Dash9034bf9340cf
diff --git a/apps/desktop/src/renderer/features/bots/__tests__/botSessionOwners.test.ts b/apps/desktop/src/renderer/features/bots/__tests__/botSessionOwners.test.ts
index 0427d6eda8..13a3ae9fd5 100644
--- a/apps/desktop/src/renderer/features/bots/__tests__/botSessionOwners.test.ts
+++ b/apps/desktop/src/renderer/features/bots/__tests__/botSessionOwners.test.ts
@@ -312,6 +312,29 @@ describe('通知入口在伙伴投影未加载时的路由', () => {
expect(isOrdinaryLatest()).toBe(false);
});
+ it('离开后又回到普通页也算去过别处:不再拉回伙伴页,也不处置', async () => {
+ const { open, openBotRoute, consumeAlert, resolve } = setup();
+ open.locationCommitted('/cc-agent/new');
+ open('s-lane', undefined, 'entry-3');
+ open.locationCommitted('/cc-agent/s-lane');
+ open.locationCommitted('/elsewhere');
+ open.locationCommitted('/cc-agent/s-lane');
+ resolve(lane);
+ await Promise.resolve();
+ expect(openBotRoute).not.toHaveBeenCalled();
+ expect(consumeAlert).not.toHaveBeenCalled();
+ });
+
+ it('普通页导航因投影已更新直接落到伙伴页时,照常处置这次点击', async () => {
+ const { open, consumeAlert, resolve } = setup();
+ open.locationCommitted('/cc-agent/new');
+ open('s-lane', undefined, 'entry-4');
+ open.locationCommitted('/bots/groups/g-1');
+ resolve(lane);
+ await Promise.resolve();
+ expect(consumeAlert).toHaveBeenCalledExactlyOnceWith('s-lane', 'entry-4');
+ });
+
it('用户已去了别处时不再拉回伙伴页,也不处置', async () => {
const { open, openBotRoute, consumeAlert, resolve } = setup();
open.locationCommitted('/cc-agent/new');
diff --git a/apps/desktop/src/renderer/features/bots/botSessionOwners.ts b/apps/desktop/src/renderer/features/bots/botSessionOwners.ts
index 6e3a404ca6..a8ffce3f40 100644
--- a/apps/desktop/src/renderer/features/bots/botSessionOwners.ts
+++ b/apps/desktop/src/renderer/features/bots/botSessionOwners.ts
@@ -171,7 +171,10 @@ export function createSessionEntryNavigator(
): SessionEntryNavigator {
let sequence = 0;
let committedPath: string | null = null;
- let commitCount = 0;
+ // Every location committed since the latest entry opened; a correction is valid only while
+ // all of them are the entry's own landing (ordinary page or the Bot target), so leaving and
+ // coming back never counts as "stayed".
+ let committedSinceOpen = new Set<string>();
let pending: { entry: number; sessionId: string; islandEntryId: string; route: string } | null = null;
const openBotTarget = (entry: number, sessionId: string, target: BotSessionEntryTarget, disposalId: string | undefined) => {
if (target.consumesAlert && disposalId) {
@@ -191,7 +194,7 @@ export function createSessionEntryNavigator(
const open = (sessionId: string, messageClientId?: string, islandEntryId?: string) => {
const entry = ++sequence;
pending = null;
- const commitsAtOpen = commitCount;
+ committedSinceOpen = new Set();
const isLatest = () => sequence === entry;
const known = deps.readKnownBotRoute(sessionId);
// Background tasks keep their ordinary page with message anchors and visible-session reporting.
@@ -205,8 +208,11 @@ export function createSessionEntryNavigator(
const ordinaryRoute = `/cc-agent/${encodeURIComponent(sessionId)}`;
void deps.resolveBotRoute(sessionId).then((target) => {
if (!isLatest() || !target || target.route.startsWith('/cc-agent/')) return;
- // Correct only this entry's own landing; any other committed location means the user moved on.
- if (commitCount !== commitsAtOpen && committedPath !== ordinaryRoute) return;
+ // Correct only this entry's own landing: the ordinary page, or the Bot page the ordinary
+ // path already resolved to. Any other committed location means the user moved on.
+ for (const path of committedSinceOpen) {
+ if (path !== ordinaryRoute && path !== target.route) return;
+ }
movedToBotPage = true;
openBotTarget(entry, sessionId, target, islandEntryId);
});
@@ -214,7 +220,7 @@ export function createSessionEntryNavigator(
return Object.assign(open, {
locationCommitted: (path: string) => {
committedPath = path;
- commitCount += 1;
+ committedSinceOpen.add(path);
const waiting = pending;
if (!waiting) return;
pending = null;
diff --git a/docs/product-rules/cindy-bots-runtime.md b/docs/product-rules/cindy-bots-runtime.md
index 09158fc185..c7d39c81d8 100644
--- a/docs/product-rules/cindy-bots-runtime.md
+++ b/docs/product-rules/cindy-bots-runtime.md
@@ -605,7 +605,7 @@ Session 任务遵守同一套机制与呈现契约:
新的提醒照常出现。处置只清提醒,任务记录、失败状态与错误行不变。主任务仍只由报错横幅处置。
- 通知、灵动岛与任务深链点击立即按内存里的伙伴投影跳转,不等待重读伙伴列表。投影还不认识的任务先
打开普通任务页,同时在后台重读一次投影;若它其实是伙伴的主任务、历史或群专线,再转到对应页面——
- 前提是用户这期间没有去别处。新挂上的伙伴任务因此可能先短暂显示普通任务页,换来普通任务点击即达。
+ 前提是用户这期间没有去过别处(离开后又回来也算)。新挂上的伙伴任务因此可能先短暂显示普通任务页,换来普通任务点击即达。
- iOS 的伙伴正常回复使用系统通信通知:伙伴名字、头像与回复摘要,应用角标由系统绘制。
普通任务、报错和待处理事项保留原通知语义。头像仅携带有界缩略图、内置头像标识或
单个字符,不上传公开头像地址;缺失头像回退名字首字,扩展失败仍交付原通知。