Skip to content

Layout backups: skip a widget whose app is missing, name blank labels, plain errors - #461

Merged
McCal-Codes merged 3 commits into
mainfrom
backup-fixes
Oct 22, 2026
Merged

McCal-Codes merged 3 commits into
mainfrom
backup-fixes

Conversation

@McCal-Codes

Copy link
Copy Markdown
Owner

Fixes three problems in Settings > Backup from the 20 Oct code review.

  • Saving a layout no longer fails when a widget's app is missing or disabled. That widget is left out and the message says how many were.
  • A blank app, shortcut or widget label is saved under a fallback name, so the backup can be read back (it used to write one it then refused to decode).
  • Errors show a few plain translated messages instead of raw exception text.

Checked: LayoutBackupTest has new cases for each (unit tests and lint pass). Not tried on the phone.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 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-21T17:21:00.827182Z bd77b3c PR opened
ℹ️ 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: bd77b3cc69

ℹ️ 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 on lines +180 to +182
private var skippedWidgets = 0
private fun savedMessage(base: String) = if (skippedWidgets > 0)
base + " " + activity.resources.getQuantityString(R.plurals.backup_widgets_left_out, skippedWidgets, skippedWidgets) else base

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 Persist the omitted-widget count with the export

When the activity is recreated while the document picker is open—for example after a rotation, fold, or process restart—restore() resumes the persisted export without calling encodeBackup(), but this field is reinitialized to zero. The file still omits the unavailable widgets, while savedMessage() no longer warns how many were omitted; persist the count alongside KEY_EXPORT or bind it to the pending export payload.

Useful? React with 👍 / 👎.

val root = JSONObject(raw)
val version = root.strictInt("version")
require(version in 1..LAYOUT_BACKUP_VERSION) { "Unsupported layout backup version" }
require(version in 1..LAYOUT_BACKUP_VERSION) { BACKUP_NEWER_VERSION }

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 Distinguish invalid old versions from newer backups

This assigns BACKUP_NEWER_VERSION to every value outside 1..LAYOUT_BACKUP_VERSION, including zero and negative versions. A malformed or unsupported-old file therefore tells the user to update Folio even though updating cannot make it valid; only versions above the supported maximum should receive the newer-version message, while lower values should use the ordinary invalid-backup error.

Useful? React with 👍 / 👎.

* requirement", "Widget 3 is unavailable"). The raw text goes to Diagnostics, where it can be read and shared on purpose.
*/
private fun failureMessage(error: Throwable, fallback: Int): String {
caught("Backup: ${error::class.java.simpleName}: ${error.message}") { throw error }

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 exception messages out of Diagnostics

When an I/O, provider, or parsing exception includes a file path, package, or user-supplied value, interpolating error.message into where causes Diagnostics.caught() to persist that value in the diagnostic trail. This bypasses the privacy behavior documented in Diagnostics.kt, where exception messages are deliberately excluded because the trail may be viewed or shared; pass a stable operation name and let caught record only the exception type.

Useful? React with 👍 / 👎.

@McCal-Codes
McCal-Codes merged commit fbd2c70 into main Oct 22, 2026
3 checks passed
@McCal-Codes
McCal-Codes deleted the backup-fixes branch October 22, 2026 00:32
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