Skip to content

fix: validate effective chat picker readiness - #854

Open
itsJai42 wants to merge 1 commit into
fathah:mainfrom
itsJai42:fix/remote-chat-readiness
Open

fix: validate effective chat picker readiness#854
itsJai42 wants to merge 1 commit into
fathah:mainfrom
itsJai42:fix/remote-chat-readiness

Conversation

@itsJai42

Copy link
Copy Markdown
Contributor

Summary

  • validate pre-send readiness against the current Chat picker's full {provider, model, baseUrl} identity
  • keep credential inspection in the main process
  • skip Desktop-local .env and auth.json credential probes for Remote and SSH connections while preserving missing-model validation
  • document the model and credential ownership boundaries in lat.md

Why

Chat already reran readiness when picker state changed, but IPC validated only the persisted global model. That produced NO_ACTIVE_MODEL for valid session picks. Forwarding the picker identity exposes a second boundary: Remote and SSH credentials live on the other host, so Desktop cannot infer MISSING_API_KEY from local files.

This supersedes #839, credits its picker-override approach, and incorporates the Remote/SSH refinement reported in #839 (comment).

Verification

  • RED: 3 focused regressions failed against current main with NO_ACTIVE_MODEL, MISSING_API_KEY, and missing model-detection mismatch
  • GREEN: focused validation/preload/IPC-contract suite: 226 passed
  • full suite: 1,747 passed, 3 skipped
  • npm run typecheck: passed
  • npm run build: passed
  • changed-file ESLint: 0 errors
  • Prettier, git diff --check, and lat check: passed

Existing baseline

Full npm run lint remains nonzero because current main has 9 errors in unchanged src/renderer/src/components/ProviderKeysSection.tsx. This PR adds no lint errors.

@greptile-apps

greptile-apps Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes Chat readiness follow the conversation’s effective model selection. The main changes are:

  • Pass the picker’s provider, model, and base URL through preload IPC.
  • Validate the effective session model instead of only persisted configuration.
  • Skip Desktop-local credential probes for Remote and SSH connections.
  • Add focused validation tests and document credential ownership.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
src/renderer/src/screens/Chat/Chat.tsx Passes the current conversation’s effective routing identity into readiness validation.
src/preload/index.ts Forwards the optional model override through the preload IPC bridge.
src/preload/index.d.ts Updates the renderer-facing API declaration for the model override.
src/main/ipc/register.ts Derives credential-check scope from the current connection mode.
src/main/validation.ts Validates the supplied session model and conditionally checks local credentials.
tests/validation.test.ts Covers session model selection, remote credential scope, and missing-model validation.
lat.md/model-selection.md Documents readiness routing and local versus remote credential ownership.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant Chat as Chat renderer
    participant Preload as Preload API
    participant Main as Main IPC handler
    participant Validation as Readiness validation
    Chat->>Preload: validate(profile, effective model identity)
    Preload->>Main: validate-chat-readiness
    Main->>Main: Read connection mode
    Main->>Validation: Validate model and credential scope
    alt Effective model is empty
        Validation-->>Chat: NO_ACTIVE_MODEL
    else Local connection
        Validation->>Validation: Check local credentials
        Validation-->>Chat: Readiness result
    else Remote or SSH
        Validation->>Validation: Skip Desktop credential probes
        Validation-->>Chat: Ready
    end
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant Chat as Chat renderer
    participant Preload as Preload API
    participant Main as Main IPC handler
    participant Validation as Readiness validation
    Chat->>Preload: validate(profile, effective model identity)
    Preload->>Main: validate-chat-readiness
    Main->>Main: Read connection mode
    Main->>Validation: Validate model and credential scope
    alt Effective model is empty
        Validation-->>Chat: NO_ACTIVE_MODEL
    else Local connection
        Validation->>Validation: Check local credentials
        Validation-->>Chat: Readiness result
    else Remote or SSH
        Validation->>Validation: Skip Desktop credential probes
        Validation-->>Chat: Ready
    end
Loading

Reviews (1): Last reviewed commit: "fix: validate effective chat model readi..." | Re-trigger Greptile

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