SSE: Emit bom.merged event on BOM merge #46

Closed
opened 2026-02-09 00:17:16 +00:00 by forbes · 0 comments
Owner

Summary

When the BOM merge endpoint (#45) processes a merge, emit an SSE event so connected clients (silo-mod Activity pane, web UI) receive real-time notification of the merge result.

Event Format

{
  "type": "bom.merged",
  "data": {
    "part_number": "ASM-001",
    "user": "joseph",
    "summary": "BOM updated: 1 added, 1 quantity changed, 1 unreferenced",
    "diff": {
      "added": [{"part_number": "PRT-300", "quantity": 1}],
      "removed": [{"part_number": "PRT-400", "quantity": 2}],
      "quantity_changed": [{"part_number": "F01-001", "old_quantity": 8, "new_quantity": 12}],
      "unchanged_count": 2
    },
    "resolve_url": "/items/ASM-001/bom"
  }
}

Implementation

This is a single s.broker.Publish() call at the end of HandleMergeBOM in bom_handlers.go:

s.broker.Publish("bom.merged", mustMarshal(map[string]any{
    "part_number": partNumber,
    "user":        username,
    "summary":     fmt.Sprintf("BOM updated: %d added, %d quantity changed, %d unreferenced",
        len(diff.Added), len(diff.QuantityChanged), len(diff.Removed)),
    "diff":        diff,
    "resolve_url": "/items/" + partNumber + "/bom",
}))

Notes

  • Uses the existing SSE broker infrastructure from PR #40
  • Broker.Publish(eventType string, data string) is the existing method signature
  • The unchanged array is omitted from the SSE payload (replaced with unchanged_count) to keep event size small
  • The silo-mod Activity pane will render this as a merge summary with a "View in Silo" link
  • This is part of the BOM merge endpoint (#45) implementation — listed separately for tracking
## Summary When the BOM merge endpoint (#45) processes a merge, emit an SSE event so connected clients (silo-mod Activity pane, web UI) receive real-time notification of the merge result. ## Event Format ```json { "type": "bom.merged", "data": { "part_number": "ASM-001", "user": "joseph", "summary": "BOM updated: 1 added, 1 quantity changed, 1 unreferenced", "diff": { "added": [{"part_number": "PRT-300", "quantity": 1}], "removed": [{"part_number": "PRT-400", "quantity": 2}], "quantity_changed": [{"part_number": "F01-001", "old_quantity": 8, "new_quantity": 12}], "unchanged_count": 2 }, "resolve_url": "/items/ASM-001/bom" } } ``` ## Implementation This is a single `s.broker.Publish()` call at the end of `HandleMergeBOM` in `bom_handlers.go`: ```go s.broker.Publish("bom.merged", mustMarshal(map[string]any{ "part_number": partNumber, "user": username, "summary": fmt.Sprintf("BOM updated: %d added, %d quantity changed, %d unreferenced", len(diff.Added), len(diff.QuantityChanged), len(diff.Removed)), "diff": diff, "resolve_url": "/items/" + partNumber + "/bom", })) ``` ## Notes - Uses the existing SSE broker infrastructure from PR #40 - `Broker.Publish(eventType string, data string)` is the existing method signature - The `unchanged` array is omitted from the SSE payload (replaced with `unchanged_count`) to keep event size small - The silo-mod Activity pane will render this as a merge summary with a "View in Silo" link - This is part of the BOM merge endpoint (#45) implementation — listed separately for tracking
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kindred/silo#46