Skip to content

A Pulse Link Carries Its Destination, and One Table Delivers It - #654

Merged
Dharp02 merged 3 commits into
mainfrom
feat/pulse-destinations
Oct 7, 2026
Merged

Dharp02 merged 3 commits into
mainfrom
feat/pulse-destinations

Conversation

@morepriyam

@morepriyam morepriyam commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Stage 1 of landing #615 in pieces on top of 0.5.0 (#644). This one is the foundation the Huddle, Clock and timesheet destinations will build on, and it changes nothing a person sees.

pulsevault.reserve now takes { destination }: { kind: 'library' }, or { kind: 'ticket' | 'redmine', id }. The destination is checked, then signed into the capability token's context, which PulseVault stores with the upload and hands back to onUploadComplete. There is still no reservation table.

Delivery moves to meteor-backend/server/pulse-destinations.js, shaped like pulsevault's examples/meteor-demo: one DESTINATIONS entry per kind, with check (run at reserve, and again at delivery) and deliver (idempotent on the video id, since PulseVault replays a completion it never saw recorded).

Changes

  • pulse-destinations.js (new): library, ticket, redmine. resolvePulseDestination for the reserve; deliverPulseVideo for the completion, returning { state: 'done', note } or { state: 'kept', reason }.
  • pulsevault.js: attachUploadedVideo and the inline reserve branches are gone. onUploadComplete is three lines: describe the video, deliver, record the outcome. The attachment title stays Video <id8>.
  • Kept, not thrown: a destination that is gone at delivery — not-found (ticket deleted, Redmine issue gone) or forbidden (the uploader left the team) — is recorded kept with the reason. Before, a forbidden at delivery would have been replayed every five minutes forever. Anything else (Redmine unreachable, a write failed) still throws, so PulseVault replays it.
  • pulsevault.reserveForLibrary removed: the library is a destination kind. Its five callers (videoApi.reserve({ kind: 'library' })) and the Wormhole schema are updated; existingVideoid is unchanged.
  • Tests: attachments.test.ts uses the new shape and no longer asserts on the pulsevault_reservations collection chore(pulsevault): upgrade to 0.5.0 #644 removed. New e2e case: a ticket deleted while its video uploads ends kept, with no attachment.

Testing

Local, at this commit, backend on :3101 against a scratch MongoDB replica set with VIDEOS_DIR set, frontend :3002 from the Playwright config:

  • tests/e2e/tickets/pulsevault.spec.ts + huddle/pulsevault-video.spec.ts + huddle/composer-actions.spec.ts: 26 passed, 0 skipped, no retries. That covers the library and ticket destinations end to end (device upload lands as an attachment), the new kept case, and the backend logging kept … Ticket not found — it was gone before the video finished uploading.
  • meteor-backend/tests/attachments.test.ts (Redmine reserve refusal): 5/5.
  • tsc --noEmit, npm run lint (0 errors), npm run format, vitest run src/features/pulse-upload (4/4): clean.

Not run: a Redmine-target upload (no Redmine here; its check is resolveTicketRef, the same call as on main), and an upload from the Pulse app on a phone.

