Skip to content

fix(config): keep the comments of a key the command removed - #528

Merged
runkids merged 4 commits into
mainfrom
fix/config-keep-removed-key-comments
Oct 11, 2026
Merged

runkids merged 4 commits into
mainfrom
fix/config-keep-removed-key-comments

Conversation

@runkids

@runkids runkids commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Why

#526 kept comments on keys that survive a write. A comment on a key the command removed (for example target remove universal) was still lost. No comment should be dropped (#525).

What

  • copyComments collects the comments of removed mapping keys and list items, including every comment inside the removed subtree, and puts them in front of the next surviving entry. A trailing orphan goes on the last entry's foot comment, since yaml.v3 prints a container's own foot comment after the following key.
  • Tests: removed key's comment leads the next key; removed last key's comment ends the file; removed list item's comment leads the next item.
  • Runbook ai_docs/tests/config_keeps_comments_runbook.md: a config with 11 comments (head, inline, odd spacing, nested, list items, trailing), target set then remove, every comment asserted after each step. 5/5 in a fresh ssenv.

Refs #525

Verification

make check in the devcontainer passes. Runbook 5/5.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T13:46:11.750371Z ffd3e61 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 878be2396f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

setUpdates((prev) => updatesLeft(prev, plan, response));
const failed = failureText(t, response);
const failedTargets = (response.result?.results ?? []).filter((r) => r.status === 'failed').map((r) => r.target);
set(p.name, failed ? { status: 'failed', note: failed, failed: failedTargets.length && failedTargets.length < p.targets.length ? failedTargets : undefined } : { status: 'done', note: undefined });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve skipped batch updates as skipped

When the server deliberately skips an update target—for example because a native marketplace disappeared or a Codex plugin is disabled—Apply returns a skipped outcome without setting response.failure. This branch therefore marks the entire plugin as done, and the dialog reports it as updated even when none or only some of its targets changed. Inspect the returned outcomes and keep the batch item skipped or partially failed instead of treating every failure-free response as successful.

Useful? React with 👍 / 👎.

export function updatesPending(updates: Updates, inventory?: PluginInventory): UpdatePick[] {
const targets = targetMap(inventory?.targetDefinitions);
return Object.entries(updates)
.map(([name, u]) => ({ name, targets: Object.keys(u).filter((target) => targets[target]?.operations.includes('update')) }))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Remove stale update picks when their bindings disappear

After a check finds an update, the user can remove that plugin through its supported row menu; the inventory refreshes, but updates is retained and this filter only checks target capabilities. The removed plugin consequently remains in pendingUpdates, keeps the header on “Update”, and produces a permanently retryable plugin package ... not found failure when selected. Filter against the current package and binding (and its current selection state) so inventory mutations invalidate stale check results.

Useful? React with 👍 / 👎.

A comment on a removed key moved nowhere and was lost. It now sits in
front of the next surviving key, or on the last entry of its section.
Adds the config_keeps_comments runbook that drives `target` set and
remove over a file full of comments.

Refs #525
… the orphans

Prepending the orphaned comments first made the key look commented, so
its own head comment was skipped and lost.
@runkids
runkids force-pushed the fix/config-keep-removed-key-comments branch from 56cf7ee to 5735485 Compare October 11, 2026 13:35
@runkids

runkids commented Oct 11, 2026

Copy link
Copy Markdown
Owner Author

Rebuilt the branch on main with only the two config commits: two unrelated ui/plugins commits had been committed onto it from a shared checkout and are not part of this PR. The two Codex findings above are about those files. @codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5735485143

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/config/format.go Outdated
}
}
if j+1 >= len(cur.Content) {
orphaned = joinComments(orphaned, allComments(old.Content[i]), allComments(old.Content[i+1]))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep removed mapping comments in source order

When a removed final mapping entry has both an inline value comment and a trailing foot comment, such as # BEGIN\nmode: merge # note\n# END, yaml.v3 associates the foot comment with the key while leaving the inline comment on the value (parser logic). Collecting every key comment before every value comment therefore emits these as BEGIN, END, note, which can invert marker blocks or other order-sensitive annotations. Gather a mapping pair's head/inline/foot comments in their original presentation order instead.

Useful? React with 👍 / 👎.

Codex review: the key's foot comment comes after the value's line
comment in the file, so it must come after it in the orphaned block.
@runkids

runkids commented Oct 11, 2026

Copy link
Copy Markdown
Owner Author

Fixed: a removed entry's comments are gathered as key head, key line, value comments, key foot, so # BEGIN / # note / # END keep their order. Test TestMarshalConfig_CommentOfRemovedLastKeyEndsTheFile now asserts the order. @codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ffd3e615b5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/config/format.go Outdated
Comment on lines +187 to +188
for _, c := range n.Content {
out = joinComments(out, allComments(c))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Traverse nested mapping pairs in presentation order

When a removed entry contains a nested mapping, this generic child traversal still processes each key's foot comment before the paired value's comments. For example, in removed:\n # BEGIN\n child: value # note\n # END, yaml.v3 stores # END on the nested child key, so allComments produces BEGIN, END, note. Although pairComments fixes the outer removed pair, it does not fix mappings encountered recursively; traverse every mapping node pairwise with the same key-head/key-line/value/key-foot ordering to avoid breaking nested marker blocks.

Useful? React with 👍 / 👎.

…ntry's comments

Codex review: a nested key's foot comment was emitted before its
value's line comment.
@runkids

runkids commented Oct 11, 2026

Copy link
Copy Markdown
Owner Author

Fixed: allComments walks mapping nodes pairwise, so nested # BEGIN / # note / # END keep their order (TestMarshalConfig_RemovedNestedEntryKeepsCommentOrder). Three review rounds done; merging once CI is green.

@runkids
runkids merged commit 0792d0e into main Oct 11, 2026
8 checks passed
This was referenced Oct 11, 2026
@runkids
runkids deleted the fix/config-keep-removed-key-comments branch October 11, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant