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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- **Your model tries the journeys too.** Ask it to book the hike, or to give up halfway: it clicks through the mockup
looking at each screen, as a user would, and tells you where it got stuck, the clicks that did nothing and the screens
no click opens.

### Fixed

- In the light theme, a screen being presented or tried has the thin outline it has on the board: one with a white or
cream ground no longer fades into the window.

## [0.5.0] - 2026-12-03

### Added
Expand Down
4 changes: 2 additions & 2 deletions DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ A status color tints its own background at `1f` alpha (the status pill).

Every dark color has a light one that takes its role (`lightColors` in `theme.go`, the one place they are
listed): ground `#f7f1eb` with `#dbccbf` dots, white surfaces with `#ebe0d7` borders, text `#241a15`,
`#5e4c43`, `#948177`, the accent a deeper `#d93d1f` for contrast on white. Frames get a hairline
`#ebe0d7` edge, white on the light ground. The theme follows the system's (read when the app opens) until
`#5e4c43`, `#948177`, the accent a deeper `#d93d1f` for contrast on white. Frames, and the screen
presented or tried, get a hairline `#ebe0d7` edge, or a white or cream one is lost in the light ground. The theme follows the system's (read when the app opens) until
the user picks Light or Dark in the settings; System, the default, follows it again.

### Shape
Expand Down
1 change: 1 addition & 0 deletions docs/AUTHORING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ What a mockup of more than one screen needs, learned building lich's screens wit
- 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.
The model tries it with `try_journey`: ask it to book, sign up or give up halfway, and to tell where it got stuck.
- `theme=light` on a screen draws it in another look of the registry; copy a screen to compare both.
- Files are for versioning: `export` writes a project as one `.gockup`, `import` reads one back (its own
`import "lib/…"` lines inlined). Outside a project, a library file shared with `import` still works.
Expand Down
3 changes: 2 additions & 1 deletion docs/GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ Tools: `list_design_systems`, `add_design_system`, `remove_design_system`, `list
`list_places`, `place_screens` (where frames sit on the board, moved as one undoable change),
`write_item` (one screen, fragment, note or journey; the whole project is validated, nothing invalid is written), `edit_item`
(replace a snippet), `rename_item` (the gotos, calls, notes and journeys pointing at it follow), `delete_item`, `move_item`, `validate_item`, `render_screen` (PNG via the headless GPU renderer),
`render_overview` (every screen on one PNG). Keep the projects window open to watch the model work live.
`render_overview` (every screen on one PNG), `try_journey` (the model walks a journey click by click, with live widgets, and is told
what each click did, the ones that did nothing and the screens no click opens). Keep the projects window open to watch the model work live.

The `from_app` prompt (`/mcp__gockup__from_app` in Claude Code) mocks up an app you already have: the
model reads its UI code and rebuilds every screen as a project, with your design system's components,
Expand Down
3 changes: 3 additions & 0 deletions docs/ceilings.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ file is the trap alone.
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.
- **`try_journey` starts over at every call** and does all its clicks again: nothing is kept between calls, so a project
changed in between is walked as it is now. It clicks and scrolls and does not type, as nothing reads what is typed.
A click by text finds its place as a goto's is found, so what a list has not scrolled to is not there.
- **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
Expand Down
7 changes: 6 additions & 1 deletion journeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ func (s *Session) gotoAreas(sc *dsl.Screen, px float32) []image.Rectangle {
Constraints: layout.Exact(image.Pt(metric.Dp(unit.Dp(sc.Width)), metric.Dp(unit.Dp(sc.Height)))),
}, sc)
router.Frame(ops)
areas := make([]image.Rectangle, len(nodes))
return areasIn(&router, len(nodes))
}

// areasIn are where the n nodes measured in the router's last frame were laid out.
func areasIn(router *input.Router, n int) []image.Rectangle {
areas := make([]image.Rectangle, n)
for _, n := range router.AppendSemantics(nil) {
if at, ok := strings.CutPrefix(n.Desc.Label, areaLabel); ok {
if i, err := strconv.Atoi(at); err == nil {
Expand Down
23 changes: 22 additions & 1 deletion mcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ screen "Name" width=360 height=640 theme=dark { // size in dp, defaults 360x64
journey "Create account" from="Login" via="Register" to="Welcome"
from is where it starts, to the screen it is meant to get to (left out, one nothing leads out of). The board shows
the shortest way; via, optional, is a screen it must go through when a shorter one skips the point. Link every
step with a goto: the journey tells the clicks that did nothing and the screens no click opens.
step with a goto: the journey tells the clicks that did nothing and the screens no click opens. try_journey walks it
with your clicks: do it after linking a flow, and tell the user where you got stuck.
- Notes give context on the board, for the user and for you: why a screen is the way it is, what is
still to do. One line each, on its own item:
note "Why the eye" on="Login" status=decided x=40 y=600 text="The user asked for it in the review."
Expand Down Expand Up @@ -235,6 +236,7 @@ func (s *mcpServer) handle(req rpcRequest) (any, *rpcError) {
"when the user's own is not installed, import it first (it tells how: write an adapter, then add_design_system), and tell the user you are doing so. " +
"Then list_projects; create_project names the design system, and list_components shows its components. " +
"Add or replace one screen or fragment per write_item, change one with edit_item and always check them with render_screen. " +
"Once a flow is linked, write its journey and walk it with try_journey before showing it. " +
"To version a project in the user's repository, run `gockup export \"<project>\" -o <file>.gockup` in a shell: it writes the file and the project's assets beside it.",
}, nil
case "ping":
Expand Down Expand Up @@ -362,6 +364,21 @@ var (
"project": projectArg,
"scale": map[string]any{"type": "number", "description": "pixels per dp, default 1"},
}, "project")},
{"name": "try_journey", "description": "Use the mockup as its user would: walk a journey from its start, with live widgets, and see where it gets stuck. " +
"Every call starts over and does all the clicks, so add one to the list after looking at the picture of where the last got to. " +
"Click what someone who only sees the picture would, not what the source says is linked; then tell the user the clicks that did nothing, " +
"the screens no click opens and where it was not clear what to do. Nothing is written.",
"inputSchema": schema(map[string]any{
"project": projectArg,
"journey": map[string]any{"type": "string", "description": "the journey's name"},
"clicks": map[string]any{"type": "array", "description": "what is done, in order; none shows where the journey starts",
"items": map[string]any{"type": "object", "properties": map[string]any{
"text": map[string]any{"type": "string", "description": "click what says exactly this: a button's text, a field's hint"},
"x": map[string]any{"type": "number", "description": "with y, click this point instead, in dp: an icon, or one of two with the same text"},
"y": map[string]any{"type": "number"},
"scroll": map[string]any{"type": "number", "description": "turn the wheel instead of clicking, in dp, down when positive; at x and y, or the screen's middle"},
}}},
}, "project", "journey")},
}
)

