    def _build_tree_string(
        self, path: str = "/", prefix: str = "", max_depth: int = 3
    ) -> str:
        """Build a tree representation of the directory structure"""
        if max_depth <= 0:
            return ""

        lines = []
        contents = self._list_directory_contents(path)

        for i, item in enumerate(contents):
            is_last = i == len(contents) - 1
            current_prefix = "└── " if is_last else "├── "

            if item["type"] == "directory":
                icon = "📁"
                lines.append(f"{prefix}{current_prefix}{icon} {item['name']}/")

                child_prefix = prefix + ("    " if is_last else "│   ")
                subtree = self._build_tree_string(
                    item["path"], child_prefix, max_depth - 1
                )
                if subtree:
                    lines.append(subtree)
            else:
                f = self.files.get(item["path"])
                icon = f.file_type.icon if f and f.file_type else "📄"
                state = "[OPEN]" if f and f.state == "open" else ""
                lines.append(
                    f"{prefix}{current_prefix}{icon} {item['name']} {state}".rstrip()
                )

        return "\n".join(lines)

