-
Notifications
You must be signed in to change notification settings - Fork 961
[codex] add context to v2 macOS notifications #4614
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
7f19311
77dd3e7
0b5d832
727e2e4
d203239
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 |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import { describe, expect, it } from "bun:test"; | ||
| import type { AgentLifecyclePayload } from "@superset/workspace-client"; | ||
| import { getV2NativeNotificationContent } from "./notificationContent"; | ||
|
|
||
| function payload( | ||
| overrides: Partial<AgentLifecyclePayload>, | ||
| ): AgentLifecyclePayload { | ||
| return { | ||
| eventType: "Stop", | ||
| terminalId: "terminal-1", | ||
| occurredAt: 1, | ||
| ...overrides, | ||
| }; | ||
| } | ||
|
|
||
| describe("getV2NativeNotificationContent", () => { | ||
| it("uses the agent label in the title and workspace label in the body", () => { | ||
| expect( | ||
| getV2NativeNotificationContent({ | ||
| workspaceName: "Improve notifications", | ||
| payload: payload({ | ||
| agent: { agentId: "codex", sessionId: "session-1" }, | ||
| }), | ||
| }), | ||
| ).toEqual({ | ||
| title: "Codex - Complete", | ||
| body: "Improve notifications", | ||
| }); | ||
| }); | ||
|
|
||
| it("uses needs-attention copy for permission requests", () => { | ||
| expect( | ||
| getV2NativeNotificationContent({ | ||
| workspaceName: "Improve notifications", | ||
| payload: payload({ | ||
| eventType: "PermissionRequest", | ||
| agent: { agentId: "claude" }, | ||
| }), | ||
| }), | ||
| ).toMatchObject({ | ||
| title: "Claude - Needs Attention", | ||
| body: "Improve notifications", | ||
| }); | ||
| }); | ||
|
|
||
| it("falls back to generic labels", () => { | ||
| expect( | ||
| getV2NativeNotificationContent({ | ||
| workspaceName: " ", | ||
| payload: payload({ agent: { agentId: "droid" } }), | ||
| }), | ||
| ).toEqual({ | ||
| title: "Droid - Complete", | ||
| body: "Workspace", | ||
| }); | ||
|
|
||
| expect( | ||
| getV2NativeNotificationContent({ | ||
| workspaceName: "", | ||
| payload: payload({ agent: undefined }), | ||
| }), | ||
| ).toMatchObject({ | ||
| title: "Agent - Complete", | ||
| body: "Workspace", | ||
| }); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,53 @@ | ||||||||||
| import { | ||||||||||
| BUILTIN_AGENT_LABELS, | ||||||||||
| type BuiltinAgentId, | ||||||||||
| } from "@superset/shared/agent-catalog"; | ||||||||||
| import type { | ||||||||||
| AgentIdentity, | ||||||||||
| AgentLifecyclePayload, | ||||||||||
| } from "@superset/workspace-client"; | ||||||||||
|
|
||||||||||
| interface V2NativeNotificationContentOptions { | ||||||||||
| workspaceName: string; | ||||||||||
| payload: AgentLifecyclePayload; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| export function getV2NativeNotificationContent({ | ||||||||||
| workspaceName, | ||||||||||
| payload, | ||||||||||
| }: V2NativeNotificationContentOptions): { title: string; body: string } { | ||||||||||
| const agentLabel = getAgentLabel(payload.agent); | ||||||||||
| const action = | ||||||||||
| payload.eventType === "PermissionRequest" ? "Needs Attention" : "Complete"; | ||||||||||
| const workspaceLabel = cleanLabel(workspaceName) ?? "Workspace"; | ||||||||||
|
|
||||||||||
| return { | ||||||||||
| title: `${agentLabel} - ${action}`, | ||||||||||
| body: workspaceLabel, | ||||||||||
| }; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| function getAgentLabel(agent: AgentIdentity | undefined): string { | ||||||||||
| const agentId = cleanLabel(agent?.agentId); | ||||||||||
| if (!agentId) return "Agent"; | ||||||||||
| if (agentId in BUILTIN_AGENT_LABELS) { | ||||||||||
| return BUILTIN_AGENT_LABELS[agentId as BuiltinAgentId]; | ||||||||||
|
Comment on lines
+33
to
+34
Contributor
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. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Verify BUILTIN_AGENT_LABELS declaration and whether it uses a null-prototype map.
rg -n -C3 "BUILTIN_AGENT_LABELS"
# Verify AgentIdentity/agentId typing or validation constraints upstream.
rg -n -C3 "interface AgentIdentity|type AgentIdentity|agentId"Repository: superset-sh/superset Length of output: 50379 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Find cleanLabel function definition
rg -A 10 "function cleanLabel|const cleanLabel|export.*cleanLabel" apps/desktop/src/renderer/routes/_authenticated/components/V2NotificationController/lib/notificationContent.ts
# Show the full function context in notificationContent.ts
rg -B 5 -A 15 "function getAgentLabel" apps/desktop/src/renderer/routes/_authenticated/components/V2NotificationController/lib/notificationContent.tsRepository: superset-sh/superset Length of output: 973 Use On line 36, the Proposed fix- if (agentId in BUILTIN_AGENT_LABELS) {
+ if (Object.prototype.hasOwnProperty.call(BUILTIN_AGENT_LABELS, agentId)) {
return BUILTIN_AGENT_LABELS[agentId as BuiltinAgentId];
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| } | ||||||||||
| return humanizeIdentifier(agentId); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| function cleanLabel(value: string | null | undefined): string | null { | ||||||||||
| const trimmed = value?.trim(); | ||||||||||
| return trimmed ? trimmed : null; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| function humanizeIdentifier(value: string): string { | ||||||||||
| const words = value | ||||||||||
| .replace(/^custom:/, "") | ||||||||||
| .split(/[-_:\s]+/) | ||||||||||
| .filter(Boolean); | ||||||||||
| if (words.length === 0) return "Agent"; | ||||||||||
| return words | ||||||||||
| .map((word) => word.charAt(0).toUpperCase() + word.slice(1)) | ||||||||||
| .join(" "); | ||||||||||
| } | ||||||||||
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.
P2: Using a constant fallback label (
"Workspace") removes unique workspace identification for unnamed/unbranched workspaces, making notifications ambiguous.Prompt for AI agents
Tip: Review your code locally with the cubic CLI to iterate faster.