Skip to content

fix(ui): label system-injected maintenance prompts as System#26469

Open
pdonizete wants to merge 6 commits intoopenclaw:mainfrom
pdonizete:fix/26461-system-injected-chat-label
Open

fix(ui): label system-injected maintenance prompts as System#26469
pdonizete wants to merge 6 commits intoopenclaw:mainfrom
pdonizete:fix/26461-system-injected-chat-label

Conversation

@pdonizete
Copy link

@pdonizete pdonizete commented Feb 25, 2026

Summary

Fixes Gateway Chat UI labeling for system-injected maintenance prompts that were shown as "You".

What changed

  • Detect heartbeat/post-compaction injected maintenance prompt text in chat message normalization.
  • Reclassify only those injected prompts from user to system for UI rendering.
  • Add explicit sender label resolution so system renders as System.
  • Add tests for:
    • heartbeat prompt normalization to system
    • post-compaction audit normalization to system
    • normal user message remains user
    • sender label mapping for system

Why

Issue #26461 reports that users mistake system-injected messages for real user messages, causing false security alarms.

Scope

UI normalization/rendering + tests only.

Fixes #26461.

Greptile Summary

Reclassified system-injected maintenance prompts (heartbeat and post-compaction audit messages) from user to system role for correct UI rendering with System label.

  • Added detection logic in message-normalizer.ts for heartbeat prompts via Provider field and text prefix patterns
  • Extracted resolveSenderLabel helper to map roles to display labels (system → "System")
  • Added system avatar rendering with "S" initial
  • Comprehensive test coverage for heartbeat, post-compaction, and normal user messages

Confidence Score: 4/5

  • Safe to merge with minor test coverage improvement recommended
  • Implementation correctly addresses the security concern of mislabeled system messages. Logic is sound with pattern matching for heartbeat/compaction prompts. Test coverage is good but missing one test case for the tool role in resolveSenderLabel. The fix is UI-only with no runtime behavior changes.
  • No files require special attention - consider adding tool role test case to ui/src/ui/chat/grouped-render.test.ts

Last reviewed commit: b60269a

(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

4 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +5 to +17
describe("resolveSenderLabel", () => {
it("labels user role as You", () => {
expect(resolveSenderLabel("user", "Assistant")).toBe("You");
});

it("labels assistant role with assistant name", () => {
expect(resolveSenderLabel("assistant", "Codex")).toBe("Codex");
});

it("labels system role as System", () => {
expect(resolveSenderLabel("system", "Assistant")).toBe("System");
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

missing test coverage for tool role

Suggested change
describe("resolveSenderLabel", () => {
it("labels user role as You", () => {
expect(resolveSenderLabel("user", "Assistant")).toBe("You");
});
it("labels assistant role with assistant name", () => {
expect(resolveSenderLabel("assistant", "Codex")).toBe("Codex");
});
it("labels system role as System", () => {
expect(resolveSenderLabel("system", "Assistant")).toBe("System");
});
});
describe("resolveSenderLabel", () => {
it("labels user role as You", () => {
expect(resolveSenderLabel("user", "Assistant")).toBe("You");
});
it("labels assistant role with assistant name", () => {
expect(resolveSenderLabel("assistant", "Codex")).toBe("Codex");
});
it("labels system role as System", () => {
expect(resolveSenderLabel("system", "Assistant")).toBe("System");
});
it("labels tool role as Tool", () => {
expect(resolveSenderLabel("tool", "Assistant")).toBe("Tool");
});
});
Prompt To Fix With AI
This is a comment left during a code review.
Path: ui/src/ui/chat/grouped-render.test.ts
Line: 5-17

Comment:
missing test coverage for `tool` role

```suggestion
  describe("resolveSenderLabel", () => {
    it("labels user role as You", () => {
      expect(resolveSenderLabel("user", "Assistant")).toBe("You");
    });

    it("labels assistant role with assistant name", () => {
      expect(resolveSenderLabel("assistant", "Codex")).toBe("Codex");
    });

    it("labels system role as System", () => {
      expect(resolveSenderLabel("system", "Assistant")).toBe("System");
    });

    it("labels tool role as Tool", () => {
      expect(resolveSenderLabel("tool", "Assistant")).toBe("Tool");
    });
  });
```

How can I resolve this? If you propose a fix, please make it concise.

@pdonizete
Copy link
Author

Thanks for the review — addressed in follow-up commit 993bf0e:

  • added test coverage for resolveSenderLabel("tool", ...)
  • applied formatting cleanup in touched chat files to satisfy CI format check

@pdonizete
Copy link
Author

All feedback addressed (tool label test + formatting). Ready for maintainer review.

@openclaw-barnacle
Copy link

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle bot added the stale Marked as stale due to inactivity label Mar 3, 2026
@openclaw-barnacle openclaw-barnacle bot removed the stale Marked as stale due to inactivity label Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Gateway Chat UI displays system-injected messages (Post-Compaction Audit, Heartbeat) as "You"

1 participant