Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions apps/presentation/dashboard/smoke/delegation-read-cancel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,9 @@ for (const storage of ["file", "sqlite"]) {
const row = [...document.querySelectorAll(".personal-message.is-assistant")].at(-1)!;
const answer = row.querySelector(".personal-md > p")!.getBoundingClientRect();
const delivery = row.querySelector(".personal-return-delivery")!.getBoundingClientRect();
return answer.top >= viewport.top && answer.bottom <= viewport.bottom
&& delivery.top >= viewport.top && delivery.bottom <= viewport.bottom;
const toolbar = document.querySelector(".personal-conversation-find")!.getBoundingClientRect();
return answer.top >= Math.max(viewport.top, toolbar.bottom) && answer.bottom <= viewport.bottom
&& delivery.top >= Math.max(viewport.top, toolbar.bottom) && delivery.bottom <= viewport.bottom;
}).catch(async error => {
console.error(JSON.stringify(await page.evaluate(() => ({
viewport: document.querySelector(".personal-channel-scroll")?.getBoundingClientRect().toJSON(),
Expand All @@ -217,6 +218,33 @@ for (const storage of ["file", "sqlite"]) {
await returned.getByRole("link", {name: /单独阅读完整答复|Read full answer separately/}).scrollIntoViewIfNeeded();
assert.ok(await returned.getByText("还需核验安装包中的字段映射和失败恢复。", {exact: true}).isVisible());
}
// Reading older content remains a reader choice when native history grows.
// Exercise a real wheel event, then append through the existing store owner.
const scroller = page.locator(".personal-channel-scroll");
await page.waitForFunction(() => {
const node = document.querySelector(".personal-channel-scroll")!;
return node.scrollHeight - node.scrollTop - node.clientHeight < 2;
});
const bottom = await scroller.evaluate(node => node.scrollTop);
await scroller.hover();
await page.mouse.wheel(0, -400);
await page.waitForFunction(previous => document.querySelector(".personal-channel-scroll")!.scrollTop < previous - 100, bottom);
const readingTop = await scroller.evaluate(node => node.scrollTop);
assert.equal(await scroller.evaluate(node => getComputedStyle(node).overflowAnchor), "auto");
await fixture("conversation-arrival");
await page.getByText("新的委派阅读测试消息。", {exact: true}).waitFor();
await page.evaluate(() => new Promise<void>(resolve => requestAnimationFrame(() => requestAnimationFrame(() => resolve()))));
assert.ok(Math.abs(await scroller.evaluate(node => node.scrollTop) - readingTop) < 2,
"New native history must not take over an explicit older-message reading position");
await page.getByRole("button", {name: /回到最新消息|Latest message/}).click();
await page.waitForFunction(() => {
const node = document.querySelector(".personal-channel-scroll")!;
return node.scrollHeight - node.scrollTop - node.clientHeight < 2;
});
assert.equal(await scroller.evaluate(node => getComputedStyle(node).overflowAnchor), "none");
await page.getByRole("button", {name: /^(总览|Overview)$/}).click();
assert.equal(await scroller.evaluate(node => getComputedStyle(node).overflowAnchor), "auto",
"The conversation's anchor ownership does not change overview scrolling");
// Switching steward views keeps the existing conversation connection.
// Reading a returned answer neither resumes the Session nor starts a Turn.
assert.deepEqual(writes, reloadWrites);
Expand All @@ -226,7 +254,7 @@ for (const storage of ["file", "sqlite"]) {
assert.deepEqual(errors, []);
results.push({storage, requests: 61, originalBodyChars: [...body].length, sourceUnchanged: true,
initial: true, filterRetry: true, staleSearch: true, more: true, multiWindow: true, sourceRecovery: true,
returnedAnswerStart: true, completeReaderBody: true, inventoryWrites: 0, reloadSessionResumes: reloadWrites.length, readerTurnsStarted: 0});
returnedAnswerStart: true, completeReaderBody: true, manualReadingPreserved: true, inventoryWrites: 0, reloadSessionResumes: reloadWrites.length, readerTurnsStarted: 0});
} finally {
// Release before shutdown: cancelled clients do not stop server work.
child.stdin.write("release\nstop\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ export function returnedAnswerStart(scroller: HTMLElement): {key: string; top: n
const row = Array.from(scroller.querySelectorAll<HTMLElement>(".personal-message")).at(-1);
if (row?.dataset.returnedAnswer !== "true" || !row.dataset.messageSession || !row.dataset.messageId
|| row.getBoundingClientRect().height <= scroller.clientHeight) return null;
const viewport = scroller.getBoundingClientRect();
const toolbar = scroller.querySelector<HTMLElement>(".personal-conversation-find")?.getBoundingClientRect();
// The sticky Find control must not cover the return status or first answer.
const readingTop = Math.max(viewport.top, toolbar?.bottom ?? viewport.top);
return {key: JSON.stringify([row.dataset.messageSession, row.dataset.messageId]),
top: Math.max(0, scroller.scrollTop + row.getBoundingClientRect().top - scroller.getBoundingClientRect().top)};
top: Math.max(0, scroller.scrollTop + row.getBoundingClientRect().top - readingTop)};
}

/** Folding is an explicit reading choice after the initial historical snapshot. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,11 @@ export function PersonalWorkspacePage({
const composerRef = useRef<HTMLTextAreaElement>(null);
const channelScrollRef = useRef<HTMLDivElement>(null);
const followConversationRef = useRef(true);
const [followingConversation, setFollowingConversation] = useState(true);
const setConversationFollowing = useCallback((following: boolean) => {
followConversationRef.current = following;
setFollowingConversation(following);
}, []);
const readReturnRef = useRef<string | undefined>(undefined);
const conversationScrollTopRef = useRef(0);
const [showLatestMessage, setShowLatestMessage] = useState(false);
Expand Down Expand Up @@ -1470,7 +1475,7 @@ export function PersonalWorkspacePage({
}, [timelineKey, goalDraftTargetChanged]);
const conversationOpen = (!agentWorkActive || managedWorkActive) && (selectedGoal ? selectedGoalTab === "chat" : managerChatOpen);
const boundHistory = Boolean(originalConversation);
const onReadTimelineMessage = useCallback(() => { followConversationRef.current = false; }, []);
const onReadTimelineMessage = useCallback(() => { setConversationFollowing(false); }, [setConversationFollowing]);
const historyPositionScope = JSON.stringify([selectionScope, conversationKey, selectedAgentId,
conversationMessageFocus?.sessionId, conversationMessageFocus?.messageId]);
const [positionedHistoryScope, setPositionedHistoryScope] = useState<string | null>(null);
Expand All @@ -1485,7 +1490,7 @@ export function PersonalWorkspacePage({
const latestMessage = managerMessages.at(-1);
const latestMessageTextLength = latestMessage?.text.length ?? 0;
function scrollToLatestMessage() {
followConversationRef.current = true;
setConversationFollowing(true);
setShowLatestMessage(false);
const scroller = channelScrollRef.current;
if (scroller) {
Expand All @@ -1499,15 +1504,15 @@ export function PersonalWorkspacePage({
const start = scroller ? returnedAnswerStart(scroller) : null;
if (!scroller || !start || start.key === readReturnRef.current) return false;
readReturnRef.current = start.key;
followConversationRef.current = false;
setConversationFollowing(false);
scroller.scrollTop = start.top;
conversationScrollTopRef.current = scroller.scrollTop;
setShowLatestMessage(false);
return true;
}
useLayoutEffect(() => {
readReturnRef.current = undefined;
followConversationRef.current = !conversationMessageFocus;
setConversationFollowing(!conversationMessageFocus);
conversationScrollTopRef.current = channelScrollRef.current?.scrollTop ?? 0;
setPositionedHistoryScope(null);
setShowLatestMessage(false);
Expand Down Expand Up @@ -1540,7 +1545,7 @@ export function PersonalWorkspacePage({
const readQuote = (event: Event) => {
const details = event.target;
if (!(details instanceof HTMLDetailsElement) || !details.open || !details.classList.contains("conversation-reply-context")) return;
followConversationRef.current = false;
setConversationFollowing(false);
window.cancelAnimationFrame(frame);
frame = window.requestAnimationFrame(() => details.querySelector("summary")?.scrollIntoView({block: "nearest"}));
};
Expand Down Expand Up @@ -2615,7 +2620,7 @@ export function PersonalWorkspacePage({
return;
}
if (sending) return;
followConversationRef.current = true;
setConversationFollowing(true);
setShowLatestMessage(false);
if (loopxMode?.session_id === conversationSessionId && loopxMode?.enabled && loopxMode.active_turn_id && conversationSessionId) {
if (pendingImages.length) {
Expand Down Expand Up @@ -3068,13 +3073,17 @@ export function PersonalWorkspacePage({
onExecute={(operation, settings) => callbacks.onStartLoopX?.(operation, selectedAgentId, selectedGoalId, settings)}
/> : null}
<div className="personal-channel-scroll" data-agent-work={agentWorkActive && !managedWorkActive || undefined} data-active-goal-view={selectedGoal ? selectedGoalTab : undefined} ref={channelScrollRef}
// The app owns return/latest anchoring while following. Browser
// anchoring can otherwise look like an upward reader scroll when
// native history grows. Restore native anchoring while reading.
style={conversationOpen && followingConversation ? {overflowAnchor: "none"} : undefined}
onScroll={(event) => {
if (!conversationOpen) return;
const { scrollHeight, scrollTop, clientHeight } = event.currentTarget;
const nearBottom = scrollHeight - scrollTop - clientHeight < 64;
// Growing content or a shorter viewport is not a reader moving up.
if (nearBottom) followConversationRef.current = true;
else if (scrollTop < conversationScrollTopRef.current) followConversationRef.current = false;
if (nearBottom) setConversationFollowing(true);
else if (scrollTop < conversationScrollTopRef.current) setConversationFollowing(false);
conversationScrollTopRef.current = scrollTop;
setShowLatestMessage(!nearBottom);
}}>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions docs/guides/personal-workspace-user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,22 @@ The local Chat HTTP read is `GET /api/chat/delivery-review?goal_id=example-goal`
Lark continues using its existing Goal Channel projection; this slice adds no
Lark card or notification and does not qualify cross-channel presentation parity.

### 阅读返回的长答复 / Read a completed long answer

当最后一条消息是已完成的长答复时,重新打开对话会从其送达状态和正文开头显示,避开固定的
「查找对话」工具栏。向上滚动阅读旧内容后,新消息不会强制把你拉回底部;点击
**回到最新消息**可恢复跟随。答复末尾的 **单独阅读完整答复** 可打开独立阅读页。
这些阅读操作不会启动新的 Turn,也不会把“已送达”变成结果已通过验收。

English: When the last message is a completed long return, reopening the
conversation positions its delivery status and opening paragraph below the fixed Find control. Scroll
up to read older content without new messages pulling you to the bottom; choose
**Latest message** to follow again. **Read full answer separately** at the end of
the answer opens its reader. Reading starts no new Turn, and delivery does not
mean the result passed acceptance.

<img src="../assets/personal-workspace/returned-answer-reading.png" alt="Synthetic completed answer: delivery status and opening paragraph remain visible below Find on a narrow screen" width="390" />

### 查找先前的要求和答复 / Find earlier instructions and answers

在管家或 Goal 的**对话**中点击 **查找对话 / Find in conversation**,输入原消息中的
Expand Down
Loading