Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- **Screens that change by a click**: while a journey is tried, a click can show a field's error, open a menu or go to a
form's next step on the same screen, with what was typed still there. A screen declares its `state`, `set` changes it
and `When` shows what goes with it; your model writes them, and `render_screen` draws a screen in any state.
- **Settings › Updates**: gockup tells when there is a new version, what is in it, and updates itself in a click, opening
again where you were. Installed from the AUR or Homebrew, it gives the command instead. It looks once a day, when it
opens, and you can turn that off.

## [0.4.0] - 2026-12-03

### Added
Expand Down
18 changes: 17 additions & 1 deletion DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ Present shows screens; trying a journey is using the app, to find where it fails
stays as it was left. There is no next: only the app's own links lead on.
- What is typed stays on the way back; starting over clears it. A step back undoes the step, the app's own back
(`goto=back`) is one more.
- A click that changes the screen's state (`set`) is a step too, on the same screen: "With error=yes: you are here", and
the state beside the screen's name in the bottom pill. Only what is not as the screen starts is told. The state lasts
from a screen to the next; a step back undoes it and starting over clears it. The board and Present show every screen
as it starts.
- At the end, the journey's `to` or a screen nothing leads out of, once through its `via`, the path says "Got to Welcome in 4 steps" and
**what it showed**: the clicks that did nothing, in yellow, and the screens of its pages no click opens, in blue.
Three names at most, then "and 2 more"; with neither, one green line says so.
Expand All @@ -157,10 +161,22 @@ Present shows screens; trying a journey is using the app, to find where it fails
- Laid out as a project: the sections are rows in the floating sidebar, under "← Settings"; the open one
fills the rest of the window as a card titled level with the sidebar's title. The ground is the plain
one of the pages: the dots are the board's alone.
- The sections are Appearance and MCP. A part of a section is its name at 15 over a line at 12, then what it holds.
- The sections are Appearance, MCP and Updates. A part of a section is its name at 15 over a line at 12, then what it holds.
- Theme is a selector of the app in miniature in each theme (ground, sidebar, top bar, a frame), System
showing both, overlapped; each preview keeps its own theme's colors whatever theme shows it.

## Updates

- Settings › Updates is a card with the version in use, a green check and when gockup last looked, "Look now" at its
right. With a newer one out it is that one, in coral: what is new, six changes at most from the release's notes, and
"Update and restart". The section's row has a coral dot till then.
- Updating shows the megabytes and a bar, and can be cancelled. gockup then restarts where the user was. One that fails
says why under the card and leaves gockup as it was.
- **gockup replaces only what it installed.** From the AUR or Homebrew the card gives the command to copy, in the button's
place; where it cannot write, "Download" opens the release; built from source, it only says so.
- The projects page tells of a new version once, over the projects: "Not now" closes it till the next one.
- It looks once a day, when it opens. The switch at the foot of the page turns that off; "Look now" still works.

## Agents

