Skip to content

👴🏻 fix: Continue Saved Chats After Endpoint Retirement - #18861

Merged
dustinhealy merged 7 commits into
devfrom
fix/continue-chats-after-endpoint-retirement
Nov 24, 2026
Merged

dustinhealy merged 7 commits into
devfrom
fix/continue-chats-after-endpoint-retirement

Conversation

@dustinhealy

@dustinhealy dustinhealy commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A saved chat can become impossible to continue when its model spec moves to a different endpoint and the original endpoint is retired. Reopening the chat now resolves the saved spec against the effective server configuration, including specs hidden from the model menu. The next message continues in the same conversation.

How it works

The conversation detail endpoint returns the replacement target when the original endpoint is gone and the saved spec points to an available provider. It keeps the saved model if the replacement serves it and otherwise uses the spec default. Enforced specs use their configured model.

Sidebar navigation opens immediately when it has a compatible recovered target in cache. It fetches the detail before opening when it still needs a replacement. A transient refresh failure preserves the cached transcript and saved settings.

Type of change

  • Bug fix

Testing

Tested environments/configuration

Chromium, a mock provider, and disposable MongoDB. The browser regression creates a chat, simulates endpoint retirement, reopens the original URL, and verifies that a follow-up persists with the same conversation ID and parent message while retaining the original transcript.

Automated tests

  • Focused conversation detail, model-spec recovery, and sidebar navigation suites.
  • Playwright continuation regression and a matched before-and-after browser run.
  • TypeScript, static checks, and the Lighthouse conversation-load budget. The unused-dependency check was skipped locally because depcheck was unavailable.

Screenshots / recordings

Open the same saved conversation from the sidebar and submit the same follow-up after its original endpoint has been retired.

Before

The transcript opens, but the composer reports that it cannot load the model or agent. Pressing Enter leaves the follow-up in the composer.

before-retired-endpoint.mp4

After

The composer opens on the replacement provider. The follow-up sends and receives a reply below the original messages.

after-retired-endpoint.mp4

Risk / compatibility

Recovery requires a saved spec pointing to an available replacement. Opening a chat uses the existing response fields and requires no database migration. The first affected sidebar open waits for the detail request if it lacks a usable cached target. When recovery checks whether a different saved model is available, a dynamic model catalog can add a provider request. Recovery-specific latency was not measured.

Checklist

  • I reviewed my own changes
  • Relevant tests have been added or updated
  • Existing relevant tests pass
  • The change does not introduce new warnings or errors
  • User-facing or complex behavior is documented where necessary
  • Required dependency changes have been merged/published (N/A)
  • Required documentation PR (N/A)

Copilot AI balanced review requested due to automatic review settings November 24, 2026 16:58
@dustinhealy

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T23:21:58.213422Z 7eb085b 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.

@dustinhealy dustinhealy changed the title 🔧 fix: Continue Saved Chats After Endpoint Retirement 👴🏻 fix: Continue Saved Chats After Endpoint Retirement Nov 24, 2026

@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: e9fe2891f0

ℹ️ 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 api/server/routes/convos.js Resolved

Copilot AI 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.

🟡 Changes recommended

A pending refresh can overwrite newly committed agent or assistant IDs with stale values in conversation caches, causing subsequent navigation to select the wrong target.

1 open issue
What changed in this PR

This PR lets saved chats continue in the same conversation after their original endpoint is retired, using the saved model spec to resolve an available replacement provider.

Changes:

  • Resolves replacement targets from effective server configuration, including hidden specs, while preserving compatible saved models.
  • Updates sidebar navigation to use recovered cached targets or fetch details before opening, preserving cached history on transient failures.
  • Adds backend, navigation, and browser regression coverage.
File Description
packages/​api/​src/​conversations/​target.ts Resolves replacement endpoints and models for saved specs.
packages/​api/​src/​conversations/​target.spec.ts Tests recovery eligibility and model selection.
packages/​api/​src/​conversations/​load.ts Applies recovered targets to conversation detail responses.
packages/​api/​src/​conversations/​load.spec.ts Tests history preservation when target resolution fails.
packages/​api/​src/​conversations/​index.ts Exports the target resolver.
e2e/​specs/​mock/​retired-spec-continuation.spec.ts Verifies continuation preserves conversation identity and history.
client/​src/​hooks/​Conversations/​useNavigateToConvo.tsx Handles retired targets during cached and fetched navigation.
client/​src/​hooks/​Conversations/​__tests__/​useNavigateToConvo.spec.tsx Covers recovered targets, cache updates, and refresh failures.
api/​server/​routes/​convos.js Connects target recovery to configuration and model services.

Review effort: Balanced

@dustinhealy

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: d2631c8326

ℹ️ 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".

Copilot AI 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.

🔵 Needs a closer look

The refresh can overwrite usable recovered routing fields in both caches with a retired endpoint and obsolete agent ID, causing the next conversation open to restore a broken composer during the same outage.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Preserve cached routing when refresh returns an unavailable endpoint

client/​src/​hooks/​Conversations/​useNavigateToConvo.tsx:179

