The MCOimg pixel decoder loads at the first image, not with the chat
The decoder moves from core/mcoimg.py to core/mcoimg_decode.py, unchanged. mcoimg.py keeps recognition (the caption needs only the header) and is what the chat imports; pixelart imports the decoder inside decoded(). On the PicoCalc the decoder cost about 50 ms on every chat import. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2f2225b8bb
commit
e84c902a80
5 files changed
+1270
-1241
No files matched your search
+7
-1234
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
+2
-1
@@ -68,6 +68,7 @@ from .widgets import (
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..context import AppContext
|
||||
from ..core.mcoimg_decode import Picture
|
||||
from ..services.message_paths import TraceWalk
|
||||
from .map_render import MapMarker
|
||||
from .map_screen import Locator
|
||||
@@ -1355,7 +1356,7 @@ class ChatScreen(Screen):
|
||||
message = self._messages[max(0, min(self._selected, len(self._messages) - 1))]
|
||||
return links.urls(self._sender_and_body(message)[1])
|
||||
|
||||
def _picked_picture(self) -> mcoimg.Picture | None:
|
||||
def _picked_picture(self) -> Picture | None:
|
||||
"""The pixel image of the selected message, or ``None`` (no selection, or no image)."""
|
||||
if self._selected is None or not self._messages:
|
||||
return None
|
||||
|
||||
@@ -25,12 +25,11 @@ from rich.console import Group
|
||||
from rich.style import Style
|
||||
from rich.text import Text
|
||||
|
||||
from ..core import mcoimg
|
||||
from ..platforms import Platform, on_platform
|
||||
from .tui.screen import ScrollScreen
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..core.mcoimg import Picture
|
||||
from ..core.mcoimg_decode import Picture
|
||||
|
||||
RGB = tuple[int, int, int]
|
||||
|
||||
@@ -57,9 +56,12 @@ def decoded(body: str) -> Picture | None:
|
||||
"""The image of a message body, or ``None``. It keeps the last results.
|
||||
|
||||
A transcript paints many times while a message is visible. Each paint asks again, and
|
||||
the cache answers without a second decode.
|
||||
the cache answers without a second decode. The decoder is large, so it loads here, at
|
||||
the first image, and not when the chat opens.
|
||||
"""
|
||||
return mcoimg.decode(body)
|
||||
from ..core.mcoimg_decode import decode
|
||||
|
||||
return decode(body)
|
||||
|
||||
|
||||
def fit(
|
||||
|
||||
Reference in new issue
Block a user