Skip to content

refactor(web): let contract types flow through web/service instead of casts - #47120

Merged
hyoban merged 1 commit into
mainfrom
fix/web-service-contract-casts
Nov 25, 2026
Merged

hyoban merged 1 commit into
mainfrom
fix/web-service-contract-casts

Conversation

@hyoban

@hyoban hyoban commented Nov 25, 2026

Copy link
Copy Markdown
Member

Summary

  • uploadPublicRemoteFileInfo (web/service/common.ts) now returns the remoteFiles.upload contract type. Before, a cast claimed mime_type and url were always strings. The contract says they can be null, and the file uploader already falls back with res.mime_type ?? '' and res.url ?? url.
  • FileUploadStrategy.uploadRemote now declares the small result shape the uploader reads, with mime_type and url nullable. It no longer borrows ReturnType<typeof uploadPublicRemoteFileInfo>, so the contract result fits and so does the human-input v2 upload result. Runtime behavior is unchanged.

Casts left in web/service, and why

The contract and the local type really differ in each case below. The cast was kept to avoid hiding the gap or changing behavior.

Site Reason
log.ts fetchRunDetail / fetchTracingList The generated run-detail and node-execution schemas leave out fields the run panel reads (inputs_truncated, outputs_truncated, metadata, created_by).
workflow.ts fetchAppWorkflowDraft / fetchPipelineWorkflowDraft The contract types graph as Record<string, unknown> and variable value as unknown. The editor needs nodes/edges and typed environment and conversation variables.
share.ts / debug.ts stream sender bodies (body as …['body'], 10 sites) StreamSender takes Record<string, unknown>, and its callers are the chat and text-generation hooks. Typing the bodies means changing those hooks, which is out of scope here.
debug.ts generateBasicAppFirstTimeRule / generateRule The UI can send model_config.mode: '' and leave out flow_id. The contract requires 'chat' | 'completion' and a flow_id.
share.ts fetchAppInfo (AppData) The contract has custom_config optional and end_user_id nullable. AppData has both as required or non-null.
share.ts fetchConversations / generationConversationName (web app branch) The contract has introduction optional and nullable. ConversationItem has it as string. The installed-app branch already normalizes it through selectConversation.
share.ts fetchAppParams (ChatConfig) The contract parameters lack pre_prompt, prompt_type, dataset_configs and more that ChatConfig declares.
share.ts fetchAppMeta (AppMeta) The contract tool_icons is optional Record<string, unknown>. The installed-app branch normalizes it, the web app branch does not.
share.ts getAppAccessModeByAppCode The contract types accessMode as string, not the AccessMode enum.
share.ts getHumanInputForm The contract form type differs from LegacyHumanInputFormData.
share.ts human-input local/remote file upload responses The contract FileResponse fields are mostly nullish, and it has no url field at all. The local HumanInputFormRemoteFileUploadResponse declares url: string.
tools.ts form / schema_type The UI models hold free strings, and the custom-collection editor can send schema_type: ''. The contract uses enums.
plugin-credential-queries.ts The plugin-auth Credential view model needs is_default and reads fields the contract lacks (from_enterprise, not_allowed_to_use, allow_custom_token).
plugin-install-queries.ts TanStack structuralSharing passes unknown arguments.
marketplace-template-discovery.ts Strips runtime fields that the MarketplaceTemplate contract does not declare.
console/code-based-extension-query.ts, console/app-parameters-select.ts, console/defined-errors.ts Narrow JSON that the contract types as unknown or a plain record.
fetch.ts, http-error.ts, xhr-fetch.ts, event-stream.ts, base.ts Transport-level narrowing of DOM or unknown JSON. No contract covers these.
use-plugins.ts Not touched in this PR.

Contract mismatches worth following up

  • The web app humanInputForms.files.post response (FileResponse) has no url field. The legacy remote-upload code declares url: string.
  • The workflow run detail and node execution responses are missing inputs_truncated, outputs_truncated, metadata and created_by.
  • The rule and instruction generate payloads require model_config.mode to be chat or completion, and the instruction payload requires flow_id. The UI can send '' for the mode and leave out flow_id.
  • The web app accessMode is typed as a plain string.

@github-actions github-actions Bot added size:S This PR changes 10-29 lines, ignoring generated files. web This relates to changes on the web. labels Nov 25, 2026
@hyoban
hyoban marked this pull request as ready for review November 25, 2026 10:37
@hyoban
hyoban requested a review from iamjoel as a code owner November 25, 2026 10:37
@hyoban
hyoban added this pull request to the merge queue Nov 25, 2026
Merged via the queue into main with commit a8c51cd Nov 25, 2026
83 of 85 checks passed
@hyoban
hyoban deleted the fix/web-service-contract-casts branch November 25, 2026 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files. web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants