Skip to content

feat(desktop): refine session status reminder summaries#446

Open
snowjuly wants to merge 16 commits into
TouchAI-org:mainfrom
snowjuly:reminder-v3
Open

feat(desktop): refine session status reminder summaries#446
snowjuly wants to merge 16 commits into
TouchAI-org:mainfrom
snowjuly:reminder-v3

Conversation

@snowjuly

@snowjuly snowjuly commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

First external contributors may need to complete the CLA Assistant check before merge.
For code changes, this PR must link the related issue or RFC in the section below.

Summary

Refine desktop session status reminder notifications so they read like plain-text summaries instead of raw markdown fragments.

User-facing impact:

  • Completed reminders no longer leak markdown markers such as headings, emphasis, code fences, or table separators.
  • Failed reminders and waiting-for-approval reminders now produce more natural notification copy instead of flat --joined fragments.
  • Existing native/system notification flow and cross-platform reminder transport remain unchanged.

Related issue or RFC

Link the issue or RFC:

For code changes, link the tracking issue. Only documentation wording, link fixes, or comment-only cleanups may skip the issue-first flow.

AI assistance disclosure

If AI tools materially assisted this contribution, disclose that here or point to the relevant commit trailer.

  • Tool(s) used: Codex
  • Scope of assistance: located reminder code paths, implemented notification summary sanitization/formatting updates, added regression tests, ran local verification commands, and built/install-tested the desktop app locally
  • Human review or rewrite performed: reviewed and iterated on the reminder text behavior, adjusted summary rules after manual notification testing, and validated final behavior against local test runs and desktop installation output
  • Architecture or boundary impact: no new abstraction or cross-boundary contract; existing reminder payload shape and native notification transport are unchanged

Testing evidence

List the commands you ran and the results you observed.

  • pnpm --filter desktop exec tsc --noEmit --pretty false — passed
  • pnpm --filter desktop test -- --run tests/services/AgentService/task/center-reminder.test.ts — passed
  • pnpm --filter desktop test -- --run tests/composables/SearchView/useSearchPage.test.ts — passed
  • pnpm --filter desktop test -- --run tests/services/native-service.test.ts — passed
  • pnpm --filter desktop test -- --run tests/services/NotificationService/i18n.test.ts — passed
  • pnpm tauri build — passed
  • Local install/manual verification: built and installed 1.1.1; verified reminder notifications against manual desktop testing flow

Not run locally:

  • pnpm test:pr
  • pnpm test:coverage:rust
  • pnpm test:e2e

Did you follow TDD (test-first) for feature and fix work? Strongly recommended. See docs/testing/testing.md.

pnpm test:pr
pnpm test:coverage:rust
pnpm test:e2e

Risk notes

  • AgentService, runtime, MCP, or schema impact: touches AgentService/task/center.ts reminder text generation only; no payload shape, runtime protocol, MCP, or schema change
  • database baseline or migration impact: none
  • release or packaging impact: desktop package rebuilt and locally installed for manual verification; no packaging config change in this branch

Screenshots or recordings

  • Manual desktop notification verification performed locally

Checklist

  • The PR title follows Conventional Commits and is valid for squash merge.
  • This PR is either ready for review or explicitly marked as a Draft PR.
  • I did not use [WIP] or similar title prefixes.
  • If AI materially assisted this PR, I disclosed the tools and scope and I personally reviewed every affected change.
  • I can explain the why, what, and how of this change without relying on an AI tool.
  • If this touches AgentService, runtime, MCP, or schema boundaries, there is an accepted RFC.
  • If this changes architecture or adds a new cross-boundary abstraction, there is an accepted RFC.
  • I ran pnpm test:pr for this code PR, or this is a docs-only change.
  • If I changed Rust behavior or tests, I reviewed pnpm test:coverage:rust or relied on CI coverage evidence.
  • If I changed desktop startup/window/search/popup/settings/E2E paths, I ran pnpm test:e2e locally or documented why CI is the first valid proof.
  • I added tests or explained why tests are not appropriate.
  • I updated docs when behavior changed.

@github-actions github-actions Bot added the area:agent-service AgentService and conversation runtime changes label Jun 8, 2026
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Replaces whitespace-based reminder summarization with a locale-aware, markdown/HTML-to-plain-text pipeline (summarizeNotificationText) and applies it to completed, waiting-approval, waiting-user-question, and failed session reminders; tests validate sanitization, command previews, and edge cases.

Changes

Notification text sanitization pipeline