gockup sets up its own MCP server: nothing else does, the install script included.
Expand Down
14 changes: 12 additions & 2 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,11 @@ type studio struct {
settings bool
// systemsTab is the home showing the design systems, not the projects.
systemsTab bool
// section is the settings' open section: "" is Appearance, or mcpSettings.
// section is the settings' open section: "" is Appearance, or mcpSettings
// or updateSettings.
section string
agents agentsUI
updates updatesUI
// clip is text for the clipboard, written by the next frame; copied is
// what the last action copied, "" for one that did not.
clip, copied string
Expand Down Expand Up @@ -329,10 +331,11 @@ func (sys *systems) app(db *store.DB, serve func() string) error {
a.checkAgents()
a.askAboutAgents()
}()
go a.lookByItself()
if r.src != nil {
go r.src.run(func(bin string) {
a.mu.Lock()
env := append(os.Environ(), appStateEnv+"="+a.savedState())
env := append(os.Environ(), appStateEnv+"="+a.savedState(), baseBinEnv+"="+baseBin)
a.mu.Unlock()
err := execSelf(bin, env)
r.src.setStatus("Restart into the new build failed: " + err.Error())
Expand Down Expand Up @@ -360,6 +363,8 @@ func newStudio(sys *systems, db *store.DB, invalidate func()) *studio {
a.uiSess.SetAssets(appIcons())
// both are called while a frame is laid out, with a.mu already held
a.uiSess.Goto = a.act
a.updates = updatesUI{from: gitHub, bin: baseBin, version: version(), install: installation{kind: installSource}, restart: restartInto}
a.loadUpdates()
var st appState
if err := json.Unmarshal([]byte(os.Getenv(appStateEnv)), &st); err == nil {
a.project, a.selKind, a.selName = st.Project, st.Kind, st.Name
Expand Down Expand Up @@ -825,6 +830,10 @@ func (a *studio) act(action string) {
clear(a.agents.failed)
go a.checkAgents()
}
case "update-look", "update-start", "update-cancel", "update-close", "update-page", "update-auto":
err = a.updateAct(strings.TrimPrefix(verb, "update-"))
case "update-open":
a.settings, a.section, a.menu, a.dialog = true, updateSettings, "", ""
case "settings-close":
a.settings = false
case "folder":
Expand Down Expand Up @@ -1393,6 +1402,7 @@ func (a *studio) homeScreen() string {
var b strings.Builder
b.WriteString(`screen "home" { Page {` + "\n")
a.homeHead(&b)
a.updateNotice(&b)
a.agentNotices(&b)
ps, err := a.db.Projects()
if err != nil {
Expand Down
50 changes: 48 additions & 2 deletions app.gockup
Original file line number Diff line number Diff line change
Expand Up @@ -1025,13 +1025,59 @@ fragment TrialFinding text="" where="" color="#ffcf4a" {
}

// under the app being tried: a step back, where it is, start over, the path shown or not
fragment TrialBar name="" back="#dccfc7" path="#ff9a80" pathBg="#3a2019" {
fragment TrialBar name="" state="" back="#dccfc7" path="#ff9a80" pathBg="#3a2019" {
Pill top=4 bottom=4 left=4 right=4 {
Flex axis=horizontal align=center spacing=4 {
Tip text="Step back" key="" { Box radius=999 goto="try-back" { Inset all=6 { Image src="back.svg" width=16 color=$back } } }
Inset left=4 right=4 { Text text=$name bold=true }
Inset left=4 right=4 { Flex axis=horizontal align=center spacing=6 { Text text=$name bold=true Text text=$state size=12 color="#9c8d84" } }
Tip text="Start over" key="" { Box radius=999 goto="try-restart" { Inset all=6 { Image src="restart.svg" width=16 color="#dccfc7" } } }
Tip text="Path" key="" { Box color=$pathBg radius=999 goto="try-path" { Inset all=6 { Image src="route.svg" width=16 color=$path } } }
}
}
}

// a version of gockup: the one in use, or the one out, and at the right (the Slot) what can be done
fragment UpdateHead title="" text="" icon="check.svg" color="#34e08f" tint="#34e08f26" {
Inset all=14 {
Flex axis=horizontal align=center spacing=12 {
Sized width=36 height=36 { Overlay { Box color=$tint radius=10 fill=true { Spacer } Image src=$icon width=18 color=$color } }
Flex axis=vertical spacing=2 weight=1 {
Text text=$title size=15
Text text=$text size=12 color="#9c8d84"
}
Slot
}
}
}

fragment UpdateProgress done=0.5 left=0.5 {
Inset left=14 right=14 bottom=14 {
Box color="#302824" radius=2 {
Sized height=4 {
Flex axis=horizontal {
Box color="#ff5f3d" radius=2 fill=true weight=$done { Spacer }
Spacer weight=$left
}
}
}
}
}

fragment UpdateNews {
Flex axis=horizontal spacing=10 {
Inset top=7 { Box color="#ff5f3d" radius=3 { Sized width=5 height=5 { Spacer } } }
Flex axis=vertical spacing=1 weight=1 { Slot }
}
}

fragment SwitchOn open="" {
Box color="#ff5f3d" radius=11 goto=$open {
Sized width=38 height=22 { Inset all=3 { Flex axis=horizontal { Spacer weight=1 Box color="#ffffff" radius=8 { Sized width=16 height=16 { Spacer } } } } }
}
}

fragment SwitchOff open="" {
Box color="#3a302b" radius=11 goto=$open {
Sized width=38 height=22 { Inset all=3 { Flex axis=horizontal { Box color="#9c8d84" radius=8 { Sized width=16 height=16 { Spacer } } Spacer weight=1 } } }
}
}
3 changes: 3 additions & 0 deletions board.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ func contentPrint(reg *Registry, sc *dsl.Screen, assets map[string][]byte) uint6
maphash.WriteComparable(&h, reg)
maphash.WriteComparable(&h, image.Pt(sc.Width, sc.Height))
maphash.WriteComparable(&h, sc.Theme)
for _, p := range sc.State {
maphash.WriteComparable(&h, [2]string{p.Name, p.Value.Plain()})
}
var walk func(n *dsl.Node)
walk = func(n *dsl.Node) {
maphash.WriteComparable(&h, n.Type)
Expand Down
8 changes: 8 additions & 0 deletions builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"gioui.org/text"
"gioui.org/unit"
"gioui.org/widget/material"

"github.com/lichdotdev/gockup/dsl"
)

func registerBuiltins(r *Registry) {
Expand Down Expand Up @@ -156,6 +158,12 @@ func registerBuiltins(r *Registry) {
return stacked(c.Children())(gtx)
},
})
r.Register(dsl.WhenNode, Component{
Doc: "its children, laid out by its parent as if written there, only while the screen's states have these values: " +
"When error=yes { … }, with state error=no at the screen's start",
Children: true,
Layout: func(c *Ctx) layout.Dimensions { return stacked(c.Children())(c.Gtx) },
})
r.Register("Spacer", Component{
Doc: "empty space",
Props: []Prop{
Expand Down
3 changes: 3 additions & 0 deletions docs/AUTHORING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ What a mockup of more than one screen needs, learned building lich's screens wit
- A screen per **state** of a flow (Session → Menu → Confirm); `goto="Screen"` on the node you would click
links them, so the app walks the flow; `goto=back` on a back arrow or a Cancel opens, while a journey is tried,
wherever the user came from.
- A state the user should see on the board, or that looks like another screen, is a screen of its own. One that keeps
what was typed (a field's error, an open menu, a step of a form) is a `state` with `When` and `set` in the same screen:
going to another screen starts its fields empty.
- A **journey** per thing the user came to do (`journey "Create account" from="Login" to="Welcome"`). The board
shows the shortest way there: `via="Register"` takes it through a screen that one skips. Trying it
tells the clicks that did nothing and the screens no click opens: link every step, the ways out too.
Expand Down
18 changes: 18 additions & 0 deletions docs/GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ were working (there, `goto=back` opens the screen the user came from), `note "Wh
leaves context on the board for whoever reads the project next, the model included,
`theme=` on a screen picks a look. [AUTHORING.md](AUTHORING.md) is the guide for mockups of many screens.

A screen can also change in place while a journey is tried. `state` declares what can change and how it starts, `set`
changes it on a click, and `When` has its children only while the states have the values it lists:

```
screen "Register" {
state error=no
Flex axis=vertical spacing=16 {
Editor hint="E-mail"
When error=yes { Caption text="That is not an e-mail yet" }
When error=no { Button text="Create account" set="error=yes" }
When error=yes { Button text="Create account" goto="Welcome" }
}
}
```

There are no expressions and nothing reads what is typed: a journey is played, not programmed. The board shows the screen
as it starts; `render_screen` takes the state to draw it in.

## Projects

A project holds screens and fragments (its reusable components) and draws with one design system, the one
Expand Down
15 changes: 15 additions & 0 deletions docs/ceilings.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ file is the trap alone.
- **Where a goto is on its screen comes from Gio's semantic tree** (`Session.gotoAreas`): Gio tells no widget its
place, so the screen is laid out once more, each goto labelled. It is as the screen opens, so on a live frame
scrolled by hand the ring stays where the goto was.
A goto in a `When` not shown as the screen starts has no place: its arrow leaves from the frame's edge, with no ring.
- **A `When` is never laid out**: `Ctx.Children` gives its parent what is in it, in its place, or nothing. So it takes no
`weight`, `goto` or `set`, cannot be a screen's root, and picking one in the layers outlines nothing.
- **A click that did nothing is told by the state its node keeps** (`Session.answers`): a leaf that keeps only a
`widget.Clickable`, or nothing, did nothing without a goto. An adapter with a click type of its own passes for
one that answers, so its dead buttons are not told; a bare `Box` or `Spacer` never is.
Expand Down Expand Up @@ -135,3 +138,15 @@ file is the trap alone.
only after `task install`.
- **The light mockups are copies** (`Light…` fragments, "… – light" screens), made with the same color map as
the window's theme: a change to a dark fragment does not reach its light twin; change both.

## Updates

- **The checksum is the release's own** (`checksums.txt`, from the same place): it tells a broken download, not a release
published by someone else. Nothing is signed. The new gockup must also start and tell the version it is for.
- **The gockup updated is the one the user installed** (`baseBin`), which the environment carries to the build of design
systems that runs in its place. That build is made again for the new version when it opens, with no window till it is
done.
- **Windows keeps the replaced binary** as `gockup.exe.old` until the next start, and its list of installed programs keeps
the version of the installer. On macOS the whole `gockup.app` is replaced, for its signature.
- **Only Linux's launcher stays as installed**: an update brings the binary, not the `.desktop` file nor its icon.
- **GitHub answers 60 questions an hour to an address** with no account: many windows behind one can be told 403.
15 changes: 14 additions & 1 deletion dsl/dsl.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ type Screen struct {
Width, Height int
// Theme names one of the registry's themes; "" is its default look.
Theme string
// State are the names the screen's Whens look at, with what each starts as.
State []Prop
Root *Node
Line int
// Source is the declaration's text, the comments above it included.
Expand Down Expand Up @@ -474,7 +476,13 @@ func (p *parser) screen() (*Screen, error) {
return nil, &Error{pr.Line, fmt.Sprintf("unknown screen property %q", pr.Name)}
}
}
children, err := p.block()
if _, err := p.expect(tLBrace, "{"); err != nil {
return nil, err
}
if s.State, err = p.state(); err != nil {
return nil, err
}
children, err := p.nodes()
if err != nil {
return nil, err
}
Expand All @@ -489,6 +497,11 @@ func (p *parser) block() ([]*Node, error) {
if _, err := p.expect(tLBrace, "{"); err != nil {
return nil, err
}
return p.nodes()
}

// nodes reads the rest of a block, its closing brace included.
func (p *parser) nodes() ([]*Node, error) {
var nodes []*Node
for p.peek().kind != tRBrace {
n, err := p.node()
Expand Down
6 changes: 4 additions & 2 deletions dsl/fragment.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ const Back = "back"
func IsBack(v Value) bool { return v.Kind == Ident && v.Str == Back }

// IsUniversal reports whether every node takes the prop, whatever its type.
func IsUniversal(name string) bool { return name == WeightProp || name == GotoProp }
func IsUniversal(name string) bool {
return name == WeightProp || name == GotoProp || name == SetProp
}

// SlotNode marks where a fragment places the children of the call.
const SlotNode = "Slot"
Expand All @@ -42,7 +44,7 @@ type scope struct {
func expandFile(f *File) error {
e := &expander{frags: map[string]*Fragment{}}
for _, fr := range f.Fragments {
if fr.Name == SlotNode || fr.Name == "screen" || fr.Name == "fragment" {
if fr.Name == SlotNode || fr.Name == WhenNode || fr.Name == "screen" || fr.Name == "fragment" {
return &Error{fr.Line, fmt.Sprintf("%q is reserved and cannot name a fragment", fr.Name)}
}
if prev, dup := e.frags[fr.Name]; dup {
Expand Down
65 changes: 65 additions & 0 deletions dsl/state.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package dsl

import (
"fmt"
"strings"
)

// SetProp is accepted on any node: a click on it, while a journey is tried,
// gives one of the screen's states a value, set="error=yes".
const SetProp = "set"

// WhenNode has its children only while the screen's states have the values
// it is written with, When error=yes { … }.
const WhenNode = "When"

// Plain is the value as text, the way states compare.
func (v Value) Plain() string {
if v.Kind == Number {
return v.String()
}
return v.Str
}

// ParseSet reads a set's value, the state's name and what it becomes.
func ParseSet(s string) (name, value string, ok bool) {
name, value, ok = strings.Cut(s, "=")
return name, value, ok && name != ""
}

// StateOf is what the screen's state name starts as.
func (s *Screen) StateOf(name string) (value string, ok bool) {
for _, p := range s.State {
if p.Name == name {
return p.Value.Plain(), true
}
}
return "", false
}

// state reads the states a screen's body starts with, state error=no step=1.
func (p *parser) state() ([]Prop, error) {
var all []Prop
for p.peek().kind == tIdent && p.peek().text == "state" {
kw := p.next()
props, err := p.props()
if err != nil {
return nil, err
}
if len(props) == 0 {
return nil, &Error{kw.line, "state needs a name and the value it starts with: state error=no"}
}
for _, pr := range props {
if pr.Value.Kind == Param {
return nil, &Error{pr.Line, fmt.Sprintf("state %s must start with a value, got %s", pr.Name, pr.Value)}
}
for _, had := range all {
if had.Name == pr.Name {
return nil, &Error{pr.Line, fmt.Sprintf("duplicate state %q", pr.Name)}
}
}
all = append(all, pr)
}
}
return all, nil
}
Loading
Loading