Skip to content

Refactor dump_chat_to_markdown handler to use parseGetChatHistoryArgs pattern #13

@kiki830621

Description

@kiki830621

Problem

Issue #7parseGetChatHistoryArgs pure function 重構了 get_chat_history handler,但 dump_chat_to_markdown handler (Server.swift:466-499) 保留同樣的 inline 驗證邏輯

  • chat_id guard
  • max_messages 0/10_000 cap (一字不差)
  • parseISODate + parseUntilDate with DateParseError catch
  • errorResult 轉換

From verification of #7 by devils-advocate (HIGH):
「若未來改 HandlerArgs.swift 的 cap policy,dump_chat_to_markdown 會 silently drift。commit message 和 code comment 都沒提這 exception,test file 名稱 ServerHandlerLogicTests 又泛化,下個 reviewer 容易誤以為『all handlers covered』」

Type

refactor

Expected

  • DumpChatToMarkdownArgs struct + parseDumpChatToMarkdownArgs(_ args:) throws -> ... pure function
  • 或 generalize: parseGetChatHistoryArgsparseChatHistoryArgs(帶 isDumpMode: Bool 或 output context),兩個 handler 共用
  • 對應 unit tests 覆蓋 dump_chat_to_markdown 的 validation 路徑

Code Reference

  • Sources/CheTelegramAllMCPCore/Server.swift:466-499(被忽略的 handler)
  • Sources/CheTelegramAllMCPCore/HandlerArgs.swift(可 extend 的模組)

Related: #7


Current Status

Phase: closed
Last updated: 2026-04-26 by idd-close

Key Decisions

Scope Changes

  • 增補:testDumpExplicitSelfLabel(scope+1,default vs explicit override 對稱覆蓋,已透明標註)
  • 增補:CHANGELOG 10 new tests11 new tests in-scope fix(commit ac306ba

Blocking

(none)

Follow-up

Test counts

  • 139 → 150 (+11), 0 failures
  • Codex 獨立驗證 24 tests pass

Commits

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions