Can't Cycle Layouts After Recent Update(v0.57.0)

After the recently released update, i find myself unable to cycle between different layouts.
I used this code snippet which i found on the hyprland wiki. It worked, until recently after i updated hyprland, now it doesn’t work anymore.

--Cycle Between The Two Main Layouts I Use(master & monocle)
hl.bind(mainMod .. "+ F", function ()
    local layouts   = {"master", "monocle"}
    local workspace = hl.get_active_workspace()
    if hl.get_active_special_workspace() then
        workspace = hl.get_active_special_workspace()
    end

    local next_layout = "master"

    if not workspace then
        return
    end

    for i = 1, #layouts do
        if layouts[i] == workspace.tiled_layout then
            local next_layout_idx = (i % #layouts) + 1
            next_layout = layouts[next_layout_idx]
            break
        end
    end

    if workspace.special then
        hl.workspace_rule({ workspace = tostring(workspace.name), layout = next_layout })
    else
        hl.workspace_rule({ workspace = "name:" .. tostring(workspace.name), layout = next_layout })
    end
end)

I’ve used a simple bash script for this kind of thing for a while. This should work on 0.57.0.

#!/bin/bash

ACTIVE=$(hyprctl activeworkspace)
WS_ADDR=$(echo "$ACTIVE" | grep "workspace" | cut -d " " -f 2)
NEXT_LAYOUT=$(echo "$ACTIVE" | grep -q 'monocle' && echo 'master' || echo 'monocle')

hyprctl eval "hl.workspace_rule({ workspace = \"$WS_ADDR\", layout = \"$NEXT_LAYOUT\" })"
-- hyprland.lua
hl.bind(mainMod .. " + F", hl.dsp.exec_cmd("~/.scripts/swap-layout"))

Coincidentally, I’ve been working on a named workspace manager and just wrote a feature for layout selection and toggling today because I had to update this script for 0.57 as well. The feature is still in a draft PR but should be ready soon.

If it’s of interest to you, here it is: