Repository navigation
refactor: declare tg chats list output once - #179
Merged
neoromantic merged 2 commits intoNov 18, 2026
Merged
neoromantic merged 2 commits into
neoromantic merged 2 commits into
Conversation
A trial of one output declaration on one command. The data that tg chats list prints is a zod schema with a description per field; its types are inferred from it, the field table in docs/cli-commands.md is generated from it, and an e2e test parses the real output strictly against it. zod is a devDependency: the command imports only the type, so nothing new ships. The output is unchanged. Refs neoromantic#160 Co-Authored-By: Claude Fable 5.2 <[email protected]>
3 tasks done
No textual conflict. nextChatsPage (from neoromantic#185) takes the declared ChatsListOutput: PaginatedResult is no longer imported here. Co-Authored-By: Claude Fable 5.2 <[email protected]>
neoromantic
added a commit
that referenced
this pull request
Nov 18, 2026
refactor: declare tg chats list output once (#179)
ertembiyik
pushed a commit
to ertembiyik/telegram-sync-cli
that referenced
this pull request
Nov 18, 2026
ertembiyik
added a commit
to ertembiyik/telegram-sync-cli
that referenced
this pull request
Nov 18, 2026
main now has neoromantic#179 (neoromantic#188). No conflict. Co-Authored-By: Claude Fable 5.2 <[email protected]>
ertembiyik
added a commit
to ertembiyik/telegram-sync-cli
that referenced
this pull request
Nov 18, 2026
main now has neoromantic#179 (neoromantic#188). No conflict. Co-Authored-By: Claude Fable 5.2 <[email protected]>
ertembiyik
added a commit
to ertembiyik/telegram-sync-cli
that referenced
this pull request
Nov 18, 2026
main now has neoromantic#179 (neoromantic#188). CHANGELOG: both Changed entries kept. Co-Authored-By: Claude Fable 5.2 <[email protected]>
ertembiyik
added a commit
to ertembiyik/telegram-sync-cli
that referenced
this pull request
Nov 18, 2026
main now has neoromantic#179 (neoromantic#188). CHANGELOG: main's Changed section, then this PR's Removed. Co-Authored-By: Claude Fable 5.2 <[email protected]>
ertembiyik
added a commit
to ertembiyik/telegram-sync-cli
that referenced
this pull request
Nov 18, 2026
main now has neoromantic#179 (neoromantic#188). No conflict. Co-Authored-By: Claude Fable 5.2 <[email protected]>
ertembiyik
added a commit
to ertembiyik/telegram-sync-cli
that referenced
this pull request
Nov 18, 2026
main now has neoromantic#178 (neoromantic#186) and neoromantic#179 (neoromantic#188). No conflict. Co-Authored-By: Claude Fable 5.2 <[email protected]>
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.
What and why
The trial you asked for on point 5 of #160, on one command. The
datathattg chats listprints is declared once, insrc/commands/chats/list-output.ts(82 lines), and its types, its docs table and an e2e check all come from that declaration. The output itself does not change: five invocations on the same made-up cache are byte-identical before and after. Refs #160The declaration is a zod 4 schema with a description on every field:
Nothing new ships. zod is a devDependency. The command imports only the inferred type (
import type), so it is not in the compiled binary (no zod strings indist/tg, no zod module in the bundle's metafile), andtg chats listruns the same withnode_modules/zodmoved away. Only the tests and the docs script load the schema.Which types it replaces
interface ChatIteminhelpers.ts,interface ChatListIteminlist.ts, and the inlinePaginatedResult<ChatListItem> & { source: string; stale: boolean }. Both answers, from the cache and from the API, are now typedChatsListOutput.chats getandchats searchprint the same item, so their item type comes from the declaration too; their files are unchanged.Which docs it replaces
Two paragraphs in
docs/cli-commands.mdthat described 3 of the 16 fields are replaced by a table of every field, generated between<!-- output: chats list -->markers bybun run docs:outputs:items[].memberCountnullnullwhen unknownitems[].lastMessageAtnullsourcecacheorapicache, orapiwith--freshor when the cache has no matching chatA unit test fails when the table and the declaration differ. Changing one description without running the script gives:
How the e2e check catches drift
src/__e2e__/chats-list-output.e2e.test.tsrunstg chats liston made-up chats (every type, nullable fields both set and null, with and without sync state) and parses the real output strictly against the declaration. RenamingunreadCounttounreadMessagesin the command, without touching the declaration, fails it:tscrejects the same rename, because the type is inferred from the declaration. The e2e check is what catches drift the compiler can't see, such as a value that arrives from untyped SQL or JSON.What the next command would cost
One-off, done here: the devDependency,
scripts/docs-outputs.ts(71 lines), the docs test and thedocs:outputsscript. Per command: a declaration of 40 to 80 lines, one line in the script's map, a marker pair in the docs, swapping the hand-written types forimport type, and an e2e test of about 30 lines plus fixtures. Shared pieces (the chat item, the paging fields) reuse with.extend.Decisions you may want to change:
list-output.ts, not in a centralsrc/outputs/.Not covered: the e2e test runs the cache path only. The
--freshpath builds the same items with the same function and its answer is typedChatsListOutput, sotscchecks it, but the fake client doesn't implementiterDialogs.This touches
src/commands/chats/list.ts, as #176 did;mainis merged in, see the update below.Update:
mainmerged in (3a2fb89)nextChatsPagefrom feat: add next commands to paged reads and an empty chat cache (#176 on main) #185 usedPaginatedResult, which this PR no longer imports inchats/list.ts: it now takes the declaredChatsListOutput.bun run checkclean,bun run test2347 pass,bun run test:e2e454 pass, 0 fail.How I checked it
bun run check: clean.bun run test: 2302 pass, 0 fail.bun run test:e2e: 433 pass, 0 fail.Output of
tg chats list(default,--limit 2 --offset 1,--type community,--unread,--format pretty) on the same made-up cache: byte-identical before and after (cmp, same 5592 bytes).bun run build, then searcheddist/tgand the bundle's metafile for zod: none. Bundling the docs script the same way finds it, so the search would have.Tests pass locally and use made-up data only
README, docs and affected demos follow the product content standard (
docs/cli-commands.md, generated)Title follows the repo's commit style: Conventional Commits (
feat: …,fix: …) unlessAGENTS.mdsays otherwise🤖 Generated with Claude Code