Repository navigation
fix(core): ObjectLogger honors NO_COLOR and TTY detection before emitting ANSI colors - #3111
Merged
Merged
Conversation
…ting ANSI colors The kernel/plugin logger colorized pretty-format level tags unconditionally, so NO_COLOR=1 runs and piped/CI output still carried ANSI escapes, breaking plain-text log scanners (publish-smoke.sh had to strip ANSI before grepping). Per no-color.org, color is now emitted only when the destination stream (stdout, or stderr for error/fatal) is an interactive TTY and NO_COLOR is unset or empty. Interactive terminals keep colorized output. The optional file destination always receives plain text now. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 22 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
This was referenced Jul 17, 2026
os-tesla
pushed a commit
that referenced
this pull request
Oct 25, 2026
…ectui#12724) (#13508) <!-- claude-projects-attribution: {"github_login":"os-zhuang"} --> _Requested by **Sam** · [project thread](https://claude.ai/code/project/chan_01GsBogozeZG5sdpAARrN7HP?thread=cmsg_01GsBogozeZG5sdpAARrN7HPPdgXnLU8SfcQmac3AzRouL)_ Clause-②: yes (the exported `ProposedPlanCard` gains the optional `posture`) Closes #12724 ## What objectstack-ai/cloud declared `planCard.posture` on `propose_blueprint`'s envelope (cloud#2924 ruling A, cloud PR #3111, `f0ecef3a`): `{ mode: 'publish' | 'draft', liveRecords, line }`. objectui drew nothing from it yet. The plan card now draws `posture.line` (for example 「首次搭建直接上线;之后的修改先存草稿,由你发布」) as the **last item of the assumptions list**, where the AiBuild artboard draws it. A plan card without the key draws as before. If a plan has a posture but no assumptions, the section still renders and holds the posture line alone. - `mapMessages.ts`: `ProposedPlanCard.posture?: { mode; line }`, lifted in `liftPlanCard` only when `mode` is a declared value and `line` is non-empty. `liveRecords` is already in the line, so it is not lifted. - `ChatbotEnhanced.tsx`: one `<li data-testid="proposed-plan-posture" data-posture={mode}>` after the assumptions. - `fixtures/build-cards.schema.ts`: re-vendored verbatim at cloud `f0ecef3a`. The only change from the `f7ab9cc8` copy is `planCard.posture`, and cloud `main` `36b07fdf` has the same schema byte for byte. - `buildCards.fixtures.ts`: `planEnvelope(lang, { posture: 'firstBuild' | 'draft' })`, built with cloud's own `postureFirstBuild` / `postureIntoLiveApp` wording. - The docs paragraph in `content/docs/plugins/plugin-chatbot.mdx`, and a changeset (`@object-ui/plugin-chatbot` minor). ## Why this closes #12724 The card's two remaining artboard rows have no producer key at cloud `main` `36b07fdf`, and no cloud card plans one: - the plan card's 「确认后约 1 分钟搭好」 and 「也可以直接回复:…」 - the result card's subtitle 「应用已进启动台 · 包 … · 以下每一条都按方案核对过」 The maintainer ruled in the project thread on 2026-10-25 to drop both from the artboard rather than wait for cloud. This posture row was the last declared key still undrawn. ## Tests - `pnpm exec vitest run packages/plugin-chatbot/`: 83 files, 795 tests, all passed, including the new `ChatbotEnhanced.planCardPosture-12724.test.tsx`. It covers zh and en first-build lines, the draft line, posture without assumptions, and two controls: no key, and an undeclared mode. - `buildCards.contract-12724.test.ts` checks both new fixture payloads against the vendored schema. - `node scripts/check-changeset-presence.mjs` ✅. `pnpm check:new-line-citations`: 0 new. - [x] Adds no product-specific widget, dialog, hook or string (see AGENTS.md › Product-neutral renderer) --- _Generated by [Claude Code](https://claude.ai/code/session_01R3ARF6ZEyBWW8EBT9we3eX)_ Co-authored-by: Claude <noreply@anthropic.com>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
os serve/os dev接线的内核插件日志(ctx.logger=ObjectLogger,默认pretty格式)无条件给 level 标签着色,NO_COLOR=1也不例外:违反 no-color.org 约定,且 CI 里纯文本 grep 会漏掉 ERROR 行 —— scripts/publish-smoke.sh(#3100)就是因此被迫先 strip ANSI 再扫日志(该兜底保留不动)。
修复(只动
packages/core/src/logger.ts,不动调用点/spec)按 no-color.org 约定,
pretty格式仅在满足以下两个条件时才输出 ANSI 色码:NO_COLOR未设置或为空 —— 任何非空值(含0)都禁用颜色。交互式终端默认行为不变(仍着色);管道/重定向/CI 输出恒为纯文本;可选的
file目的地现在恒写纯文本(此前会把色码写进日志文件)。json/text格式不受影响。浏览器 bundle(@objectstack/client复用此模块)无process/TTY → 纯文本,保持 browser-safe。验证
logger.test.ts新增 "Color emission (no-color.org)" 7 例(TTY 默认着色 / 非空 NO_COLOR 禁用含'0'/ 空串视为未设 / 非 TTY 无色 / stderr 门控 error 色 / 文件目的地无 ANSI)。@objectstack/core356 测试全绿。ERROR头与原报告字节一致)。pnpm dev -- --fresh+NO_COLOR=1冒烟,启动日志零 ESC。相关
logger.file静默失效,__require('fs')抛错被catch {}吞掉)—— 本 PR 不处理。@objectstack/corepatch。🤖 Generated with Claude Code