Layer / File(s) Summary
Markdown sanitization pipeline infrastructure
apps/desktop/src/services/AgentService/task/center.ts
Adds getLocale import, reminder-formatting constants/types (max chars, escape/path patterns), ReminderTextMode enum, and initializes reminderMarkdownParser for dedicated reminder parsing.
Preprocessing, clause extraction, and joining
apps/desktop/src/services/AgentService/task/center.ts
Implements locale-aware text truncation, separator/punctuation helpers, path-like token protection, HTML-to-text stripping, typography normalization (typographic quotes → ASCII), markdown token flattening, clause generation (tables/code blocks), deduplication, mode-specific joining rules, and summarizeNotificationText orchestration.
Reminder builders integration
apps/desktop/src/services/AgentService/task/center.ts
Completed assistant-history uses summarizeNotificationText(..., 'summary'). Waiting-approval summarizes reason/description/title in natural mode, generates a command-mode preview from approval.command, and conditionally appends a labeled truncated command fragment. Waiting-user-question summarizes only the first pending question in natural mode (falls back if empty). Failed-task error bodies use summarizeNotificationText(snapshot.error).
Test coverage: completed-task reminders
apps/desktop/tests/services/AgentService/task/center-reminder.test.ts
Validates completed-task reminders sanitize and flatten assistant markdown (including escaped markdown), markdown tables, and markdown-heavy completion output into readable plain-text notification bodies.
Test coverage: failed-task reminders
apps/desktop/tests/services/AgentService/task/center-reminder.test.ts
Validates failed-task reminders convert error markdown into sanitized plain-text failure messages and preserve bracketed log prefixes (e.g., [ERROR]: ...) without stripping them as markdown constructs.
Test coverage: waiting-approval reminders
apps/desktop/tests/services/AgentService/task/center-reminder.test.ts
Validates waiting-approval reminders sanitize markdown in approval details while preserving non-markdown tokens (path/glob patterns, scoped package markers like @scope/package, Windows paths with escaped backslashes, shell pipeline syntax) and producing readable single-line command previews.

Sequence Diagram

sequenceDiagram
  participant Caller
  participant summarizeNotificationText
  participant reminderMarkdownParser
  Caller->>summarizeNotificationText: request(text, mode, locale)
  summarizeNotificationText->>summarizeNotificationText: normalize text & protect paths
  summarizeNotificationText->>reminderMarkdownParser: parse markdown/HTML tokens
  summarizeNotificationText->>summarizeNotificationText: extract clauses, dedupe
  summarizeNotificationText->>summarizeNotificationText: join with mode-aware separators
  summarizeNotificationText->>summarizeNotificationText: truncate to max chars
  summarizeNotificationText->>Caller: return sanitized plain-text summary
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • TouchAI-org/TouchAI#314: Modifies related session-status reminder logic in apps/desktop/src/services/AgentService/task/center.ts.
  • TouchAI-org/TouchAI#217: Modifies session status reminder construction in the same file, with earlier whitespace-based summarization replaced by markdown-aware clause flattening.

Suggested reviewers

  • hiqiancheng

Poem

🐰 I hopped through markdown, unknotted every tag and fence,
Clauses stitched by locale, trimmed with careful sense,
Paths and pipes kept whole, tables flattened neat,
Reminders now speak plain and tidy in the feed,
A rabbit nods, delighted — copyable and sweet.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 73.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Title 'feat(desktop): refine session status reminder summaries' follows Conventional Commits with appropriate prefix and scope, accurately describes the core change of improving reminder text formatting.
Description check ✅ Passed Description covers summary, related issue, AI disclosure, testing evidence, risk notes, and checklist; however, some checklist items remain unchecked including RFC validation and not running full test suite.
Linked Issues check ✅ Passed Changes fully address issue #437 objectives: convert markdown formatting in session status reminders to plain-text summaries without modifying payload shape, runtime, or schema.
Out of Scope Changes check ✅ Passed All changes are scoped to reminder text generation in AgentService/task/center.ts and corresponding test coverage; no unrelated modifications to runtime, schema, or cross-boundary contracts.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot requested a review from hiqiancheng June 8, 2026 16:44
@coderabbitai coderabbitai Bot added the area:frontend Frontend UI or view-layer changes label Jun 8, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 8, 2026
@hiqiancheng

Copy link
Copy Markdown
Collaborator

Is this solution secure and stable enough? I might lean more towards using an existing Markdown library for parsing