Expand All @@ -382,6 +399,8 @@ func (s *mcpServer) call(name string, raw json.RawMessage) (toolResult, error) {
Group *string `json:"group"`
SVG string `json:"svg"`
DesignSystem string `json:"design_system"`
Journey string `json:"journey"`
Clicks []walkClick `json:"clicks"`
Places map[string]struct {
X float32 `json:"x"`
Y float32 `json:"y"`
Expand Down Expand Up @@ -516,6 +535,8 @@ func (s *mcpServer) call(name string, raw json.RawMessage) (toolResult, error) {
return s.renderScreen(args.Project, args.Screen, args.Scale, args.State)
case "render_overview":
return s.renderOverview(args.Project, args.Scale)
case "try_journey":
return s.tryJourney(args.Project, args.Journey, args.Clicks)
}
return toolResult{}, fmt.Errorf("unknown tool %q", name)
}
Expand Down
5 changes: 5 additions & 0 deletions present.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"gioui.org/layout"
"gioui.org/op"
"gioui.org/op/clip"
"gioui.org/op/paint"
"gioui.org/unit"

"github.com/lichdotdev/gockup/dsl"
Expand Down Expand Up @@ -117,6 +118,10 @@ func layoutAlone(gtx layout.Context, sess *Session, sc *dsl.Screen, left int) la
free := room.Sub(image.Pt(left, 2*gtx.Dp(presentRoom)))
k := min(1, float32(free.X)/float32(size.X), float32(free.Y)/float32(size.Y))
at := f32.Pt(float32(left), 0).Add(layout.FPt(room.Sub(image.Pt(left, 0))).Sub(layout.FPt(size).Mul(k)).Mul(0.5))
w := gtx.Dp(1)
edge := image.Rectangle{Min: at.Round(), Max: at.Add(layout.FPt(size).Mul(k)).Round()}.Inset(-w)
// under the screen, not stroked as the board's: a 1px stroke there falls on half pixels and fades
paint.FillShape(gtx.Ops, frameEdge, clip.UniformRRect(edge, int(float32(gtx.Dp(presentRadius))*k)+w).Op(gtx.Ops))
defer op.Affine(f32.Affine2D{}.Scale(f32.Point{}, f32.Pt(k, k)).Offset(at)).Push(gtx.Ops).Pop()
defer clip.UniformRRect(image.Rectangle{Max: size}, gtx.Dp(presentRadius)).Push(gtx.Ops).Pop()
fgtx := gtx
Expand Down
47 changes: 47 additions & 0 deletions present_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package gockup

import (
"image"
"image/color"
"strings"
"testing"

Expand Down Expand Up @@ -40,3 +42,48 @@ func TestPresenting(t *testing.T) {
}
s.frame()
}

// A screen as light as the window's ground still shows where it ends in the
// light theme, presented or tried.
func TestAScreenAloneHasAnEdgeInTheLight(t *testing.T) {
// what the eye takes for a line, in levels of a color's channel
const seen = 8
t.Cleanup(func() { applyTheme(false) })
reg := NewRegistry()
reg.Background = color.NRGBA{R: 0xfa, G: 0xf7, B: 0xf1, A: 0xff}
s := newStudioDrawing(t, reg, dsl.Decl{Kind: dsl.JourneyDecl, Name: "Look", Text: `journey "Look" from="A"`})
s.a.setTheme(true)
s.act("sel:screen:A")
for _, c := range []struct {
action string
left int
}{{"present", 0}, {"try:Look", s.a.sidebarSpan()}} {
s.act(c.action)
window := *s.a.view
window.Width, window.Height = 1200, 800
img, err := s.a.uiSess.render(&window, 1)
if err != nil {
t.Fatal(err)
}
x, y := c.left+(1200-c.left-360)/2, (800-640)/2
if got := img.RGBAAt(x+180, y+320); got != color.RGBA(reg.Background) {
t.Fatalf("%s: the middle of the screen is %v", c.action, got)
}
ground := img.RGBAAt(x-20, y+320)
for side, at := range map[string][2]image.Point{
"left": {{X: x, Y: y + 320}, {X: 1}},
"right": {{X: x + 360, Y: y + 320}, {X: 1}},
"top": {{X: x + 180, Y: y}, {Y: 1}},
"bottom": {{X: x + 180, Y: y + 640}, {Y: 1}},
} {
most := 0
for d := -2; d <= 2; d++ {
p := img.RGBAAt(at[0].X+d*at[1].X, at[0].Y+d*at[1].Y)
most = max(most, min(int(ground.B), int(reg.Background.B))-int(p.B))
}
if most < seen {
t.Errorf("%s: the %s edge is %d levels from the ground, want %d", c.action, side, most, seen)
}
}
}
}
22 changes: 16 additions & 6 deletions render.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,21 @@ func offscreenOf(size image.Point) (*headless.Window, error) {
return w, nil
}

// lockLayout waits for this session's turn to lay out off screen, and returns
// what gives it back.
func (s *Session) lockLayout() func() {
layoutTurn.Lock()
if s.layoutMu != nil {
s.layoutMu.Lock()
}
return func() {
if s.layoutMu != nil {
s.layoutMu.Unlock()
}
layoutTurn.Unlock()
}
}

func (s *Session) render(sc *dsl.Screen, scale float32) (*image.RGBA, error) {
return s.renderLaidOutAt(sc, scale, scale)
}
Expand All @@ -185,12 +200,7 @@ func (s *Session) renderLaidOutAt(sc *dsl.Screen, layoutPx, scale float32) (*ima
// the first frame starts enter animations (a dialog growing in); the one
// shot is laid out once they have settled
frame := func(at time.Duration) {
layoutTurn.Lock()
defer layoutTurn.Unlock()
if s.layoutMu != nil {
s.layoutMu.Lock()
defer s.layoutMu.Unlock()
}
defer s.lockLayout()()
ops.Reset()
k := scale / layoutPx
op.Affine(f32.AffineId().Scale(f32.Point{}, f32.Pt(k, k))).Add(ops)
Expand Down
Binary file modified site/img/tried-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ var (
}()
)

// frameEdge outlines the frames that have no other outline: none in the dark,
// where white frames stand out; a hairline in the light.
// frameEdge outlines the board's frames that have no other outline and the
// screen presented or tried: none in the dark, where white frames stand out; a
// hairline in the light.
var frameEdge color.NRGBA

// applyTheme sets the Go code's colors for the light theme or the dark one.
Expand Down
Loading
Loading