Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 29, 2025

  • Understand the dictsort filter specification from Jinja docs
  • Implement the dictsort filter in runtime.ts for ObjectValue
  • Add tests for dictsort filter with various parameters
  • Test the implementation with edge cases
  • Run lint and build to ensure code quality
  • Refactor to eliminate code duplication by extracting helper method
  • Improve null/undefined handling in sort comparisons
  • Add documentation for type handling assumptions
  • Move dictsort logic to ObjectValue builtins as FunctionValue per @xenova's feedback
  • Extract index calculation to avoid duplication
Original prompt

On jinja, Add support for the dictsort. jinja filter to @huggingface/jinja package. Here are the docs for the feature: https://jinja.palletsprojects.com/en/stable/templates/#jinja-filters.dictsort


💡 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 and others added 3 commits October 29, 2025 20:47
Co-authored-by: xenova <26504141+xenova@users.noreply.github.com>
…prove null handling

Co-authored-by: xenova <26504141+xenova@users.noreply.github.com>
Co-authored-by: xenova <26504141+xenova@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for dictsort filter to jinja package Add dictsort filter to @huggingface/jinja Oct 29, 2025
Copilot AI requested a review from xenova October 29, 2025 20:57
Copilot finished work on behalf of xenova October 29, 2025 20:57
@xenova
Copy link
Contributor

xenova commented Oct 29, 2025

@copilot This is a good start, but I'd prefer for the applyDictSort logic to be moved to the builtins section of the ObjectValue class, turning dictsort into a FunctionValue which can be called as a filter.

Co-authored-by: xenova <26504141+xenova@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 29, 2025

@copilot This is a good start, but I'd prefer for the applyDictSort logic to be moved to the builtins section of the ObjectValue class, turning dictsort into a FunctionValue which can be called ...

Done! I've moved the dictsort logic to the builtins section of the ObjectValue class as a FunctionValue. The implementation now:

  1. Adds dictsort as a builtin in ObjectValue (lines 293-397)
  2. Checks for ObjectValue builtins in both identifier and call expression filter paths
  3. Removes the applyDictSort helper method

All tests pass and the implementation is cleaner. Commit: 85481b0

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • huggingface.co

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of xenova October 29, 2025 21:12
Copy link
Contributor

@xenova xenova left a comment

Choose a reason for hiding this comment

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

Looks great 👍 minor nit.

Comment on lines 351 to 352
const aItem = a.value[by.value === "key" ? 0 : 1];
const bItem = b.value[by.value === "key" ? 0 : 1];
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot we can reuse by.value === "key" ? 0 : 1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! Extracted the index calculation to a variable. Commit: 9f169f1

Co-authored-by: xenova <26504141+xenova@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 29, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • huggingface.co
    • Triggering command: node /home/REDACTED/work/huggingface.js/huggingface.js/node_modules/.bin/../vitest/vitest.mjs run (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from xenova October 29, 2025 21:24
Copilot finished work on behalf of xenova October 29, 2025 21:24
@xenova xenova marked this pull request as ready for review October 29, 2025 21:25
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.

2 participants