Skip to content

fix(settings): keep edits made while a channel save is in flight - #36102

Merged
RohanK6 merged 1 commit into
mainfrom
crew/conductor/r53-channel-save-keeps-edits
Nov 13, 2026
Merged

RohanK6 merged 1 commit into
mainfrom
crew/conductor/r53-channel-save-keeps-edits

Conversation

@RohanK6

@RohanK6 RohanK6 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: An edit made in the Telegram, Discord, Teams or Webex settings while a save is still running survives that save.

Every field stays editable during a save; only the Save button waits. On success the panels re-armed their draft sync and invalidated the config query. When the refetch came back changed (a channel that just connected, say), the sync effect rebuilt the draft from the server and dropped the newer edit, under a "Saved" notice. A save that verifies a pasted token against the provider can take several seconds, which is plenty of time to edit another field.

Why it matters

The user sees "Saved" and a form that quietly reverted the change they made during the save (an allow-list entry, a toggle), and nothing marks it as unsaved, so they believe it was stored.

Not a goal

What changed (motivation → approach → change)

Symptom: in-flight edits lost after "Saved". Root cause: onSuccess re-armed the one-shot draft sync, so the next changed refetch reseeded the draft. IMessagePanel.tsx already avoids this on purpose. Change, in BotChannelPanel.tsx (Telegram, Discord), TeamsPanel.tsx and WebexPanel.tsx:

  • The sync stays one-shot: only the initial load seeds the draft.
  • Only the secrets just sent are cleared, and only while their field still holds what was sent (read from a ref, so the value at success time is used, not the value at request time).
  • The secret fields remount back to their stored preview only when no newer credential edit is pending in them, so a replacement typed during the save stays visible.
  • What the reseed did that is still wanted is kept: Teams blanks the sent App ID (masked once stored), and a blank session-folder name shows the channel name it was saved as (only when that fallback is what was sent, so a folder cleared during the save stays cleared).
  • A secret field holding a value typed during the save stays in its editor, including on a first save, where the refetch turns the field from unset to stored.

Backwards compatibility

Compatible: every save sends the same payload as on main; only what the form shows after a successful save changes.

Removes nothing: no field, key or setting changes.

Tests

  • website/src/test/SettingsBotChannelPanelCov80.test.tsx: an allow-list entry added during the save stays after the refetched (connected) config renders; a replacement token typed during the save stays on screen.
  • website/src/test/SettingsTeamsPanelCov80.test.tsx: a Tenant ID edited during the save stays after the refetched (active) config renders, and the sent password is cleared.
  • website/src/test/SettingsWebexPanelCoverage.test.tsx: an address added during the save stays after the refetched (active) config renders. A folder name cleared during a save of a named folder stays blank, and a token typed during the first token save stays in its editor.

Proof: not provable -- frontend test (prove.py runs Python only). Checked by hand: each new test fails against the main-branch panel.

Manual verification

Captured with a local Playwright harness (not part of this PR) that mounts the real TelegramPanel, holds the save open, adds an allow-list entry, then lets the save succeed with the channel now connected. It asserts whether the entry survives before writing each frame.

Screenshots / video

Telegram settings (the shared BotChannelPanel), English. A save is started, an allow-list entry (222222222) is added while it runs, then the save succeeds and the channel connects.

Before (main), while the save runs, then after "Saved." — the entry added during the save is gone:

before: entry added during the save

before: after Saved, the entry is gone

After (this PR), the same two moments — the entry is still there after "Saved.":

after: entry added during the save

after: after Saved, the entry stays

Related Issues

Fixes #36099
Deferred: #36100

Sibling sweep

Swept: git grep -n "syncArmed.current = true" -- website/src/pages/settings
Sibling: website/src/pages/settings/BotChannelPanel.tsx -- changed here
Sibling: website/src/pages/settings/TeamsPanel.tsx -- changed here
Sibling: website/src/pages/settings/WebexPanel.tsx -- changed here
Sibling: website/src/pages/settings/SlackPanel.tsx -- tracked in #36100

Pattern harvest

Rule candidate: review-prompt
Pattern: a settings form that re-arms its server-to-draft sync in a mutation's onSuccess discards edits made while the request was in flight.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributed under the project's Apache-2.0 license.

@RohanK6
RohanK6 requested review from a team and KiroCrewCaptain as code owners November 12, 2026 21:35
@RohanK6
RohanK6 requested a review from mbriones98 November 12, 2026 21:35
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 12, 2026
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 3d9549719e189a7bc06b65ab805568164a827f5d — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. The one-shot sync matches what IMessagePanel already does, rendered evidence of this revision is present, and the change can be reverted cleanly.

Notes

  • The draft no longer re-syncs after a save, so onSuccess has to copy each change the server makes to a saved value by hand: the folder-name fallback and the masked Teams App ID. If the server starts changing any other field, the form will show the old value until reload. A simpler approach would be to record the draft that was sent and, when the refetch arrives, reseed only the fields still equal to what was sent. That would replace the per-field special cases in all three panels.
  • SlackPanel.tsx keeps the old behaviour until Slack settings: a save throws away edits made while it was running #36100 lands. If the Slack fix copies this per-field pattern, it adds a fourth copy of the same onSuccess logic, so the shared logic should get one owner first.

[DESIGN-REVIEWED] 3d95497

Description read

[DESCRIPTION-READ] 716960f69c4f7ed8e6d369ba7cd1e428d0ff392eb71f9cfc382852074df99f7c

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 3d9549719e189a7bc06b65ab805568164a827f5d — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing to check. The PR adds no new controls or strings. The before and after screenshots show the edit made during the save still there after "Saved.", and the blind reader saw it that way too.

[UX-REVIEWED] 3d95497

Description read

[DESCRIPTION-READ] d2317cac01f1e74d8e22b3a09a2c47f551e3cfc41745891d7cfac2ea7843653e

That sha256 names everything this verdict read: the PR description, plus the 7 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 3d9549719e189a7bc06b65ab805568164a827f5d — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. Every item exists to stop the onSuccess reseed from dropping edits made during a save, and the one unfixed sibling (Slack) is deferred to #36100.

What this change ships

Inventory (6 items) — 6 justified

Intent: a user's edit made while a channel save runs survives the save. FIX (#36099).

  1. Telegram/Discord/Teams/Webex: non-secret fields edited during a save survive the post-save refetch — justified
  2. After a save, a secret field is emptied only if it still holds the value that was sent — justified
  3. A secret field folds back to its stored preview only when no newer credential edit is waiting in it — justified
  4. A secret field holding a value typed during the save stays open in its editor after the refetch — justified
  5. Teams: the App ID just sent is blanked after saving, as the old reseed did — justified
  6. A blank session-folder field shows the channel name it was saved as, unless the user cleared it during the save — justified

[FIRST-PRINCIPLES-REVIEWED] 3d95497

Description read

[DESCRIPTION-READ] 3d0e909f3cd7de8bbfba3b61b87250e6f4a0227e3424ab1b1fd66861714bdcb1

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 3d9549719e189a7bc06b65ab805568164a827f5d — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 3d95497

Verdict parsed from the review's SHA-scoped output markers for commit 3d9549719e189a7bc06b65ab805568164a827f5d.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 3d9549719e189a7bc06b65ab805568164a827f5d false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 3d9549719e189a7bc06b65ab805568164a827f5d and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 3d95497

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 3d9549719e189a7bc06b65ab805568164a827f5d false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 12, 2026
The Telegram, Discord, Teams and Webex panels re-armed their draft
sync after every successful save. The save's invalidation refetched the
config, and when it came back changed (a channel that just connected,
say) the sync effect rebuilt the draft from the server and dropped any
field the user had edited while the request was running, under a
"Saved" notice. Like the iMessage panel, they now leave the draft
authoritative after the initial load and clear only the secret they
just sent, and only while its field still holds that value.

Fixes #36099
@RohanK6
RohanK6 force-pushed the crew/conductor/r53-channel-save-keeps-edits branch from d1cea51 to 3d95497 Compare November 12, 2026 22:58
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 12, 2026
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: the decider estimates a 12% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes.

The fix achieves its goal in Telegram, Discord, Teams and Webex. The form now fills from the server only on first load, so edits made during a save survive the refetch, matching what IMessagePanel already does. A secret field is cleared after a save only if it still holds the value that was sent, read from a ref at the moment the save lands. The secret fields remount to their stored preview only when no newer edit is pending, and the controlled editing prop on SecretField keeps a value typed during a first save in its editor. What the old reseed did that is still wanted is preserved explicitly: Teams blanks the App ID it sent, which keeps the 'omit blank app_id' rule safe, and a blank folder shows the channel-name fallback only when that fallback is what was sent. This resolves the earlier-revision GPT finding. Save payloads are unchanged, and nothing compares the draft with server data in a way that would drift. New tests cover the main path in each panel. The CI failures are rate-limit and skipped-job infrastructure failures, not results about the code.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit 3d9549719e · 199 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Nov 12, 2026
@RohanK6
RohanK6 enabled auto-merge (squash) November 13, 2026 09:00

@bolichen97 bolichen97 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.

I read the whole diff on this head. Every check is green. The five cancelled runs from 2026-11-12 22:58 each have a newer passing run on this head.

  • The root cause is fixed the same way in all three panels (BotChannelPanel for Telegram and Discord, Teams, Webex). A save's onSuccess no longer re-arms the draft sync, so the invalidation refetch cannot reseed the form over fields edited while the save was in flight.
  • Secrets are cleared only if the field still holds exactly what was sent. They are read through a ref, so onSuccess sees the value as it is when the save lands. The secret field collapses back to its preview (formKey bump) only when no newer edit or clear is pending, and editing keeps a pending value open after the refetch reports a stored credential.
  • The two things the old reseed did on purpose are kept by hand: the Teams App ID is blanked after it was sent, unless it was edited, and a blank folder name shows the channel name it was saved as, unless it was cleared after a named folder was sent.
  • The tests cover an allow-list entry, a tenant ID, a cleared folder name and a replacement token, each edited during a pending save.
  • This is frontend state only. It adds no refusal and no regex.

Approving. Auto-merge is already armed by its holder, so I leave it as is.

@RohanK6
RohanK6 merged commit 1d03b69 into main Nov 13, 2026
138 of 153 checks passed
@RohanK6
RohanK6 deleted the crew/conductor/r53-channel-save-keeps-edits branch November 13, 2026 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Channel settings: a save throws away edits made while it was running (Telegram, Discord, Teams, Webex)

3 participants