Repository navigation
fix(googlechat): keep folded progress when a turn ends without an answer #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ import { resolveWebhookPath } from "openclaw/plugin-sdk/webhook-ingress"; | |
| import type { ResolvedGoogleChatAccount } from "./accounts.js"; | ||
| import { | ||
| deleteGoogleChatMessage, | ||
| updateGoogleChatMessage, | ||
| downloadGoogleChatMedia, | ||
| GoogleChatApiError, | ||
| sendGoogleChatMessage, | ||
|
|
@@ -387,6 +388,10 @@ async function processGoogleChatEvent( | |
| onError: (error) => runtime.error?.(`Google Chat status update failed: ${String(error)}`), | ||
| }) | ||
| : undefined; | ||
| // Progress folded into the activity message stays visible when the turn ends | ||
| // without a separately posted answer, e.g. after handing work to a subagent. | ||
| let foldedProgressText: string | undefined; | ||
| let answerPosted = false; | ||
| const unregisterProgressActivity = | ||
| activity && typingMessage | ||
| ? registerGoogleChatProgressActivity({ | ||
|
|
@@ -407,7 +412,14 @@ async function processGoogleChatEvent( | |
| } | ||
| hooks.assertDirectAdapterHandoff?.(); | ||
| await hooks.onPlatformSendDispatch?.(); | ||
| return await activity.updateText(chunk); | ||
| const updated = await activity.updateText(chunk); | ||
| if (updated) { | ||
| foldedProgressText = chunk; | ||
| } | ||
| return updated; | ||
| }, | ||
| noteSeparatePost: () => { | ||
| answerPosted = true; | ||
| }, | ||
| }) | ||
| : undefined; | ||
|
|
@@ -427,6 +439,18 @@ async function processGoogleChatEvent( | |
| } | ||
| const placeholder = typingMessage; | ||
| typingMessage = undefined; | ||
| if (placeholder && foldedProgressText && !answerPosted) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a final source reply is confirmed through Useful? React with 👍 / 👎. |
||
| try { | ||
| await updateGoogleChatMessage({ | ||
| account, | ||
| messageName: placeholder.name, | ||
| text: foldedProgressText, | ||
| }); | ||
| return; | ||
| } catch (error) { | ||
| runtime.error?.(`Google Chat folded progress restore failed: ${String(error)}`); | ||
| } | ||
| } | ||
| if (placeholder) { | ||
| try { | ||
| await deleteGoogleChatMessage({ account, messageName: placeholder.name }); | ||
|
|
@@ -509,7 +533,13 @@ async function processGoogleChatEvent( | |
| )[0]; | ||
| if (text) { | ||
| try { | ||
| await activity.updateText(text); | ||
| const updated = await activity.updateText(text); | ||
| if ( | ||
| updated && | ||
| (payload.isCommentary === true || payload.isStatusNotice === true) | ||
| ) { | ||
| foldedProgressText = text; | ||
| } | ||
| } catch (error) { | ||
| runtime.error?.(`Google Chat progress update failed: ${String(error)}`); | ||
| } | ||
|
|
@@ -549,6 +579,7 @@ async function processGoogleChatEvent( | |
| !isProgressReply(payload, info?.kind) | ||
| ) { | ||
| hasVisibleAnswer = true; | ||
| answerPosted = true; | ||
| if (resolveReplyThreadName(payload)) { | ||
| hasThreadedReply = true; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a long message-tool answer is chunked and a later
sendGoogleChatMessagecall fails, the handler throws a partial-delivery error after earlier chunks are already visible. This notification runs only after the whole loop succeeds, so the activity is never marked; settlement then preserves folded progress alongside the partial answer. Notify the matching activity before throwing wheneveracceptedTextis nonempty.Useful? React with 👍 / 👎.