Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 6, 2025

Thanks a lot for contributing!

When logCustom is called with a TalkerLog that has both a custom pen and a key (e.g., TalkerKey.debug), the custom pen color is ignored and replaced with the key's default color.

talker.logCustom(
  TalkerLog(
    'WITH A KEY',
    pen: AnsiPen()..xterm(46),  // Custom green - ignored!
    key: TalkerLogType.debug.key,
  ),
);

Root cause: _handleLogData unconditionally overwrites data.pen via settings.getPenByKey(key, fallbackPen: data.pen). Since debug exists in the default colors map, the fallback is never used.

Fix: Only apply the key's default color when no custom pen was provided:

if (pen == null) {
  pen = settings.getPenByKey(key);
  data.pen = pen;
}

Added test cases verifying:

  • Custom pen is preserved when key is also set
  • Default key color still applies when no custom pen provided
Original prompt

This section details on the original issue you should resolve

<issue_title>Talker ignores pen color in logCustom, when the key is set.</issue_title>
<issue_description>Describe the bug

Reopening issue: #313

As of a version 4.8.3 this is still not working. I am adding full testable code + output screenshot.

  final talker = TalkerFlutter.init();

  talker.logCustom(
    TalkerLog(
      'WITH A KEY',
      pen: AnsiPen()..xterm(46),
      key: TalkerLogType.debug.key,
    ),
  );

  talker.logCustom(
    TalkerLog(
      'WITHOUT A KEY',
      pen: AnsiPen()..xterm(46),
    ),
  );

Image

I did not go any deeper into the code. Just quickly checked the merged PR(fbe77e0) that should have fix the issue. This one seems maybe a bit of:

Image

This implies to me, at first glance, that the settings.getPenByLogKey(logTypeKey gets still the pen color by logType key in priority of the setted pen color.

Expected behavior
The color should be changed appropriately.

Desktop (please complete the following information):

  • OS: Linux Mint

Smartphone (please complete the following information):

  • Device: Samsung S22 Ultra
  • OS: Android 14

</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix pen color functionality in logCustom method Fix pen color ignored in logCustom when key is set Dec 6, 2025
Copilot AI requested a review from Frezyx December 6, 2025 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Talker ignores pen color in logCustom, when the key is set.

2 participants