gum-tool-output

$npx mdskill add vchelaru/Gum/gum-tool-output

Manage Gum output messages and errors via IOutputManager.

  • Adds timestamped lines or error prefixes to the Output tab.
  • Injects IOutputManager into agents for direct output calls.
  • Uses IGuiCommands.PrintOutput for background thread marshaling.
  • Stores output as a single string capped at 50,000 characters.

SKILL.md

.github/skills/gum-tool-outputView on GitHub ↗
---
name: gum-tool-output
description: Reference guide for Gum's Output tab system. Load this when working on the Output tab, IOutputManager, MainOutputViewModel, GuiCommands.PrintOutput, or adding output/error messages to the tool.
---

# Gum Tool Output System Reference

## Architecture

**`IOutputManager`** (`Gum/Managers/MainOutputViewModel.cs`) — interface with two methods:
- `AddOutput(string)` — appends a timestamped line
- `AddError(string)` — appends a timestamped line prefixed with `"ERROR:  "` (two spaces)

**`MainOutputViewModel`** — implements `IOutputManager`. Stores all output as a single `OutputText` string (not a list). Registered as a singleton in DI, aliased as both `MainOutputViewModel` and `IOutputManager`.

**`MainOutputPlugin`** — `InternalPlugin` that creates the Output tab at `TabLocation.RightBottom`.

## How to Write Output

Inject `IOutputManager` and call `AddOutput` or `AddError` directly — this is the standard approach. Callers must already be on the UI thread.

`IGuiCommands.PrintOutput` is a thin wrapper around `AddOutput` that marshals to the UI dispatcher — use this when calling from a background thread. There is **no `PrintError` equivalent** in `IGuiCommands`; callers needing `AddError` from a background thread must dispatch manually.

## Non-Obvious Behaviors

- **Buffer cap**: `OutputText` is capped at 50,000 chars. When exceeded, it is trimmed to the last 25,000 chars — oldest output is silently discarded.
- **No dispatcher in `IOutputManager`**: `AddOutput`/`AddError` write directly to the `OutputText` property with no thread marshaling. Calling from a background thread will throw.
- **Auto-scroll**: The `TextBox` in the view uses `TextBoxAutoScroll.AutoScrollToEnd="True"` — new output scrolls into view automatically.

## Key Files

| File | Purpose |
|------|---------|
| `Gum/Managers/MainOutputViewModel.cs` | `IOutputManager` interface + `MainOutputViewModel` implementation |
| `Gum/Commands/GuiCommands.cs` | `PrintOutput` — dispatcher-safe wrapper |
| `Gum/Commands/IGuiCommands.cs` | `PrintOutput` declaration |
| `Gum/Plugins/InternalPlugins/Output/MainOutputPlugin.cs` | Registers the Output tab |
| `Gum/Plugins/InternalPlugins/Output/MainOutputPluginView.xaml` | Output tab view (TextBox + clear button) |
| `Gum/Services/Builder.cs` | DI registration of `MainOutputViewModel` as `IOutputManager` |

More from vchelaru/Gum

SkillDescription
bump-nuget-versionBump the NuGet package versions for all 12 Gum projects (11 libraries + GumCli). Queries NuGet to check if a version exists for today, then sets the new version to YYYY.M.D.V where V increments from the latest published version today (or starts at 1). Creates a release branch named ReleaseCode_YYYY_M_D_V, commits the changes, and pushes. Run this before triggering the nuget release workflow.
gum-cliReference guide for GumCli — the headless command-line tool for Gum projects. Load this when working on gumcli commands (new, check, codegen, codegen-init), Gum.ProjectServices, HeadlessErrorChecker, ProjectLoader, HeadlessCodeGenerationService, CodeGenerationAutoSetupService, or the FormsTemplateCreator.
gum-docs-writingReference guide for writing Gum documentation in GitBook markdown. Load when writing or editing docs/ files, adding pages to SUMMARY.md, using GitBook hints/figures, linking between pages, or adding images.
gum-forms-behaviorsCovers Gum's behaviors system and the design-time → runtime Forms wrapping lifecycle. Load this when working on BehaviorSave, ElementBehaviorReference, StandardFormsBehaviorNames, FormsUtilities.RegisterFromFileFormRuntimeDefaults, DefaultFromFileXxxRuntime classes, or when investigating why Forms properties cannot be set at design time in the Gum tool.
gum-forms-controlsReference guide for Forms controls — classes inheriting from FrameworkElement. Load this when working on Button, CheckBox, ListBox, ComboBox, TextBox, ScrollViewer, or any class in Gum.Forms.Controls (or FlatRedBall.Forms.Controls). Also load when working on FrameworkElement itself, the Visual/InteractiveGue relationship, state machines, DefaultVisuals, or ReactToVisualChanged.
gum-forms-default-visualsReference guide for Forms DefaultVisuals — the code-only visual classes that back Forms controls. Load when working on ButtonVisual, any *Visual class in DefaultVisuals/, Styling, DefaultFormsTemplates registration, or building custom code-only Forms visuals.
gum-forms-itemscontrolReference guide for ItemsControl and ListBox — the Items/ListBoxItems relationship, templates, InnerPanel sync, and gotchas. Load this when working on ItemsControl, ListBox, ListBoxItem, VisualTemplate, FrameworkElementTemplate, Items collection behavior, ListBoxItems desync, or adding/removing items from a list box.
gum-layout>
gum-layout-engine>
gum-localizationReference guide for Gum's runtime localization system — ILocalizationService, CSV/RESX loading, Text vs TextNoTranslate paths, Forms control localization patterns, and gotchas.