Repository navigation
feat(v2): draft quiet pod system action line (TASK-406) #2551
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
41e252d
feat(v2): draft quiet task claim system line
lilyshen0722 f3d47df
test(i18n): classify action actor as opaque
lilyshen0722 def4bf0
fix(v2): align system action line with thread artboard
lilyshen0722 a3ec7a2
fix(v2): keep system action avatar above type floor
lilyshen0722 d3381de
fix(v2): preserve system action layout in thread
lilyshen0722 101007c
fix(v2): reserve action text beside long agent names
lilyshen0722 d254470
fix(activity): exclude system action lines before feed limits
lilyshen0722 70e4282
fix(freshness): ignore quiet system action lines
lilyshen0722 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
backend/__tests__/unit/models/pg/message.systemActions.test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| jest.mock('../../../../config/db-pg', () => ({ pool: { query: jest.fn() } })); | ||
| const { pool } = require('../../../../config/db-pg'); | ||
| const Message = require('../../../../models/pg/Message'); | ||
| beforeEach(() => { pool.query.mockReset(); pool.query.mockResolvedValue({ rows: [] }); }); | ||
| test('activity exclusion is an SQL predicate before LIMIT', async () => { | ||
| await Message.findByPodId('pod-1', 1, null, null, { excludeSystemActions: true }); | ||
| const [sql, params] = pool.query.mock.calls[0]; | ||
| expect(sql).toContain("NOT (m.message_type = 'system' AND COALESCE(m.payload->>'kind', '') = 'system-action')"); | ||
| expect(sql.indexOf("= 'system-action'")).toBeLessThan(sql.indexOf('LIMIT')); | ||
| expect(params).toEqual(['pod-1', 1]); | ||
| }); | ||
| test('ordinary pod history still includes system action rows', async () => { | ||
| await Message.findByPodId('pod-1', 1); | ||
| expect(pool.query.mock.calls[0][0]).not.toContain("= 'system-action'"); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
backend/__tests__/unit/services/systemActionLineService.test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| const mockQuery = jest.fn(); | ||
| const mockEmit = jest.fn(); | ||
| const mockTo = jest.fn(() => ({ emit: mockEmit })); | ||
|
|
||
| jest.mock('../../../config/db-pg', () => ({ | ||
| pool: { query: (...args) => mockQuery(...args) }, | ||
| })); | ||
| jest.mock('../../../config/socket', () => ({ | ||
| getIO: () => ({ to: mockTo }), | ||
| })); | ||
|
|
||
| const { emitSystemActionLine } = require('../../../services/systemActionLineService'); | ||
|
|
||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| mockQuery.mockResolvedValue({ rows: [{ id: 42, created_at: '2026-10-23T20:00:00.000Z' }] }); | ||
| }); | ||
|
|
||
| it('persists one structured system row and broadcasts the same line without a wake or pod touch', async () => { | ||
| await emitSystemActionLine({ | ||
| podId: 'pod-1', actorUserId: 'user-1', actorName: 'Forge', | ||
| actorUsername: 'forge-agent', actorAvatarUrl: '/avatars/forge.png', actorIsBot: true, | ||
| action: 'task-claimed', taskId: 'TASK-406', | ||
| }); | ||
|
|
||
| expect(mockQuery).toHaveBeenCalledTimes(1); | ||
| const [sql, params] = mockQuery.mock.calls[0]; | ||
| expect(sql).toContain("'system'"); | ||
| expect(sql).not.toMatch(/UPDATE pods|attention|AgentEvent/i); | ||
| expect(params.slice(0, 3)).toEqual(['pod-1', 'user-1', 'Forge claimed TASK-406']); | ||
| expect(JSON.parse(params[3])).toEqual({ | ||
| kind: 'system-action', action: 'task-claimed', actorName: 'Forge', taskId: 'TASK-406', | ||
| }); | ||
| expect(mockTo).toHaveBeenCalledWith('pod_pod-1'); | ||
| expect(mockEmit).toHaveBeenCalledWith('newMessage', expect.objectContaining({ | ||
| id: '42', messageType: 'system', pod_id: 'pod-1', | ||
| payload: expect.objectContaining({ action: 'task-claimed', taskId: 'TASK-406' }), | ||
| user: expect.objectContaining({ username: 'forge-agent', profile_picture: '/avatars/forge.png', isBot: true }), | ||
| })); | ||
| }); | ||
|
|
||
| it('executes the INSERT and reads the table-generated identity, timestamp and JSON payload back', async () => { | ||
| const { newDb } = require('pg-mem'); | ||
| const db = newDb(); | ||
| db.public.none(`CREATE TABLE messages ( | ||
| id SERIAL PRIMARY KEY, pod_id TEXT NOT NULL, user_id TEXT NOT NULL, | ||
| content TEXT NOT NULL, message_type TEXT NOT NULL, payload JSONB, | ||
| created_at TIMESTAMPTZ NOT NULL DEFAULT now() | ||
| )`); | ||
| const { Pool } = db.adapters.createPg(); | ||
| const pool = new Pool(); | ||
| mockQuery.mockImplementation((sql, params) => pool.query(sql, params)); | ||
| try { | ||
| await emitSystemActionLine({ podId: 'pod-1', actorUserId: 'user-1', actorName: 'Persisted Forge', action: 'task-claimed', taskId: 'TASK-406' }); | ||
| const { rows: [row] } = await pool.query('SELECT * FROM messages'); | ||
| expect(row.id).toBe(1); | ||
| expect(row.created_at).toBeInstanceOf(Date); | ||
| expect(row.message_type).toBe('system'); | ||
| expect(row.payload).toEqual({ kind: 'system-action', action: 'task-claimed', actorName: 'Persisted Forge', taskId: 'TASK-406' }); | ||
| expect(mockEmit).toHaveBeenCalledWith('newMessage', expect.objectContaining({ id: String(row.id), created_at: row.created_at, payload: row.payload })); | ||
| } finally { | ||
| mockQuery.mockReset(); | ||
| await pool.end(); | ||
| } | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Exclude system actions from the activity messages too.
This predicate changes pod ranking, but
getMessageActivitiesstill fetches each ranked pod’s messages and converts system-action rows into feed items. A claim can therefore appear in Activity and increase its unread count. Apply the same exclusion beforegetMessageActivitiesbuilds activities, including before its per-pod fetch limit is spent.🤖 Prompt for AI Agents
Source: Path instructions