After Copilot's review (208a076):

  • Each kind has delivered(destination, video) next to check and deliver, asked first: a replay of a delivery whose outcome never got recorded returns the same done, whatever has become of the destination since.
  • destinationOf in pulsevault.js reads a token minted by the previous reserve ({ target, ticketId }, chore(pulsevault): upgrade to 0.5.0 #644, deployed to DEV) as a destination, for the 30 minutes such a token stays valid. Marked for removal after that window.
  • An unknown kind in a context settles as kept instead of throwing from the hook.
  • Re-run: tickets/pulsevault.spec.ts 15 passed, huddle/pulsevault-video.spec.ts 2 passed, attachments.test.ts 5/5, lint and Prettier clean.

After Copilot's review of 208a076 (3cf1a60): the draft-name title is dropped so this stage stays invisible to people; it returns with the Huddle stage and its release note.

Next

Stage 2 is one Pulse button (usePulseUpload with no detached watcher), then the Huddle, Clock and timesheet destinations as one small PR each, then removing raw video uploads. #615 and #616 stay open as the reference until the stack lands.

…vers it

`pulsevault.reserve` takes `{ destination }` — `{ kind: 'library' }`, or
`{ kind: 'ticket' | 'redmine', id }` — checks it, and signs it into the
capability token's context. `onUploadComplete` hands that context to
`pulse-destinations.js`, where each kind is one entry: `check` runs at
reserve and again at delivery, `deliver` is idempotent on the video id.

A destination that is gone by delivery (the ticket deleted, the uploader
out of its team) is recorded `kept` with the reason instead of attaching
to nothing; anything else still throws, so PulseVault replays it.

`pulsevault.reserveForLibrary` folds into `reserve`: the library is a
destination kind. The attachment title is the Pulse draft's name when one
was sent.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Legacy in-flight uploads can be discarded, and replay may record kept after delivery already succeeded.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity

Open (2)
What changed in this PR

Introduces destination-aware Pulse uploads and centralized backend delivery.

Changes:

  • Replaces library-specific reservation with { destination }.
  • Adds idempotent library, ticket, and Redmine delivery handling.
  • Adds coverage for deleted-ticket delivery outcomes.
File Description
tests/​e2e/​tickets/​pulsevault.spec.ts Updates reservation contracts and tests kept delivery.
src/​lib/​api.ts Defines destinations and updates the reservation API.
src/​features/​pulse-upload/​PulseUploadButton.tsx Reserves ticket and Redmine destinations.
src/​features/​profile/​ProfileFeed.tsx Uses the library destination.
src/​features/​huddle/​PulseAttachButton.tsx Uses the library destination.
src/​features/​huddle/​api.ts Updates video upload reservation.
src/​features/​clock/​TimesheetJustificationFields.tsx Updates justification-video reservation.
meteor-backend/​tests/​attachments.test.ts Updates Redmine reservation coverage.
meteor-backend/​server/​pulsevault.js Delegates completion delivery by destination.
meteor-backend/​server/​pulsevault-docs.js Updates reservation documentation.
meteor-backend/​server/​pulse-destinations.js Implements destination checks and delivery.
meteor-backend/​server/​main.js Updates the exposed Wormhole schema.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread meteor-backend/server/pulsevault.js Resolved
@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

🗑️ Preview Environment Cleaned Up

The preview container for this PR has been deleted.

…tination token still lands

Each destination kind now says whether this video was already delivered
(`delivered`) before anything is checked, so a replay after the outcome
went unrecorded gets the same `done` as the first time even if the ticket
has since been deleted or the uploader has left the team.

A token minted by the previous `reserve` carries `{ target, ticketId }`
in its context rather than `destination`; `destinationOf` reads both for
the thirty-minute window in which such an upload can still complete or be
replayed. An unknown kind settles as `kept` instead of throwing from the
hook, which would have replayed it every five minutes.
Copilot AI balanced review requested due to automatic review settings October 6, 2026 15:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

The user-visible Pulse title change requires a release-note entry under the repository’s documented policy.

Review effort: Balanced
Findings: None

Resolved since last review (2)
Previously missed (1)

In code that hasn't changed since last review

Low severity Add release note for Pulse video title change

meteor-backend/​server/​pulsevault.js:135

This changes the visible title of Pulse videos from Video <id> to the draft name (for example, ProfileFeed renders item.title), but the PR adds no release-note entry. The repository requires every user-visible change to ship in release-notes/ (release-notes/README.md:10-12); please add this behavior to the current version's note.

Copilot AI balanced review requested due to automatic review settings October 6, 2026 18:32
@morepriyam

Copy link
Copy Markdown
Collaborator Author

Reply to the "previously missed" finding in Copilot's review of 208a076 (it has no review thread). Add release note for Pulse video title change: the title change is gone in 3cf1a60 — describeVideo keeps Video <id8> as on main, so this stage changes nothing a person sees and needs no note. Using the Pulse draft's name is part of the Huddle stage, where it becomes the post's text, and ships with that release note.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

The critical replay-before-revalidation behavior lacks regression coverage.

Review effort: Balanced
Findings: None

Previously missed (1)

In code that hasn't changed since last review

Medium severity Add regression test for replay-before-revalidation attachment handling

meteor-backend/​server/​pulse-destinations.js:168

The replay-before-revalidation behavior has no automated regression coverage. The current e2e case only exercises an undelivered ticket becoming not-found; it would still pass if these lines were reordered and a successfully attached upload were later recorded as kept after deletion or membership loss. Add a case that delivers once, leaves the PulseVault completion unacknowledged, removes access/the destination, replays completion, and asserts the outcome remains done with one attachment.

@Dharp02 Dharp02 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good. I checked these: old { target, ticketId } links still map through destinationOf; redelivery is safe because delivered runs before the access check; the token only carries kind plus what the server-side check returns; prototype names like constructor are rejected as kinds; Redmine errors other than not-found still throw so the upload is retried; nothing still calls reserveForLibrary. One small wording issue is commented inline.

await kind.check(userId, destination);
} catch (err) {
if (err instanceof Meteor.Error && (err.error === 'not-found' || err.error === 'forbidden')) {
return { state: 'kept', reason: `${err.reason} — it was gone before the video finished uploading.` };

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit: this suffix also gets added when err.error === 'forbidden', for example when the uploader was removed from the ticket's team mid-upload. The ticket still exists in that case, so "it was gone before the video finished uploading" is wrong. Use a different suffix for forbidden (e.g. "you no longer have access to it"), or just show err.reason alone.

@Dharp02
Dharp02 merged commit 1f72f28 into main Oct 7, 2026
9 checks passed
morepriyam added a commit that referenced this pull request Oct 7, 2026
Two conflicts: release-notes/1.0.6.md, where main had started the 1.0.6 note with the
confetti and App Store changes and this branch had started it with Pulse (1.0.6 is not
tagged, so the two become one note with both), and the Playwright import line in
tests/e2e/tickets/helpers.ts, which now takes APIRequestContext, Page and Route.
@morepriyam
morepriyam deleted the feat/pulse-destinations branch November 16, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants