Skip to content

Add an Org-Level Edit Window for Huddle Posts With Edited, Original and Effective Times #797

Open

Description

@Dharp02

Overview

Goal: limit how long a Huddle post can be edited, using an organization setting (default 7 days). Every post should clearly show when it was written, which day it counts for, and when and by whom it was last edited.

Why: Huddle posts are plans, wrap-ups and status updates that teams and managers rely on as a record of work. If a post can be quietly rewritten weeks later, nobody can trust it. Anyone reading a post should be able to tell whether it changed, when, and who changed it.

**Prototypes **

Problem Statement

  1. No edit limit. A post can be edited at any time, even months later.
  2. "Edited" is often wrong. The feed treats a post as edited whenever updatedAt differs from createdAt. But updatedAt also changes when someone likes a post, comments on it, deletes a comment, or adds a wrap-up line. So posts nobody edited show "(edited)", and the edit time shown is really the time of the last like or comment.
  3. Not enough edit information. The "(edited)" tag has no date, and only a time in a hover tooltip, which doesn't work on phones. It never says who made the edit, even though team admins and org owners can edit other people's posts.
  4. Edits go unnoticed. An edited post stays in its old Day or Session conversation. Nobody is told it changed. An @mention added in an edit notifies nobody.
  5. Edit permissions don't match the intended roles. Today the author, team admins and org owners can edit. Org admins can't.

Current State

  • huddle.updatePost (meteor-backend/server/huddle.js) checks only canModifyPost (author, team admin or org owner). There is no time check, and it sends no notifications.

  • Each post stores these times:

    Field What it is Notes
    createdAt Original date and time: when the post was written Server time, an exact moment. Each viewer sees it in their own time zone. Never changes.
    deliverAt / deliveredAt When a scheduled post is due, and when it actually went out Scheduled posts only
    postDate Effective date: the day the post counts for, e.g. "2026-10-28" A calendar date with no time, so it is the same day for every viewer. The app always sets it to the day of posting (or the delivery day for scheduled posts).
    wrapUpAt When the wrap-up line was added to a session's plan post
    clockEventId The clock session the post belongs to Gives the shift's clock-in and clock-out times
    updatedAt Last write of any kind Changed by likes, comments and wrap-ups too, so it can't mean "edited"
  • The feed (src/features/huddle/superChatFeed.ts) works out "edited" as post.updatedAt !== post.createdAt.

  • SuperChat in @mieweb/ui shows an "(edited)" tag with a time-only tooltip. It can only turn editing on or off for the whole chat, not for one message.

  • Org settings already have a cascade (enterprise → org → team, with locks) in meteor-backend/server/settings/registry.js, shown by DefaultsCard in Settings → Organization. Every setting so far is an on/off switch.

  • Notifications (Add Notification Preferences for Desktop and Phone, Starting With Huddle #784) already have a per-team All posts / Mentions & replies / Mute choice. All posts sends "X posted in Team" for new posts (notifyTeamFollowers in huddle-delivery.js).

Proposed Changes

1. Three times on every post

Editing never changes the original time. Each time has one job:

Time Meaning Stored as Shown
Posted When it was written, and by whom createdAt (or deliveredAt) + userId, as today Next to the post, always
Effective The day it counts for postDate, as today. No effective time is stored, because a plan or wrap-up gets its shift times from its clock session (clockEventId) "for Wed, Oct 28", only when it's a different day from the posted date
Edited When it was last changed, and by whom New editedAt + editedBy Next to the post, whenever it was edited

On the post:

Priya Shah   9:02 AM                                            ← not edited
Priya Shah   9:02 AM · edited Thu, Oct 29, 4:15 PM              ← edited by the author
Priya Shah   9:02 AM · edited Thu, Oct 29, 4:15 PM by Sam Lee   ← edited by someone else

Clicking the time (or choosing Post details in the ⋯ menu) shows everything at once:

Posted      Thu, Oct 29, 9:02 AM by Priya Shah
Counts for  Wed, Oct 28              ← only when it differs
Edited      Thu, Oct 29, 4:15 PM by Sam Lee
Editable    Until Thu, Nov 5, 9:02 AM

An edit never moves a post. It stays in the same Day, Session, Person and Ticket conversation, in the same place in the thread, because grouping uses postDate and clockEventId, and ordering uses the original time.

2. Org setting: "Editing posts allowed for"

  • New row in Settings → Organization → Team defaults: a dropdown with Not allowed · 1 hour · 24 hours · 3 days · 7 days (default) · 30 days · No limit.
  • Enterprises and orgs can set it (levels: ['enterprise', 'org'], like allowAutoJoin). Teams can't change it.
  • Personal teams follow the org rule (no exemption).

3. Edit rules

  • Who can edit: the author, team admins, and org admins (org owners count as org admins). Nobody else, including enterprise admins and other members.
  • The limit applies to everyone, including admins. There is no admin override.
  • The window starts when the post goes out: deliveredAt ?? createdAt. A scheduled post that hasn't been sent yet can always be edited.
  • Changing the setting takes effect immediately. The limit is worked out when a post is read or saved, so going from 7 days to 24 hours locks older posts at once, and going back unlocks them. No data migration.
  • The server enforces it. huddle.updatePost refuses a late edit. The app greys out Edit message and shows the reason (e.g. "Editing closed Tue, Oct 27, 9:10 AM").
flowchart TD
  EditRequest["huddle.updatePost"] --> CanModify{"Author, team admin,<br/>or org admin/owner?"}
  CanModify -- no --> Forbidden["forbidden: cannot modify"]
  CanModify -- yes --> Scheduled{"Scheduled and<br/>not sent yet?"}
  Scheduled -- yes --> Save["Save text<br/>set editedAt + editedBy"]
  Scheduled -- no --> Window{"now < wentOut + org window?"}
  Window -- yes --> Save
  Window -- no --> Closed["forbidden: edit window closed"]
  Save --> Notify["notifyPostEdited()"]
  classDef ok fill:#dcfce7,stroke:#15803d,color:#14532d
  classDef stop fill:#fef3c7,stroke:#b45309,color:#78350f
  class Save,Notify ok
  class Forbidden,Closed stop
Loading

4. Notifications for edited posts

Who Notification
The author, when someone else edits their post "Sam Lee edited your post from Mon, Oct 26". Always sent, even if the author chose Mentions & replies or Mute.
Teammates who chose All posts for the team "Priya edited her post from Mon, Oct 26". Skipped for the author's own edits within 5 minutes of posting (typo fixes).
Anyone newly @mentioned by the edit The normal mention notification
Everyone else Nothing

The notification opens the post where it lives, so an edit to an old post can't go unnoticed.

5. How to implement (brief)

Backend (meteor-backend/server/)

  1. huddle.js / huddle.updatePost: set editedAt and editedBy (content edits only), check the edit window, and call notifyPostEdited().
  2. huddle.js / canModifyPost: allow org admin as well as owner.
  3. huddle.js / post enrichment: return editedAt, the editor's name, and editableUntil, all worked out at read time. editableUntil is not stored.
  4. settings/registry.js: add postEditWindow (default '7d', levels enterprise + org). In settings/write.js, add a value type that allows only a fixed list of choices, next to boolean.
  5. notification-prefs-core.js: add a huddlePostEdited event (desktop on, phone off). The Mentions & replies and Mute levels drop it, as they drop huddlePost. Add notifyPostEdited() to huddle-delivery.js.

Frontend (src/)

  1. features/huddle/superChatFeed.ts: use editedAt instead of updatedAt !== createdAt. Pass each message's edit permission (and the reason when it's locked), the edited label, the "for " label and the post details.
  2. features/settings/DefaultsCard.tsx: support a dropdown row, using Select from @mieweb/ui.
  3. features/org/OrganizationSettings.tsx: add the "Editing posts allowed for" row.
  4. Notification settings: a row for "Edited posts".
  5. Release note in release-notes/.

