Skip to content

fix(chat): validate restored contexts against send schema - #9294

Merged
waleedlatif1 merged 3 commits into
stagingfrom
codex/composer-context-validation
Oct 21, 2026
Merged

waleedlatif1 merged 3 commits into
stagingfrom
codex/composer-context-validation

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Validate recalled and queued chat contexts with the unchanged send schema, preserving text, valid chips, and original context identities.
  • Show context-loss notices on every chat surface. Cap recovered contexts at the existing request limit and hold incomplete sends until reviewed; prevent Send now from bypassing that hold while preserving Stop settlement and duplicate-send protections.
  • Keep lost-context evidence through recovery rewrites and clear it only after an allowed edit. Server admission is unchanged.

Type of Change

  • Bug fix

Testing

  • 227 focused tests pass, including persistence-to-editor validation, queued-context recovery, malformed storage, the context-count limit, cold-mount notifications, and edit/send behavior. New regressions fail before the fix; removing each new safeguard makes its targeted regression fail.
  • 14 browser scenarios pass in Chromium, WebKit, and Firefox, covering rich chips, malformed metadata, uploads, queue priority, caret behavior, and resubmission.
  • Root tests, lint, type-check, all 60 audits, the test-type audit, and the block-registry check pass. All four committed-artifact generators are in sync.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Oct 21, 2026 10:07pm UTC

Request Review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 4 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Heads up: you’re close to your flex budget. Increase your flex budget so reviews don’t pause.

Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new blocking issue was found.

Summary

Restored chat contexts now use the existing send schema. Invalid contexts are dropped without losing the message text or valid chips.

  • Restored chat messages keep valid context and flag context that cannot be sent.
  • Queued sends with lost context wait for the user to review them.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Stored message] --> B[Check contexts against send schema]
  B --> C[Keep valid contexts within request limit]
  C --> D{Were any contexts lost?}
  D -->|No| E[Normal queue recovery]
  D -->|Yes| F[Keep loss flag and hold message]
  F --> G[Show notice]
  F --> H[Block Send now]
  F --> I[User reviews and edits]
  I --> J[Clear hold and use a new request identity]
  J --> K[Keep any unfinished Stop dependency]
Loading

Reviews (3) · Last reviewed commit: "fix(chat): show queue warnings and bound..." · Reviewed by Greptile

Comment thread apps/sim/lib/mothership/chat/context.ts
@waleedlatif1
waleedlatif1 force-pushed the codex/composer-context-validation branch from 253d70d to 943ea3e Compare October 21, 2026 21:32
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 16 files

Heads up: you’re close to your flex budget. Increase your flex budget so reviews don’t pause.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts Outdated
Comment thread apps/sim/app/workspace/[workspaceId]/home/hooks/send-handoff.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 16 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Heads up: you’re close to your flex budget. Increase your flex budget so reviews don’t pause.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit cb5027a into staging Oct 21, 2026
56 checks passed
@waleedlatif1
waleedlatif1 deleted the codex/composer-context-validation branch October 21, 2026 22:20

This branch was previously deployed

1 inactive deployment
Preview — 3a99db61 Deployed Oct 21, 2026 by vercel[bot]
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