Skip to content

feat(chat): render Astra's habit-list card on web + mobile — Stage 2 clients - #300

Merged
thomasluizon merged 2 commits into
mainfrom
fix/astra-habit-card
Jun 24, 2026
Merged

feat(chat): render Astra's habit-list card on web + mobile — Stage 2 clients#300
thomasluizon merged 2 commits into
mainfrom
fix/astra-habit-card

Conversation

@thomasluizon

Copy link
Copy Markdown
Owner

Stage 2 (client half) of the Astra habit-listing fix

The user-visible cure for Astra dropping habits when listing. Instead of a re-typed text list (which the model mangles mid-list), the chat now renders the structured habitList payload the API returns (orbit-api #238) as a native card.

Changes (cross-platform parity)

  • packages/shared: habitListCardSchema on chatResponse + chatMessage; stripHabitListDirective to remove the [[orbit:habits:...]] token from streamed content (the server strips the final message; deltas still carry it mid-flight); chat.habitList.* i18n in en + pt-BR.
  • apps/web + apps/mobile: both send supportsHabitListCard in clientContext, map habitList onto the message, and render a new HabitListCard (emoji · title · indented hierarchy · status badge) after the markdown bubble — web with semantic tokens, mobile with createTokensV2. Falls back to plain text when there's no payload.

Backward compatibility

Purely additive. With an old API (no habitList), the card simply never renders — chat behaves exactly as before. The capability flag is opt-in; nothing breaks if the API ignores it.

Deploy order

Merge/deploy orbit-api #238 first (it must understand the flag and return the payload), then this. Web picks it up on the next Vercel deploy; mobile when the next Play build ships (older mobile builds keep the text path — and Stage 1's numbering — until they update).

Tests

Shared strip-util tests; web + mobile message-bubble tests (card renders items + badges, directive stripped from content, no card for user messages). Web 1600 passed, mobile 603 passed, shared 1014 passed.

Cross-repo

Backend contract + builder: orbit-api #238 (Stage 2 backend, stacked on #236). Stage 1 (server-side duplicate fix): orbit-api #236.

🤖 Generated with Claude Code

thomasluizon and others added 2 commits June 24, 2026 12:16
Adds the cross-platform contract for Astra's structured habit-list card:
habitListCardSchema (scope + flat items with depth/status) on chatResponse and
chatMessage, plus stripHabitListDirective to remove the [[orbit:habits:...]]
token from streamed content (the server strips the final message; deltas still
carry it mid-flight). i18n badge labels added to en + pt-BR.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Both chat surfaces now signal supportsHabitListCard in clientContext and render
the structured habitList payload Astra returns as a native card (emoji, title,
indented hierarchy, status badge) instead of a re-typed text list - the user-
visible half of the lost-in-the-middle fix. The [[orbit:habits:...]] directive is
stripped from streamed content via the shared util so it never flickers mid-stream.

New HabitListCard component mirrored across apps/web (semantic tokens) and
apps/mobile (createTokensV2), wired into each message-bubble after the markdown.
Falls back to plain text when no payload, so nothing changes for old responses.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
orbit-ui-mobile-web Ignored Ignored Jun 24, 2026 3:35pm

Request Review

@sonarqubecloud

Copy link
Copy Markdown

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

PR Review: APPROVE (0 Critical, 0 High, 2 Medium). No blocking issues. Medium findings: (1) Web HabitListCard missing empty-state test in message-bubble.test.tsx - add test for habitList with empty items array. (2) C# enum serialization risk in orbit-api (unverifiable in CI) - verify JsonStringEnumConverter on HabitListCardItemDto.Status and HabitListCardDto.Scope in orbit-api PR 238 before deploying. Backward-compat PASS - all shared type changes additive. Perfect cross-platform parity, correct token usage, behavior-focused tests, i18n in both locales. Both mediums are non-blocking. The stated deploy order (orbit-api first) is correct.

@thomasluizon
thomasluizon merged commit 6b0482b into main Jun 24, 2026
10 checks passed
@thomasluizon
thomasluizon deleted the fix/astra-habit-card branch June 24, 2026 16:06
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