LiveProgress
Description
LiveProgress is a single ellipsized line of progress text ("Reading documents · Encoding 57%") meant to be updated many times a second. The line element and its tooltip are created once and an update only rewrites their text, so nothing fades in, re-mounts or re-animates. An empty text hides the line with display: none instead of removing it, and the hover tooltip shows the untruncated text. A ToolCall carries one on its header row through SetProgress(...).
Usage
Create the line with LiveProgress() and write into it with .SetText(...), or follow an observable with .Stream(...); the subscription is released when the line leaves the DOM. .Clear() hides the line and keeps the element for the next update.
API reference
public sealed class LiveProgress : ComponentBase<LiveProgress, HTMLElement>A single quiet line of live progress text ("Reading documents · Encoding 57%") meant to be updated many times a second while a long-running task streams its progress. The line, and the tooltip carrying its untruncated text, are built once and never rebuilt: an update writes the new text into the elements already on screen. Nothing fades in or out, so a stream of updates reads as one line changing rather than a component being replaced. It also survives a host that refreshes itself by diffing a freshly built layout onto the DOM already on screen (DeltaComponent, and so ChatMessage): the line element the reader sees is then the one an earlier layout built and the diff keeps patching, so the tooltip follows the text of the element rather than the text a given instance was told to show, and the line opts its subtree out of the fade the diff puts on patched content.
- Namespace
- Tesserae
- Inheritance
- ComponentBase<LiveProgress, HTMLElement> → LiveProgress
Constructors
| Name | Description |
|---|---|
| LiveProgress | Initializes a new instance of this class. |
Properties
| Name | Description |
|---|---|
| Text | Gets the text currently shown by the component. Read from the element rather than remembered, so it stays true under a host that patches the line's text itself. |
| IsEmpty | Returns a value indicating whether the component currently shows any progress. |
public string TextGets the text currently shown by the component. Read from the element rather than remembered, so it stays true under a host that patches the line's text itself.
Methods
| Name | Description |
|---|---|
| SetText | Writes the given progress into the line already on screen. An empty text hides the line without removing it, so the next update brings back the same element. |
| Clear | Clears the progress, hiding the line until the next update. |
| Stream | Streams the progress from the given observable: every value it publishes is written into the line. The subscription is released when the component leaves the DOM, and a second call replaces the source this component follows. |
| StopStreaming | Stops following the observable passed to Stream, keeping the text it last wrote. |
| WithTooltip | Configures whether hovering the line shows its full text as a tooltip. On by default, as the line is ellipsized to the width it is given. |
| NoTooltip | Configures the component to show no tooltip when hovered. |
| Render | Renders the component's root HTML element. |
public LiveProgress SetText(string text)Writes the given progress into the line already on screen. An empty text hides the line without removing it, so the next update brings back the same element.
public LiveProgress Clear()Clears the progress, hiding the line until the next update.
public LiveProgress Stream(IObservable<string> source)Streams the progress from the given observable: every value it publishes is written into the line. The subscription is released when the component leaves the DOM, and a second call replaces the source this component follows.
public LiveProgress StopStreaming()Stops following the observable passed to Stream, keeping the text it last wrote.
public LiveProgress WithTooltip(bool value = true)Configures whether hovering the line shows its full text as a tooltip. On by default, as the line is ellipsized to the width it is given.
public LiveProgress NoTooltip()Configures the component to show no tooltip when hovered.