When target resolution fails, createGetConversationHandler returns HTTP 200 with the original stored record, so this refresh overwrites a usable recovered target in both caches with the retired endpoint and obsolete agent ID. The next open can then restore the broken composer during the same outage. Preserve cached routing fields when a same-spec response has an unavailable endpoint and the cached endpoint is still available, while refreshing the non-routing data.

1 resolved since last review

Review effort: Balanced

@dustinhealy

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: f9a62c0a41

ℹ️ 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".

Copilot AI 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.

🔵 Needs a closer look

A critical issue remains: transient catalog discovery failures can appear successful and overwrite the saved model and sidebar target with the spec default instead of preserving them.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

High severity Catalog failures can overwrite the saved model with the spec default

packages/​api/​src/​conversations/​target.ts:105

A transient catalog failure can silently replace the saved model with the spec default: the catalog loaders turn discovery failures into empty/default lists (packages/api/src/endpoints/config/models.ts:318–338 and defaults.ts:62–66). Recovery then appears successful, so a warm refresh can overwrite the cached model and sidebar target instead of preserving them. Use a failure-aware catalog read for recovery that propagates discovery failures to the handler, and select the spec default only when a successful catalog excludes the saved model.

Review effort: Balanced

@dustinhealy

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 6551aefc9d

ℹ️ 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".

Copilot AI 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.

🟡 Changes recommended

Recovery can leave conversations on retired endpoints because model discovery omits stored user credentials and Retry does not rerun failed target resolution.

2 open issues

Review effort: Balanced

Comment thread packages/api/src/conversations/load.ts Resolved
@dustinhealy

Copy link
Copy Markdown
Collaborator Author

/quality check-all

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Quality report

Outdated: this request is for an earlier PR commit.

Gate: closed. Blocked by: Change risk (api) (failure), the workflow (failure).

Status: completed (failure). Actions run, attempt 1.

  • Commit: 37b5f398348a429a8c2b8dbeaefe28f070b27f34
  • Requested by: @dustinhealy
  • Check: check-all
  • Scopes: data-schemas, api, server
  • Static mutants: off
  • Change risk: data-schemas, api, server
  • Mutation testing (experimental, data-schemas only): data-schemas (four shards)

Change risk

Takeaway: incomplete data (1 workspace report unavailable), so no summary is given.

Workspace Files measured Incomplete Unavailable Changed lines with no test Highest CRAP
data-schemas 1 of 1 0 0 0 3.0
api report unavailable
server 3 of 3 0 0 0 2.0

Refactor hints (highest CRAP first)

Function Complexity Coverage CRAP Location
getUserKey 3 100% 3.0 packages/data-schemas/src/methods/key.ts:44
getUserKeyValues 2 60% 2.3 packages/data-schemas/src/methods/key.ts:74
api 2 100% 2.0 api/server/routes/__test-utils__/convos-route-mocks.js:87
(anonymous) 1 100% 1.0 api/server/routes/__test-utils__/convos-route-mocks.js:88
(anonymous) 1 100% 1.0 api/server/routes/__test-utils__/convos-route-mocks.js:89
createKeyMethods 1 100% 1.0 packages/data-schemas/src/methods/key.ts:17

CRAP = complexity² × (1 − coverage)³ + complexity

Mutation testing

Score: killed by assertion, Killed/(Killed+Survived+NoCoverage); the Stryker score also counts timeouts.

Workspace Killed Survived Timeout No coverage Invalid Ignored Score Run
data-schemas 0 0 0 0 0 0 – complete
Jobs (8)
Check Result
Change risk (data-schemas) success
Change risk (api) failure
Change risk (server) success
Mutation testing 1/4 (data-schemas) success
Mutation testing 2/4 (data-schemas) success
Mutation testing 3/4 (data-schemas) success
Mutation testing 4/4 (data-schemas) success
Mutation report (data-schemas) success

All data (quality-report artifact) · Run page

The gate opens only when the workflow, source selection, tooling verification, and every report job succeed. A report job fails on a failed test in its workspace's own Jest run, a tool error, a job timeout, or an incomplete mutation report, including a mutation shard that reaches its execution budget. A cancelled workflow keeps the gate closed. Scores are advisory. A change-risk file marked incomplete or unavailable, for example by a failed api/ source-alias suite, does not close the gate.

@dustinhealy
dustinhealy requested a balanced review from Copilot November 24, 2026 22:26

Copilot AI 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.

🟡 Changes recommended

Target recovery can switch cold-loaded chats to an unrelated provider and repeatedly fail for user-provided proxy configurations despite valid stored connection details.

2 open issues
2 resolved since last review

Review effort: Balanced

Comment thread client/src/hooks/Chat/target.ts Resolved

Copilot AI 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.

🔵 Needs a closer look

Human assessment is needed to evaluate a cross-tab refresh and route-restoration edge case that can silently replace a retired endpoint and bypass saved-spec recovery and Retry.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

Copilot AI 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.

🟢 Approval recommended

No active review issues remain for the saved-chat replacement-endpoint recovery changes.

No open issues 🎉

Review effort: Balanced

@dustinhealy

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 7eb085b575

ℹ️ 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".

@dustinhealy
dustinhealy merged commit f9d2e1a into dev Nov 24, 2026
71 of 72 checks passed
@dustinhealy
dustinhealy deleted the fix/continue-chats-after-endpoint-retirement branch November 24, 2026 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants