fix(dingtalk): keep streaming frames growing while a table forms
A table that starts forming made stableMarkdownPrefix truncate every streaming frame at the table start, so the card froze and the whole table plus tail arrived in the single finalize frame (live: 5.2 KB dump after the answer had already finished upstream). Add the DINGTALK_CARD_WIDE_TABLE_GROUP=smooth mode: over-wide tables are grouped on every frame (as "on") and, while streaming, every table is grouped so no table block survives into a partial frame. The final frame keeps the real table whenever it lays out safely.
This commit is contained in:
@@ -12,13 +12,15 @@ import (
|
||||
// unset / on → grouped list on every frame (historical behaviour)
|
||||
// off → real tables on every frame
|
||||
// stream → grouped list while streaming, real table on the final frame
|
||||
// smooth → like "on", and every table is grouped while streaming so a
|
||||
// table forming mid-answer no longer freezes the card
|
||||
//
|
||||
// The default stays "on" so an environment without the variable renders exactly
|
||||
// as before; DINGTALK_CARD_WIDE_TABLE_GROUP selects the other modes.
|
||||
func cardWideTableGroupingMode() string {
|
||||
mode := strings.ToLower(strings.TrimSpace(os.Getenv("DINGTALK_CARD_WIDE_TABLE_GROUP")))
|
||||
switch mode {
|
||||
case "off", "0", "false", "no", "stream", "streaming", "partial":
|
||||
case "off", "0", "false", "no", "stream", "streaming", "partial", "smooth":
|
||||
log.Printf("DingTalk wide-table grouping mode=%s", mode)
|
||||
return mode
|
||||
default:
|
||||
|
||||
@@ -232,6 +232,10 @@ func TestCardWideTableGroupingMode(t *testing.T) {
|
||||
if got := cardWideTableGroupingMode(); got != "" {
|
||||
t.Fatalf("on is the default and must not be forwarded as a mode, got %q", got)
|
||||
}
|
||||
t.Setenv("DINGTALK_CARD_WIDE_TABLE_GROUP", "SMOOTH")
|
||||
if got := cardWideTableGroupingMode(); got != "smooth" {
|
||||
t.Fatalf("smooth must be normalised, got %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMainDoesNotExposeWebAdministrationOrSetupOnlyMode(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user