Skip to content

task: show post type labels in the demo apps - #822

Merged
dcalhoun merged 8 commits into
trunkfrom
task/show-post-type-labels-in-demo-apps
Oct 23, 2026
Merged

dcalhoun merged 8 commits into
trunkfrom
task/show-post-type-labels-in-demo-apps

Conversation

@dcalhoun

@dcalhoun dcalhoun commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

What?

Fix demo app typos and display post type labels rather than slugs.

Why?

Improve demo app quality.

How?

Display the post type's labels attribute rather than its key.

Testing Instructions

Manually testing this demo app change is not that important, but:

  1. Open a site with a multi-word custom post type in the demo app
  2. Verify the post type picker uses the label, not the slug
  3. Select a post type
  4. Navigate to Browse
  5. Verify the list header uses the post type plural label

The screenshots below are from #794, which adds a multiword post type that benefits from the changes.

Accessibility Testing Instructions

N/A, small demo app change.

Screenshots or screencast

Before After
before after

AI-generated details

The demo apps showed post types by their capitalized slug or REST base, which reads poorly for custom types: #794's test type showed as "Gbk_Templated" in the iOS picker and "Templated-Posts" as the iOS posts list title.

  • Picker (iOS and Android): shows each post type's singular label from the REST API, as WP Admin does (Post, Page, Templated Post).
  • iOS posts list: the title uses the plural label.
  • Fallback: the capitalized slug, as before, when the post types weren't loaded from the site (e.g. the bundled editor).
  • Fixes the "No Entires" typo on the iOS empty posts list.
  • Demo apps only; PostTypeDetails in the library is unchanged, as the labels stay in each app's view model.

Testing

  • The iOS demo app builds, and the Android demo app's Kotlin compiles. Neither app has been run with this change.
  • To check: open a site with a custom post type (e.g. feat: apply post type templates to new posts #794's wp-env templated_post), and verify the picker and the iOS posts list title show its labels.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YNDBX7RNXn3NsfDuV1PkNV

Slugs and REST bases read poorly once capitalized, e.g. "Templated-Posts". The labels match what WP Admin shows. The slug remains the fallback when the post types weren't loaded from the site. Also fixes the "No Entires" typo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YNDBX7RNXn3NsfDuV1PkNV
@github-actions github-actions Bot added the [Type] Task Issues or PRs that have been broken down into an individual action to take label Oct 22, 2026
@wpmobilebot

wpmobilebot commented Oct 22, 2026 •

Copy link
Copy Markdown

XCFramework Build

This PR's XCFramework is available for testing. Add the following to your Package.swift:

.package(url: "https://github.com/wordpress-mobile/GutenbergKit", branch: "pr-build/822")

Built from 1b8c139

dcalhoun and others added 6 commits October 22, 2026 11:17
Detekt identifies baselined issues by the function signature, so adding the labels parameter resurfaced the card's existing LongMethod and LongParameterList issues.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YNDBX7RNXn3NsfDuV1PkNV
The assignment ran before the editor configuration existed, so the setter
returned early and the default was always `post`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Storing labels in a slug-keyed map beside the post types let the two drift
and spread the fallback across call sites. Keeping each label on its post
type resolves the fallback once and drops the dictionary that trapped on
duplicate slugs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A post type registered with an empty label otherwise renders a blank picker
row and posts-list title.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The picker shows labels, so sorting by slug read as random (e.g. "Templated
Post, Page, Post").

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Matches the iOS posts list, which already shows e.g. "Pages" instead of a
hard-coded "Posts".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dcalhoun
dcalhoun marked this pull request as ready for review October 22, 2026 16:30
@dcalhoun
dcalhoun requested a review from adalpari October 22, 2026 16:30
@adalpari

Copy link
Copy Markdown
Contributor

LGTM!

Just noting this point for you to decide whether it's worth fixing.

# Severity Location Issue Impact
1 🔵 Low android/app/src/main/java/com/example/gutenbergkit/SitePreparationViewModel.kt:368, ios/Demo-iOS/Sources/Views/SitePreparationView.swift:566 The picker's sort key moved from the slug (unique — it is the REST response map key) to the server-supplied label, which is not unique, and no tiebreaker was added. A CPT registered with no labels inherits WordPress's defaults (_get_custom_object_labels, wp-includes/post.php), so singular_name is "Post" for a non-hierarchical type and "Page" for a hierarchical one — it then sits next to the built-in type as a second, visually identical row, where trunk showed distinct slugs. Tied rows also reorder between launches on both platforms: the wp_api response map is a Rust HashMap (wp_api/src/post_types.rs:65), which is randomly seeded, so neither Dictionary.values on iOS nor the Kotlin LinkedHashMap gives a stable input order. Verified empirically: six launches of the iOS chain produced six different tie orders, fixed only under SWIFT_DETERMINISTIC_HASHING=1. Selection stays correct (ids/tags key on details), so this is cosmetic — but a user who picks "the second Post" gets a different type than last time. Fix: KeyPathComparator(\.details.postType) as a second comparator on iOS, .thenBy { it.details.postType } on Android.

Labels aren't unique (an unlabeled custom type inherits "Post" or "Page"),
and the REST response map's order is randomly seeded, so tied rows reordered
between launches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dcalhoun
dcalhoun enabled auto-merge (squash) October 23, 2026 13:41
@dcalhoun
dcalhoun merged commit 1967aff into trunk Oct 23, 2026
23 checks passed
@dcalhoun
dcalhoun deleted the task/show-post-type-labels-in-demo-apps branch October 23, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Task Issues or PRs that have been broken down into an individual action to take

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants