Harden

From nicolaiprodromov/puree · View interactive version

Harden is an AI agent skill from the GitHub repository nicolaiprodromov/puree. Improve Puree UI (YAML/SCSS/Python) resilience through text overflow handling, error states, and edge case management.

How to use this skill

Skill file

Strengthen Puree interfaces against edge cases, errors, missing resources, and real-world usage scenarios that break idealized designs.

Assess Hardening Needs

Identify weaknesses and edge cases:

  1. Test with extreme inputs:
  1. Test error scenarios:
  1. Test resource scenarios:

CRITICAL: Designs that only work with perfect data aren't production-ready. Harden against reality.

Hardening Dimensions

Systematically improve resilience:

Text Overflow & Wrapping

Long text handling in Puree:

// Single line with ellipsis — works in Puree
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

Puree supports text-overflow: ellipsis and white-space: nowrap. Use these on any container that displays dynamic text.

Flex/Grid overflow:

// Prevent flex items from overflowing
.flex_item {
  min-width: 0;
  overflow: hidden;
}

// Prevent grid items from overflowing
.grid_item {
  min-width: 0;
  min-height: 0;
}

Text sizing considerations:

Example — safe text container:

.dynamic_label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  min-width: 0;
}

Error Handling in Python

Wrap Blender data access in try/except:

def main(self, app):
    def on_click(container):
        try:
            obj = bpy.context.active_object
            if obj is None:
                status_label = app.find("status_label")
                status_label.text = "No active object selected"
                status_label.mark_dirty()
                return

            name_label = app.find("object_name")
            name_label.text = obj.name
            name_label.mark_dirty()
        except Exception as e:
            error_label = app.find("error_text")
            error_label.text = f"Error: {str(e)}"
            error_label.mark_dirty()

    app.find("refresh_button").click.append(on_click)
    return app

Guard against missing containers:

def safe_find(app, name):
    """Find a container, return None if not found."""
    try:
        return app.find(name)
    except:
        return None

def on_click(container):
    label = safe_find(app, "status_label")
    if label:
        label.text = "Updated"
        label.mark_dirty()

Handle Blender state changes:

mark_dirty() Resilience

Always call mark_dirty() after property changes:

# ❌ Bad: text changes but UI doesn't update
container.text = "New value"

# ✅ Good: UI updates to reflect new text
container.text = "New value"
container.mark_dirty()

Batch property changes before marking dirty:

# ✅ Good: one mark_dirty() for multiple changes
container.text = "Updated"
container.set_property('background-color', 'rgba(255,0,0,0.2)')
container.mark_dirty()

Missing Resource Handling

Missing images:

Missing fonts:

Example — fallback styling:

// Looks acceptable even without background image
.card_with_image {
  background-color: #2a2d35;
  border-radius: 8px;
  padding: 16px;
}

Edge Cases & Boundary Conditions

Empty states:

Example — empty state in YAML:

object_list:
  style: object_list
  empty_message:
    style: empty_state
    text: 'No objects found. Select objects in the viewport.'
    font: NeueMontreal-Regular
.empty_state {
  color: rgba(180, 180, 180, 0.6);
  font-size: 13px;
  text-align: center;
  --text-align-v: center;
  padding: 20px;
}

Loading states:

Large datasets:

Concurrent operations:

is_processing = False

def on_click(container):
    global is_processing
    if is_processing:
        return
    is_processing = True
    
    try:
        # ... do work ...
        pass
    finally:
        is_processing = False

Input Validation

Validate data in Python before displaying:

def safe_display_name(name, max_length=30):
    """Truncate long names for display."""
    if len(name) > max_length:
        return name[:max_length - 3] + "..."
    return name

SCSS Defensive Patterns

Always constrain containers:

// ❌ Bad: content can overflow
.label {
  font-size: 14px;
}

// ✅ Good: overflow handled gracefully
.label {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

Use percentage widths with constraints:

.panel_content {
  width: 100%;
  max-width: 600px;
  min-width: 150px;
}

Handle visibility for conditional content:

.error_message {
  display: none;
  color: #e74c3c;
  font-size: 12px;
}

Then show/hide via Python:

def show_error(app, message):
    error = app.find("error_message")
    error.text = message
    error.set_property('display', 'flex')
    error.mark_dirty()

def hide_error(app):
    error = app.find("error_message")
    error.set_property('display', 'none')
    error.mark_dirty()

Testing Strategies

Manual testing:

Edge case checklist:

IMPORTANT: Hardening is about expecting the unexpected. Real Blender users will do things you never imagined.

NEVER:

Verify Hardening

Test thoroughly with edge cases:

Remember: You're hardening for production reality, not demo perfection. Expect users to have unexpected Blender configurations, missing files, and edge-case data. Build resilience into every container and every Python handler.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.