package main import ( "log" "os" "gitea.zheromiku.top/Weknora/dobotai-platform/internal/channels/dingtalk" ) // cardPartialUpdatesMode returns the configured card delivery mode for a // finished answer (see dingtalk.CardPartialUpdatesMode): // // unset / on / partial → placeholder card + throttled partial frames (historical) // off / final → placeholder card, and only the finished answer // direct → no placeholder card; one card with the finished answer // // The default stays "partial" so an environment without the variable behaves // exactly as before; DINGTALK_CARD_PARTIAL_UPDATES selects the other modes. The // resolved mode is logged so the startup log always states what is running. func cardPartialUpdatesMode() dingtalk.CardPartialUpdatesMode { mode := dingtalk.ParseCardPartialUpdatesMode(os.Getenv("DINGTALK_CARD_PARTIAL_UPDATES")) log.Printf("DingTalk card partial updates mode=%s", mode) return mode } // cardFinalWriteMode returns the configured terminal-write mode for a finished // answer (see dingtalk.CardFinalWriteMode): // // unset / streaming → the finished answer is written with the card streaming // API and isFinalize=true (historical behaviour) // update / plain → the same answer is written once more through the plain // card update API (PUT /v1.0/card/instances) AFTER the // streaming finalize (observed to blank the delivered card) // refresh → the answer goes through the plain card update API FIRST // and the stream is then closed with the very same text, // so the client has no delta left to animate // close-refresh → the stream is closed on the text the card already shows // (zero delta) and the answer is refreshed afterwards // // DingTalk renders streamed card content with a typewriter animation the client // drives itself, so an answer that is already complete on the server can still be // replayed character by character - and a client that is not in the foreground // pauses that animation, which reads as "streaming stopped, it continues when I // switch back". The default stays "streaming" so an environment without the // variable behaves exactly as before; DINGTALK_CARD_FINAL_WRITE selects the other // mode. The resolved mode is logged so the startup log always states what ran. func cardFinalWriteMode() dingtalk.CardFinalWriteMode { mode := dingtalk.ParseCardFinalWriteMode(os.Getenv("DINGTALK_CARD_FINAL_WRITE")) log.Printf("DingTalk card final write mode=%s", mode) return mode }