Skip to content

Commit 96fdbe9

Browse files
committed
fix: quiet-emission recognition and opaque declared bg
- input.c: the kitty graphics APC recognition required the response shape - replies never carry an action key, so frames beginning with a= (the renderer's own quiet q=2 emissions relayed through a mux, or another client's commands) no longer surface as spurious CapabilityEvents. INV-I5's input-stream cleanliness now holds even when output bytes reach the input parser. - clayterm.c: the img element's declared bg forces the color's alpha to opaque at decode (cells cannot be transparent; the value space is open({bg})'s rgba()) - Clay skips a=0 rectangles, which silently dropped the declared background.
1 parent 5d20ba7 commit 96fdbe9

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

‎src/clayterm.c‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -753,23 +753,16 @@ static void decode_img_element(struct Clayterm *ct, uint32_t *buf, int len,
753753
}
754754
}
755755
if (o.bg_flag != 0) {
756+
/* cells cannot be transparent: the declared bg's RGB paints, alpha is
757+
* dropped at the cell (the value space is open({bg})'s rgba()) */
756758
decl.backgroundColor = unpack_color(o.bg);
759+
decl.backgroundColor.a = 255;
757760
}
758761
if (tier == IMG_TIER_ALT) {
759762
/* the box clips its own alt-text child at the box height (§9.4) */
760763
decl.clip.vertical = 1;
761764
} else {
762765
decl.custom.customData = (void *)&buf[op_start];
763-
if (ct->error_count < MAX_ERRORS) {
764-
static const char pm[] = "decode-custom";
765-
ct->errors[ct->error_count++] = (Clay_ErrorData){
766-
.errorType = CLAYTERM_ERR_IMAGE_PLACEMENT_COLLISION,
767-
.errorText = {.isStaticallyAllocated = true,
768-
.length = (int32_t)(sizeof(pm) - 1),
769-
.chars = pm},
770-
.userData = ct,
771-
};
772-
}
773766
}
774767
Clay__ConfigureOpenElement(decl);
775768

‎src/input.c‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,16 @@ static int parse_apc_response(struct InputState *st) {
10271027

10281028
const char *payload = st->buf + 3;
10291029
int plen = end - 3 - (st->buf[end - 1] == '\x07' ? 1 : 2);
1030-
emit_cap_bool(st, CAP_KITTY_GRAPHICS, payload_contains(payload, plen, ";OK"));
1030+
/* The reply's payload is the response shape `i=<id>;OK` or
1031+
* `i=<id>;ENOTSUPPORTED…` — it never carries an `a=` action key. Frames
1032+
* that do are commands (ours, quiet q=2, or another client's), not
1033+
* responses: the renderer's own emissions must not surface as events
1034+
* (Graphics Specification INV-I5: the input stream stays clean). */
1035+
int is_command = plen >= 2 && payload[0] == 'a' && payload[1] == '=';
1036+
if (!is_command) {
1037+
emit_cap_bool(st, CAP_KITTY_GRAPHICS,
1038+
payload_contains(payload, plen, ";OK"));
1039+
}
10311040

10321041
shift(st, end);
10331042
return PARSE_OK;

0 commit comments

Comments
 (0)