Skip to content

fix: use current Assistant thread API#135

Merged
Microck merged 1 commit into
mainfrom
fix/assistant-current-api-threads
Jul 6, 2026
Merged

fix: use current Assistant thread API#135
Microck merged 1 commit into
mainfrom
fix/assistant-current-api-threads

Conversation

@Microck

@Microck Microck commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • move Assistant thread list/get/export/delete onto Kagi's current assistant.kagi.com/api conversation endpoints
  • accept assistant.kagi.com/chat/<uuid> URLs anywhere a thread ID is accepted
  • render exports from the current conversation payload and surface Kagi JSON error details for inaccessible chats
  • document the behavior and add a user-facing changelog entry

Verification

  • cargo fmt --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test -q
  • cargo test -q --locked
  • facts check --tags assistant-thread-migration
  • live smoke: created a temporary Kagi Assistant conversation, verified thread get, thread list, thread export, thread delete, then confirmed follow-up thread get returned Kagi's current 404 JSON error

Docs

  • README updated if user-facing behavior changed
  • CHANGELOG updated for notable user-facing changes

Auth / Secrets

  • No tokens, cookies, or local config secrets were committed
  • Any live verification steps are documented without exposing credentials

Greptile Summary

This PR moves Assistant thread commands to Kagi's current conversation API. The main changes are:

  • New conversation endpoints for thread list, get, export, and delete.
  • Assistant chat URL support wherever a thread ID is accepted.
  • Current conversation payloads converted into the existing thread response shape.
  • Message pagination support for long conversations.
  • Updated docs, changelog, and tests for the migration.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
src/api.rs Migrates Assistant thread operations to the current conversation API and adds ID validation, chat URL parsing, export rendering, error handling, and message pagination.
src/http.rs Adds support for building current Assistant API URLs used by the migrated thread commands.
tests/integration-cli.rs Updates CLI integration coverage for the Assistant thread migration behavior.

Comments Outside Diff (1)

  1. src/api.rs, line 731 (link)

    P2 Folder Counts Are Dropped

    The list response now reports total_counts as only {"all": count}. The old thread list preserved Kagi's per-folder totals across pages, so JSON consumers that display or sync folder counts now receive incomplete metadata even though folders are still returned.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: src/api.rs
    Line: 731
    
    Comment:
    **Folder Counts Are Dropped**
    
    The list response now reports `total_counts` as only `{"all": count}`. The old thread list preserved Kagi's per-folder totals across pages, so JSON consumers that display or sync folder counts now receive incomplete metadata even though folders are still returned.
    
    How can I resolve this? If you propose a fix, please make it concise.

    Fix in Codex

Reviews (3): Last reviewed commit: "fix: use current Assistant thread API" | Re-trigger Greptile

@Microck

Microck commented Jul 6, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Comment thread src/api.rs Outdated
Comment thread src/api.rs
Comment thread src/api.rs

@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: 20465104cc

ℹ️ 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 src/api.rs
Comment thread src/api.rs Outdated
Comment thread src/api.rs Outdated
@Microck
Microck force-pushed the fix/assistant-current-api-threads branch from 2046510 to e536e9f Compare July 6, 2026 21:21
@Microck
Microck force-pushed the fix/assistant-current-api-threads branch from e536e9f to d037c87 Compare July 6, 2026 21:25
@Microck

Microck commented Jul 6, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@Microck
Microck enabled auto-merge July 6, 2026 21:29
@Microck
Microck merged commit d8755a5 into main Jul 6, 2026
6 checks passed
@Microck
Microck deleted the fix/assistant-current-api-threads branch July 6, 2026 21:30

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

ℹ️ 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 src/api.rs
Comment on lines +3785 to +3786
if status.is_success() {
return serde_json::from_str(&body).map_err(|error| {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Check Assistant error envelopes before defaulted deserialization

When an Assistant endpoint returns a JSON error envelope with a 2xx status, this branch tries to deserialize into T before checking assistant_json_error. That silently masks errors for defaulted response types such as CurrentAssistantConversationListResponse, where {"error":...} can deserialize as an empty list and make thread list report no chats instead of the upstream error; check for an Assistant error envelope before deserializing successful bodies.

Useful? React with 👍 / 👎.

Comment thread src/api.rs
Comment on lines +5213 to +5215
references_markdown: current_assistant_references_markdown(&assistant.references),
metadata_html: None,
documents: assistant.attachments,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve user attachments in completed turns

For normal completed exchanges with uploaded files or auto-created pasted-content attachments, the attachments live on the user prompt message, but this paired-turn conversion only copies assistant.attachments. The user-side attachments are preserved only for unpaired user messages, so thread get and JSON exports drop documents for the common user+assistant case; merge the user attachments into documents here as well.

Useful? React with 👍 / 👎.

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