Comment thread apps/desktop/src/services/AgentService/task/center.ts Fixed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/desktop/src/services/AgentService/task/center.ts`:
- Around line 51-66: extractReminderInlineText currently assumes a non-standard
token.type === 'link' and also has fallback fields (text/raw) while the parser
and markstream-vue use markdown-it tokens; update extractReminderInlineText to
prefer token.content but also recognize and handle markdown-it link_open and
link_close tokens by recursing into token.children (or the tokens between
link_open/link_close) to extract inner text, rather than only checking for type
'link' or text/raw fields; reference ReminderMarkdownToken,
extractReminderInlineText, and token types 'link', 'link_open', 'link_close'
when locating and updating the logic.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 2d74536f-d945-4769-a9ac-15a47578260d

📥 Commits

Reviewing files that changed from the base of the PR and between 44eb615 and 804cfe2.

📒 Files selected for processing (1)
  • apps/desktop/src/services/AgentService/task/center.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Frontend Quality
  • GitHub Check: Rust Checks
  • GitHub Check: Frontend Tests
  • GitHub Check: CodeQL (rust)
  • GitHub Check: CodeQL (javascript-typescript)
  • GitHub Check: Desktop E2E Smoke (Windows)
🔇 Additional comments (7)
apps/desktop/src/services/AgentService/task/center.ts (7)

3-4: LGTM!


95-126: LGTM!


127-172: LGTM!


174-228: LGTM!


230-323: LGTM!


325-426: LGTM!


428-481: LGTM!

Comment thread apps/desktop/src/services/AgentService/task/center.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/desktop/src/services/AgentService/task/center.ts`:
- Around line 135-156: The regexes inside isReminderPathLikeToken are rebuilt on
every call; hoist pathSegment and the five RegExp instances
(posixRelativePattern, windowsRelativePattern, posixAbsolutePattern,
windowsAbsolutePattern, windowsUncPattern) to module scope as constants
(alongside REMINDER_PATH_WRAPPER_TRIM_PATTERN) and have isReminderPathLikeToken
reuse those precompiled patterns, preserving the same test logic and return
conditions; ensure the module-scope patterns use the same string templates so
behavior remains identical.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 4a6bacf5-9969-4fac-a3dd-232ac1ac2507

📥 Commits

Reviewing files that changed from the base of the PR and between 804cfe2 and 7308d85.

📒 Files selected for processing (2)
  • apps/desktop/src/services/AgentService/task/center.ts
  • apps/desktop/tests/services/AgentService/task/center-reminder.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Rust Checks
  • GitHub Check: Frontend Quality
  • GitHub Check: Frontend Tests
  • GitHub Check: CodeQL (javascript-typescript)
  • GitHub Check: CodeQL (rust)
  • GitHub Check: Desktop E2E Smoke (Windows)
🧰 Additional context used
🪛 ast-grep (0.43.0)
apps/desktop/src/services/AgentService/task/center.ts

[warning] 138-138: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(^(?:${pathSegment}/)+${pathSegment}$)
Note: [CWE-1333] Inefficient Regular Expression Complexity

(regexp-from-variable)


[warning] 139-139: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(^(?:${pathSegment}\\\\)+${pathSegment}$)
Note: [CWE-1333] Inefficient Regular Expression Complexity

(regexp-from-variable)


[warning] 140-142: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(
^(?:/|\\.{1,2}/|~/)(?:${pathSegment}/)*${pathSegment}$
)
Note: [CWE-1333] Inefficient Regular Expression Complexity

(regexp-from-variable)


[warning] 143-145: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(
^(?:[A-Za-z]:\\\\|\\.{1,2}\\\\|~\\\\)(?:${pathSegment}\\\\)*${pathSegment}$
)
Note: [CWE-1333] Inefficient Regular Expression Complexity

(regexp-from-variable)


[warning] 146-146: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(^\\\\\\\\${pathSegment}(?:\\\\${pathSegment})+$)
Note: [CWE-1333] Inefficient Regular Expression Complexity

(regexp-from-variable)

🔇 Additional comments (7)
apps/desktop/tests/services/AgentService/task/center-reminder.test.ts (1)

218-250: LGTM!

apps/desktop/src/services/AgentService/task/center.ts (6)

1-69: LGTM!


158-202: LGTM!


204-224: LGTM!


249-257: LGTM!


276-482: LGTM!


484-600: LGTM!

Comment thread apps/desktop/src/services/AgentService/task/center.ts Outdated
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 9, 2026
Comment thread apps/desktop/src/services/AgentService/task/center.ts Outdated
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 14, 2026
Comment thread apps/desktop/src/utils/reminderText.ts Fixed
Comment thread apps/desktop/src/utils/reminderText.ts Fixed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent-service AgentService and conversation runtime changes area:frontend Frontend UI or view-layer changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Optimize system notification content

3 participants