Skip to content

refactor(chatRenderer): Refactor chatRenderer.js such that it only contains data, exports, and logic related to rendering chats.#4540

Open
entitycs wants to merge 1 commit into
odysseus-dev:devfrom
entitycs:refactor/dev-chatRenderModel
Open

refactor(chatRenderer): Refactor chatRenderer.js such that it only contains data, exports, and logic related to rendering chats.#4540
entitycs wants to merge 1 commit into
odysseus-dev:devfrom
entitycs:refactor/dev-chatRenderModel

Conversation

@entitycs

@entitycs entitycs commented Jun 18, 2026

Copy link
Copy Markdown

Summary

Refactors chatRenderer.js, extracting all non-rendering, alternate-domain exports and data into logical, extensible parts.

Target branch

  • This PR targets dev, not main. All PRs land in dev; main is curated by the maintainer at each release. If your PR is on main by accident, click "Edit" on this PR and change the base.

Linked Issue

Closes #4047

Type of Change

  • Bug fix (non-breaking — fixes a confirmed issue)
  • New feature (non-breaking — adds new behaviour)
  • Breaking change (changes or removes existing behaviour)
  • Refactor / cleanup (behaviour unchanged)
  • Documentation only
  • CI / tooling / configuration

Checklist

  • I searched open issues and open PRs — this is not a duplicate.
  • This PR targets dev
  • My changes are limited to the scope described above — no unrelated refactors or whitespace changes mixed in.
    • (not true, but this is a local test run)
  • I actually ran the app (docker compose up or uvicorn app:app) and verified the change works end-to-end. Type-checks and unit tests are not enough.

How to Test

  1. python -m pytest
  2. build and run (via docker, wsl, linux, etc.)
  3. check docker logs if applicable.
  4. check browser console for errors.

Visual / UI changes — REQUIRED if you touched anything that renders

Anything that changes what the UI looks like — buttons, icons, padding, colors, fonts, spacing, layout, CSS, HTML, SVG, or any static/js/ module that draws to the DOM — needs all of the following. PRs that change rendering without these WILL be closed.

  • Screenshot or short clip of the change in the running app, attached below. Mobile screenshot too if the change affects mobile.
  • Style match: the change uses Odysseus's existing visual language. Specifically:
    • Reuse existing CSS variables (--red, --fg, --bg, --card, --border, etc.) — do not introduce new color values, font sizes, or spacing units.
    • Reuse existing button/input/card/border classes. Don't invent parallel styling.
    • No Unicode emoji in UI or code. Use inline SVG (matching the monochrome icon style already in static/index.html) or plain text.
    • Monospaced font (Fira Code) for primary UI text. Don't override.
    • Dark theme is the default; any light-mode work must be wired through the existing theme system, not hard-coded.
  • No new component patterns. If a similar widget already exists in the app, extend it instead of writing a parallel one.
  • I am not an LLM agent submitting a bulk PR. If you are, please open an issue describing the problem first — bulk auto-generated PRs that don't match the project's visual style are closed on sight, even when the underlying fix is correct.

Screenshots / clips

@github-actions github-actions Bot added the ready for review Description complete — ready for maintainer review label Jun 18, 2026
@entitycs entitycs changed the title Refactor/dev chat render model refactor(chatRenderer) Refactor chatRenderer.js such that it only contains data, exports, and logic related to rendering chats. Jun 18, 2026
@entitycs entitycs changed the title refactor(chatRenderer) Refactor chatRenderer.js such that it only contains data, exports, and logic related to rendering chats. refactor(chatRenderer): Refactor chatRenderer.js such that it only contains data, exports, and logic related to rendering chats. Jun 18, 2026
@entitycs entitycs changed the title refactor(chatRenderer): Refactor chatRenderer.js such that it only contains data, exports, and logic related to rendering chats. refactor(chatRenderer): Refactor chatRenderer.js such that it only contains data, exports, and logic related to rendering chats. (ignore) Jun 18, 2026
Comment thread static/js/compare/stream.js
Comment thread static/js/compare/vote.js
Comment thread static/js/model/endpoint.js
Comment thread static/js/model/models.js
Comment thread static/js/model/pricing.js
Comment thread static/js/model/shared.js
Comment thread static/js/util/format.js
Comment thread static/js/util/safeString.js
Comment thread static/js/compare/stream.js
Comment thread static/js/chatUserScrollMarker.js Outdated
Comment thread static/js/group.js
Comment thread static/js/cookbookServe.js
Comment thread static/js/models.js
Comment thread static/index.html
Comment thread static/style.css
Comment thread static/sw.js
Comment thread tests/helpers/valid_imports.py
Comment thread tests/test_chat_stream_scope.py
Comment thread tests/test_group_chat_storage.py
Comment thread tests/test_local_endpoint_js.py
Comment thread static/js/chat.js

@entitycs entitycs left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left to serve as an example of what to expect for new contributors looking to help refactor and/or lint.

notes:

  • Absolutely no linting on refactor side-effect handling; okay for files being fully refactored
    • eg. chat.js vs chatRenderer.js where chatRenderer.js is the refactor target and chat.js is where a side-effect is handled
  • Prefer refactor before linting
  • In new files, prefer alignment to current understanding of linting path

@entitycs
entitycs marked this pull request as draft June 18, 2026 22:30
entitycs added a commit to entitycs/odysseus that referenced this pull request Jun 18, 2026
@entitycs
entitycs force-pushed the refactor/dev-chatRenderModel branch from d65823d to e51bd36 Compare June 18, 2026 23:28
entitycs added a commit to entitycs/odysseus that referenced this pull request Jun 18, 2026
entitycs added a commit to entitycs/odysseus that referenced this pull request Jun 22, 2026
@entitycs
entitycs force-pushed the refactor/dev-chatRenderModel branch 2 times, most recently from 3515c72 to d13ec5a Compare June 22, 2026 23:06

@entitycs entitycs left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready again.

Please consider merging to help alleviate clashing in chatRenderer.js, and allow contributors to see + use extracted logic so they don't have to import or attempt to change chatRenderer, for example, to modify how model names are shortened in the frontend.

@entitycs
entitycs marked this pull request as ready for review June 22, 2026 23:29
@github-actions github-actions Bot removed the merge conflict Conflicts with the base branch; needs a rebase before review. label Jun 22, 2026
entitycs added a commit to entitycs/odysseus that referenced this pull request Jun 23, 2026
entitycs added a commit to entitycs/odysseus that referenced this pull request Jun 23, 2026
@entitycs
entitycs marked this pull request as draft June 26, 2026 22:23
entitycs added a commit to entitycs/odysseus that referenced this pull request Jul 2, 2026
entitycs added a commit to entitycs/odysseus that referenced this pull request Jul 5, 2026
@entitycs
entitycs force-pushed the refactor/dev-chatRenderModel branch from 08579c4 to 6862be9 Compare July 6, 2026 02:31
@entitycs
entitycs marked this pull request as ready for review July 6, 2026 02:40
entitycs added a commit to entitycs/odysseus that referenced this pull request Jul 7, 2026
entitycs added a commit to entitycs/odysseus that referenced this pull request Jul 8, 2026
entitycs added a commit to entitycs/odysseus that referenced this pull request Jul 8, 2026
entitycs added a commit to entitycs/odysseus that referenced this pull request Jul 8, 2026
entitycs added a commit to entitycs/odysseus that referenced this pull request Jul 9, 2026
@entitycs
entitycs force-pushed the refactor/dev-chatRenderModel branch from 6862be9 to 71ce963 Compare July 9, 2026 17:58
@entitycs

entitycs commented Jul 9, 2026

Copy link
Copy Markdown
Author

Ready once again. Combined the original 2 commits into 1. Left concise comment where I adhered to @pewdiepie-archdaemon request for change. About as clean as I can get this. Will try to keep it rebased/updated in case it pops back up the review queue.

entitycs added a commit to entitycs/odysseus that referenced this pull request Jul 11, 2026
entitycs added a commit to entitycs/odysseus that referenced this pull request Jul 11, 2026
@entitycs
entitycs force-pushed the refactor/dev-chatRenderModel branch from 71ce963 to f702fe4 Compare July 11, 2026 06:51
entitycs added a commit to entitycs/odysseus that referenced this pull request Jul 12, 2026
No changes to the module's core logic, properties or functionality.

Two 'private' methods were renamed and extracted as utility functions.
  - formatCompactNumber: Formats large numbers to K/M shorthand
    - previously named `_fmtCtx` inside of chatRenderer
  - toTrimmedString: Converts values to trimmed strings, handling null
    - previously named `modelValue` inside of chatRenderer

Elements were factored out - none factored in. Exports not belonging to the remaining set of properties and functions were removed. Updates were applied downstream to importing modules so that they use the correct sources of truth moving forward.

fix(test) Update frontend tests touching refactor

Introduces `tests/helpers/valid_imports.py` to help ease the pain of rewriting exact-match import tests when refactoring, reording of modules lists, etc., occurs

Updates tests where needed

- Update stream render test to use rfind for try block detection
- Update XSS test assertions to use new source of truth for safeDisplayImageSrc. Use valid_imports helper to survive refactors.
@entitycs
entitycs force-pushed the refactor/dev-chatRenderModel branch from f702fe4 to 58a3ccf Compare July 12, 2026 21:48
entitycs added a commit to entitycs/odysseus that referenced this pull request Jul 17, 2026
entitycs added a commit to entitycs/odysseus that referenced this pull request Jul 18, 2026
entitycs added a commit to entitycs/odysseus that referenced this pull request Jul 19, 2026
entitycs added a commit to entitycs/odysseus that referenced this pull request Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review Description complete — ready for maintainer review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant