Optimize SplitTree encoding with custom Codable
- 1 See the bug in @bug.txt . This is caused by SplitTree (@macos/Sources/Features/Splits/SplitTree.swift ) encoding the full node for `zoomed`. We should change this to encode the path instead `root.path(to: zoomed)`. Let's do this by implementing a custom Codable for SplitTree.
- 2 Look at @macos/Sources/Features/Terminal/TerminalRestorable.swift . Copy the same "currentVersion" technique to add versioning to the SplitTree codable.
Let me understand the bug first:
The bug is that when a split is zoomed and window-save-state is enabled, the zoomed split gets "forever stuck" and can't be unzoomed, closed, or split further.
The root cause mentioned is that SplitTree is encoding the full node for
zoomedinstead of encoding the path to the zoomed node.The solution is to implement a custom Codable for SplitTree that encodes/decodes the path to the zoomed node instead of the full node.
Let me look at the current SplitTree implementation to understand how it works:
Looking at SplitTree.swift:
- It has
root: Node?andzoomed: Node? - It implements
Codableautomatically (struct SplitTree<ViewType: NSView & Codable>: Codable) - There's already a
Pathstruct androot.path(to: node)method available
The plan:
- First, let me check the current TODO list
- Plan this task using todo_write
- Look more closely at the SplitTree code to understand the current structure
- Implement custom Codable for SplitTree that:
- For encoding: stores the path to zoomed node instead of the full node
- For decoding: reconstructs the zoomed node from the path
- Test the build to make sure it compiles
Let me start by checking if there are existing TODOs, then plan this task.
I'll fix this bug by implementing custom Codable for SplitTree that stores the path to the zoomed node instead of the full node.
Now I need to look at the Path struct and make sure it's Codable, and check what methods are available for path-to-node resolution.
I see that Path and Path.Component are not currently Codable. I need to make them Codable first, then implement the custom Codable for SplitTree.