@mieweb/ui (upstream PR via vendor/ui)

  1. Turn editing off for a single message, keeping "Edit message" visible but greyed out with the reason.
  2. Show the edit's date, time and editor inline next to the message time.
  3. A host-supplied details panel on the time label, and an inline label slot for "for Wed, Oct 28". Add these to docs/superchat-inbox-gaps.md.

Suggested PR order: (1) editedAt/editedBy and fix the false "edited" (shippable alone) → (2) @mieweb/ui changes → (3) the setting + server enforcement + org admin permission → (4) Huddle wiring + release note → (5) edit notifications, after the in-progress #784 notification work lands.

Acceptance Criteria

Stored times

  • A content edit sets editedAt and editedBy. Likes, comments, comment deletes, wrap-up appends and session linking don't.
  • createdAt and postDate never change when a post is edited.
  • Posts with no editedAt (including older posts) show no edited label.

Display

  • An edited post shows "· edited <weekday, month day, time>" next to its time, and "by " when the editor isn't the author.
  • A post whose postDate differs from its posted day shows "for <weekday, month day>".
  • Clicking the time (or ⋯ → Post details) shows Posted, Counts for (when different), Edited, and Editable until / closed. This works on phones.
  • Editing a post doesn't move it to another Day, Session, Person or Ticket conversation, or to another place in the thread.

Setting

  • Settings → Organization → Team defaults has "Editing posts allowed for" with the seven choices, defaulting to 7 days.
  • Enterprise and org can set it. Teams can't. "Reset to inherited" works.
  • The server refuses any other value.

Rules

  • The author, team admins, org admins and org owners can edit inside the window. Other members and enterprise admins can't.
  • After the window closes, huddle.updatePost returns forbidden for everyone, including admins.
  • A scheduled post that hasn't been sent can always be edited. Its window starts when it is delivered.
  • "Not allowed" blocks every edit after a post goes out. "No limit" allows edits at any time.
  • Changing the setting changes which existing posts can be edited without a data migration.
  • "Edit message" is greyed out with the reason when the window has closed.

Notifications

  • The author gets a notification when someone else edits their post, regardless of their team notification choice.
  • Teammates on All posts get an "edited" notification. None is sent for the author's own edits within 5 minutes of posting.
  • People newly @mentioned by an edit get a mention notification.
  • Tapping the notification opens the post in its original conversation.
  • "Edited posts" has Desktop/Phone switches in Settings → Notifications (desktop on, phone off by default).

Quality

  • Unit tests for the window check, permissions, the new setting value type and the notification routing.
  • Release note added.
  • npm run lint && npm run typecheck, npm run format and the test suites pass.

Open Questions

  1. Quick-fix grace period: is 5 minutes the right cutoff for not notifying All-posts teammates about the author's own edits? Should it be configurable?
  2. Author alert when muted: we propose always telling the author when someone else edits their post, even if they muted the team. Confirm.

Out of Scope (for Now)

  • A limit on deleting posts. Deleting stays as it is today. A matching setting can follow later.
  • Edit history. Only the most recent edit (when and by whom) is kept.
  • An admin override to edit after the window closes.
  • Comments. The limit covers posts only.
  • Posting for an earlier day (choosing postDate when posting). Posts belong to the day they are written. This would be a separate feature.
  • Per-team edit limits. Teams inherit the org (or enterprise) value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendenhancementui

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions