Improves helder

This commit is contained in:
2026-10-05 09:24:25 +02:00
parent 8fafea4fc3
commit 336987d821
44 changed files with 3454 additions and 542 deletions
+36 -12
View File
@@ -39,24 +39,48 @@ public enum ColumnLayout {
return ColumnWidths(sourceControl: (w * 0.15).rounded(), explorer: (w * 0.15).rounded(), agent: (w * agentShare).rounded())
}
/// Scales the fixed columns down so the editor keeps `minEditorWidth`; unchanged when they fit.
public static func fitted(_ widths: ColumnWidths, windowWidth: Double, sourceControlVisible: Bool) -> ColumnWidths {
let splitters = (sourceControlVisible ? 3.0 : 2.0) * splitterWidth
let budget = windowWidth - splitters - minEditorWidth
let total = (sourceControlVisible ? widths.sourceControl : 0) + widths.explorer + widths.agent
/// Scales the fixed columns down so the flex column keeps `minEditorWidth`; unchanged when they fit.
/// Hidden columns keep their width for when they come back.
public static func fitted(_ widths: ColumnWidths, windowWidth: Double, visible: ColumnVisibility) -> ColumnWidths {
let agentIsFixed = visible.agent && visible.editor
let flexMinimum = visible.editor || visible.agent ? minEditorWidth : 0
let budget = windowWidth - Double(visible.splitterCount) * splitterWidth - flexMinimum
let total = (visible.sourceControl ? widths.sourceControl : 0) + (visible.explorer ? widths.explorer : 0)
+ (agentIsFixed ? widths.agent : 0)
guard total > budget, total > 0 else { return widths }
let k = max(0, budget) / total
return ColumnWidths(
sourceControl: sourceControlVisible ? (widths.sourceControl * k).rounded(.down) : widths.sourceControl,
explorer: (widths.explorer * k).rounded(.down),
agent: (widths.agent * k).rounded(.down)
sourceControl: visible.sourceControl ? (widths.sourceControl * k).rounded(.down) : widths.sourceControl,
explorer: visible.explorer ? (widths.explorer * k).rounded(.down) : widths.explorer,
agent: agentIsFixed ? (widths.agent * k).rounded(.down) : widths.agent
)
}
/// The widest the agent column may be dragged: until the editor would drop below its minimum.
public static func maxAgentWidth(windowWidth: Double, widths: ColumnWidths, sourceControlVisible: Bool) -> Double {
let splitters = (sourceControlVisible ? 3.0 : 2.0) * splitterWidth
let others = (sourceControlVisible ? widths.sourceControl : 0) + widths.explorer
return max(minEditorWidth, windowWidth - splitters - others - minEditorWidth)
public static func maxAgentWidth(windowWidth: Double, widths: ColumnWidths, visible: ColumnVisibility) -> Double {
let others = (visible.sourceControl ? widths.sourceControl : 0) + (visible.explorer ? widths.explorer : 0)
return max(minEditorWidth, windowWidth - Double(visible.splitterCount) * splitterWidth - others - minEditorWidth)
}
}
/// Which of the four columns are shown. A hidden column keeps its width and its contents.
public struct ColumnVisibility: Sendable, Equatable {
public var sourceControl: Bool
public var explorer: Bool
public var editor: Bool
public var agent: Bool
public init(sourceControl: Bool = true, explorer: Bool = true, editor: Bool = true, agent: Bool = true) {
self.sourceControl = sourceControl
self.explorer = explorer
self.editor = editor
self.agent = agent
}
public static let all = ColumnVisibility()
/// One splitter between each pair of neighbouring visible columns.
public var splitterCount: Int {
max(0, [sourceControl, explorer, editor, agent].filter { $0 }.count - 1)
}
}
@@ -0,0 +1,128 @@
import SwiftUI
/// One button in a `ButtonGroup`. A toggle carries a state dot; an action has none.
public struct GroupItem {
public enum Kind: Equatable {
case action
case toggle(isOn: Bool)
}
var label: String
var keys: String?
var kind: Kind
var tip: Text
var action: () -> Void
public init(_ label: String, keys: String? = nil, kind: Kind, tip: Text, action: @escaping () -> Void) {
self.label = label
self.keys = keys
self.kind = kind
self.tip = tip
self.action = action
}
}
/// The title bar's shared button treatment: buttons edge to edge in one hairline box, a hairline between each.
public struct ButtonGroup: View {
var items: [GroupItem]
var tipEdge: HorizontalAlignment
public init(_ items: [GroupItem], tipEdge: HorizontalAlignment = .leading) {
self.items = items
self.tipEdge = tipEdge
}
public var body: some View {
HStack(spacing: 0) {
ForEach(Array(items.enumerated()), id: \.element.label) { index, item in
GroupButton(item: item, isFirst: index == 0, isLast: index == items.count - 1)
.tip(item.tip, edge: tipEdge)
}
}
.fixedSize()
.overlay(RoundedRectangle(cornerRadius: Metrics.radiusSmall).strokeBorder(Palette.raised, lineWidth: Metrics.hairline))
}
}
/// The fill follows the group's rounded ends; the group is not clipped, so the tooltips can hang below it.
private struct GroupButton: View {
var item: GroupItem
var isFirst: Bool
var isLast: Bool
@State private var isHovered = false
var body: some View {
Button(action: item.action) {
HStack(spacing: Metrics.groupButtonGap) {
if case .toggle = item.kind {
Circle().fill(dotColor).frame(width: Metrics.groupButtonDot, height: Metrics.groupButtonDot)
}
Text(item.label).typeRole(Typography.button).foregroundStyle(labelColor)
if let keys = item.keys {
Text(keys).typeRole(Typography.keycapSmall).foregroundStyle(isOff ? Palette.text4 : Palette.amber)
}
}
.lineLimit(1)
.fixedSize()
.padding(Metrics.groupButtonPadding)
.background(fill, in: UnevenRoundedRectangle(cornerRadii: corners))
.overlay(alignment: .leading) {
if !isFirst { Rectangle().fill(Palette.raised).frame(width: Metrics.hairline) }
}
.contentShape(Rectangle())
}
.buttonStyle(.plain)
.onHover { isHovered = $0 }
.accessibilityAddTraits(isOn ? .isSelected : [])
.animation(Metrics.smallControlTransition, value: isHovered)
.animation(Metrics.smallControlTransition, value: item.kind)
}
private var isOn: Bool { item.kind == .toggle(isOn: true) }
private var isOff: Bool { item.kind == .toggle(isOn: false) }
private var labelColor: Color {
isOn ? Palette.text1 : isOff ? Palette.text4 : Palette.text3
}
private var dotColor: Color {
isOn ? Palette.amber : Palette.text5
}
private var fill: Color {
isOn ? Palette.amberTint : isHovered ? Palette.hover : .clear
}
private var corners: RectangleCornerRadii {
let r = Metrics.radiusSmall
return RectangleCornerRadii(topLeading: isFirst ? r : 0, bottomLeading: isFirst ? r : 0,
bottomTrailing: isLast ? r : 0, topTrailing: isLast ? r : 0)
}
}
/// The icon-only title-bar control (the `?`): a 26pt square with a hairline border.
public struct ToolbarIconButton: View {
var glyph: String
var action: () -> Void
@State private var isHovered = false
public init(_ glyph: String, action: @escaping () -> Void) {
self.glyph = glyph
self.action = action
}
public var body: some View {
Button(action: action) {
Text(glyph)
.typeRole(Typography.keycap)
.foregroundStyle(isHovered ? Palette.text1 : Palette.text4)
.frame(width: Metrics.toolbarIconButton, height: Metrics.toolbarIconButton)
.background(isHovered ? Palette.hover : .clear, in: RoundedRectangle(cornerRadius: Metrics.radiusSmall))
.overlay(RoundedRectangle(cornerRadius: Metrics.radiusSmall).strokeBorder(Palette.raised, lineWidth: Metrics.hairline))
.contentShape(Rectangle())
}
.buttonStyle(.plain)
.onHover { isHovered = $0 }
.animation(Metrics.smallControlTransition, value: isHovered)
}
}
+2 -12
View File
@@ -5,10 +5,6 @@ public struct Keycap: View {
public enum Style {
/// Amber glyph, raised border.
case normal
/// On an active toolbar toggle: the border turns amber.
case active
/// On a toggle that is off by meaning: glyph and border step back to text-4.
case muted
/// On an amber fill (primary button): ink glyph, ink border.
case onAmber
/// On an amber-deep fill (destructive button): light glyph, light border.
@@ -25,10 +21,6 @@ public struct Keycap: View {
role = small ? Typography.keycapSmall : Typography.keycap
}
public init(_ keys: String, highlighted: Bool) {
self.init(keys, style: highlighted ? .active : .normal)
}
public var body: some View {
Text(keys)
.typeRole(role)
@@ -41,8 +33,7 @@ public struct Keycap: View {
private var glyph: Color {
switch style {
case .normal, .active: Palette.amber
case .muted: Palette.text4
case .normal: Palette.amber
case .onAmber: Palette.ink
case .onDeep: Palette.onDeep
}
@@ -50,8 +41,7 @@ public struct Keycap: View {
private var border: Color {
switch style {
case .normal, .muted: Palette.raised
case .active: Palette.amberKeycapBorder
case .normal: Palette.raised
case .onAmber: Palette.inkKeycapBorder
case .onDeep: Palette.onDeep.opacity(0.4)
}
@@ -1,11 +1,11 @@
import SwiftUI
/// The frame every overlay sits in: a flat ink scrim (no blur) and a `panel` card with a hairline border,
/// radius 8 and the overlay shadow. `.inset` fills the window minus 34pt; `.sized` centres a fixed-width card
/// radius 8 and the overlay shadow. `.inset` fills the window minus 34pt, up to 1200pt wide; `.sized` centres a fixed-width card
/// at the top. A click on the scrim calls `onDismiss`.
public struct OverlayShell<Content: View>: View {
public enum Placement {
/// Search, Diff: the whole window minus the 34pt inset.
/// Search, Diff: the whole window minus the 34pt inset, at most `insetOverlayMaxWidth` wide.
case inset
/// A card of this width, top-aligned inside the inset.
case sized(width: CGFloat)
@@ -36,7 +36,7 @@ public struct OverlayShell<Content: View>: View {
switch placement {
case .inset:
OverlayCard { content }
.frame(maxWidth: .infinity, maxHeight: .infinity)
.frame(maxWidth: Metrics.insetOverlayMaxWidth, maxHeight: .infinity)
case let .sized(width):
OverlayCard { content }
.frame(width: width)
@@ -0,0 +1,50 @@
import AppKit
/// An NSTextView that only sets its I-beam while it is the view under the pointer.
/// On macOS 26 SwiftTerm makes the window send every mouse move to the first responder, and NSTextView
/// sets the I-beam on each one, which fights the arrow over the other columns and a splitter's resize cursor.
class PointerBoundTextView: NSTextView {
/// Grows the view to at least the clip view's height, so the empty area below the text still takes the I-beam and clicks.
var fillsClipView = false {
didSet { fitClipView() }
}
override func mouseMoved(with event: NSEvent) {
guard isUnderPointer else { return }
super.mouseMoved(with: event)
}
override func cursorUpdate(with event: NSEvent) {
guard isUnderPointer else { return }
super.cursorUpdate(with: event)
}
override func viewDidMoveToSuperview() {
super.viewDidMoveToSuperview()
NotificationCenter.default.removeObserver(self, name: NSView.frameDidChangeNotification, object: nil)
guard let clip = superview as? NSClipView else { return }
clip.postsFrameChangedNotifications = true
NotificationCenter.default.addObserver(self, selector: #selector(clipFrameChanged), name: NSView.frameDidChangeNotification,
object: clip)
fitClipView()
}
@objc private func clipFrameChanged() {
fitClipView()
}
private func fitClipView() {
guard fillsClipView, let clip = superview as? NSClipView else { return }
minSize.height = clip.bounds.height
sizeToFit()
}
/// A splitter's hit area lies on top of the text view's edge, so the visible rect alone is not enough.
private var isUnderPointer: Bool {
guard let window, let content = window.contentView else { return false }
let location = window.mouseLocationOutsideOfEventStream
guard visibleRect.contains(convert(location, from: nil)),
let hit = content.hitTest(content.superview?.convert(location, from: nil) ?? location) else { return false }
return hit.isDescendant(of: self)
}
}
+103 -31
View File
@@ -9,7 +9,6 @@ public struct Splitter: View {
var onEnd: () -> Void
@State private var isHovered = false
@State private var isDragging = false
@State private var last: CGFloat = 0
/// `.vertical` is a column divider dragged left and right; `.horizontal` a row divider dragged up and down.
public init(_ axis: Axis = .vertical, onDrag: @escaping (Double) -> Void, onEnd: @escaping () -> Void = {}) {
@@ -23,44 +22,117 @@ public struct Splitter: View {
.fill(isHovered || isDragging ? Palette.amber : Palette.raised)
.frame(width: axis == .vertical ? Metrics.hairline : nil, height: axis == .horizontal ? Metrics.hairline : nil)
.overlay {
Color.clear
SplitterHandle(axis: axis, onHover: { isHovered = $0 }, onDragging: { isDragging = $0 }, onDrag: onDrag, onEnd: onEnd)
.frame(width: axis == .vertical ? Metrics.splitterHitArea : nil,
height: axis == .horizontal ? Metrics.splitterHitArea : nil)
.contentShape(Rectangle())
.onHover(perform: hover)
.gesture(drag)
}
.zIndex(5)
.animation(Metrics.smallControlTransition, value: isHovered || isDragging)
}
}
private var drag: some Gesture {
DragGesture(minimumDistance: 0, coordinateSpace: .global)
.onChanged { value in
let position = axis == .vertical ? value.translation.width : value.translation.height
if !isDragging {
isDragging = true
last = 0
}
onDrag(Double(position - last))
last = position
}
.onEnded { _ in
isDragging = false
last = 0
if !isHovered { NSCursor.pop() }
onEnd()
}
/// The splitter's hit area as an AppKit view, so it owns its resize cursor instead of sharing a cursor stack.
private struct SplitterHandle: NSViewRepresentable {
var axis: Axis
var onHover: (Bool) -> Void
var onDragging: (Bool) -> Void
var onDrag: (Double) -> Void
var onEnd: () -> Void
func makeNSView(context: Context) -> SplitterHandleView {
let view = SplitterHandleView()
updateNSView(view, context: context)
return view
}
private func hover(_ inside: Bool) {
guard inside != isHovered else { return }
isHovered = inside
if isDragging { return }
if inside {
(axis == .vertical ? NSCursor.resizeLeftRight : NSCursor.resizeUpDown).push()
} else {
NSCursor.pop()
}
func updateNSView(_ view: SplitterHandleView, context: Context) {
view.axis = axis
view.onHover = onHover
view.onDragging = onDragging
view.onDrag = onDrag
view.onEnd = onEnd
}
}
final class SplitterHandleView: NSView {
var axis: Axis = .vertical {
didSet { if axis != oldValue { window?.invalidateCursorRects(for: self) } }
}
var onHover: (Bool) -> Void = { _ in }
var onDragging: (Bool) -> Void = { _ in }
var onDrag: (Double) -> Void = { _ in }
var onEnd: () -> Void = {}
private var dragStart: NSPoint?
private var last: CGFloat = 0
private var cursor: NSCursor {
axis == .vertical ? .resizeLeftRight : .resizeUpDown
}
override func acceptsFirstMouse(for event: NSEvent?) -> Bool { true }
override func resetCursorRects() {
addCursorRect(bounds, cursor: cursor)
}
override func updateTrackingAreas() {
super.updateTrackingAreas()
trackingAreas.forEach(removeTrackingArea)
addTrackingArea(NSTrackingArea(rect: .zero, options: [.mouseEnteredAndExited, .cursorUpdate, .activeInActiveApp, .inVisibleRect],
owner: self))
}
override func cursorUpdate(with event: NSEvent) {
cursor.set()
}
override func mouseEntered(with event: NSEvent) {
onHover(true)
cursor.set()
}
override func mouseExited(with event: NSEvent) {
guard dragStart == nil else { return }
onHover(false)
}
/// Cursor rects stay off for the whole drag: the columns resize under the pointer and would rebuild their I-beam.
override func mouseDown(with event: NSEvent) {
dragStart = event.locationInWindow
last = 0
window?.disableCursorRects()
cursor.set()
onDragging(true)
}
override func mouseDragged(with event: NSEvent) {
guard let dragStart else { return }
cursor.set()
let point = event.locationInWindow
let position = axis == .vertical ? point.x - dragStart.x : dragStart.y - point.y
onDrag(Double(position - last))
last = position
}
override func mouseUp(with event: NSEvent) {
guard dragStart != nil else { return }
let inside = bounds.contains(convert(event.locationInWindow, from: nil))
(inside ? cursor : NSCursor.arrow).set()
endDrag()
onHover(inside)
onEnd()
}
override func viewWillMove(toWindow newWindow: NSWindow?) {
if dragStart != nil { endDrag() }
super.viewWillMove(toWindow: newWindow)
}
private func endDrag() {
dragStart = nil
last = 0
onDragging(false)
window?.enableCursorRects()
window?.resetCursorRects()
}
}
@@ -1,75 +0,0 @@
import SwiftUI
/// A title-bar toggle: Sans 12 label plus keycap. Off has no fill; on gets the amber tint and an amber keycap border;
/// `muted` is for a toggle that is off by meaning (hidden files), where label and keycap step back to text-4.
public struct ToolbarToggle: View {
var label: String
var keys: String
var isOn: Bool
var isMuted: Bool
var action: () -> Void
@State private var isHovered = false
public init(_ label: String, keys: String, isOn: Bool, muted: Bool = false, action: @escaping () -> Void) {
self.label = label
self.keys = keys
self.isOn = isOn
isMuted = muted
self.action = action
}
public var body: some View {
Button(action: action) {
HStack(spacing: 8) {
Text(label).typeRole(isOn ? Typography.toolbarLabelOn : Typography.toolbarLabel)
Keycap(keys, style: isOn ? .active : isMuted ? .muted : .normal)
}
.foregroundStyle(labelColor)
.padding(Metrics.toolbarPadding)
.background(fill, in: RoundedRectangle(cornerRadius: Metrics.radiusSmall))
.contentShape(Rectangle())
}
.buttonStyle(.plain)
.onHover { isHovered = $0 }
.animation(Metrics.smallControlTransition, value: isHovered)
.animation(Metrics.smallControlTransition, value: isOn)
}
private var labelColor: Color {
if isOn { return Palette.text1 }
if isMuted { return isHovered ? Palette.text3 : Palette.text4 }
return isHovered ? Palette.text1 : Palette.text3
}
private var fill: Color {
if isOn { return Palette.amberTint }
return isHovered && !isMuted ? Palette.hover : .clear
}
}
/// The icon-only title-bar control (the `?`): a 26pt square with a hairline border.
public struct ToolbarIconButton: View {
var glyph: String
var action: () -> Void
@State private var isHovered = false
public init(_ glyph: String, action: @escaping () -> Void) {
self.glyph = glyph
self.action = action
}
public var body: some View {
Button(action: action) {
Text(glyph)
.typeRole(Typography.keycap)
.foregroundStyle(isHovered ? Palette.text1 : Palette.text4)
.frame(width: Metrics.toolbarIconButton, height: Metrics.toolbarIconButton)
.background(isHovered ? Palette.hover : .clear, in: RoundedRectangle(cornerRadius: Metrics.radiusSmall))
.overlay(RoundedRectangle(cornerRadius: Metrics.radiusSmall).strokeBorder(Palette.raised, lineWidth: Metrics.hairline))
.contentShape(Rectangle())
}
.buttonStyle(.plain)
.onHover { isHovered = $0 }
.animation(Metrics.smallControlTransition, value: isHovered)
}
}
+33 -13
View File
@@ -19,17 +19,32 @@ public struct Tooltip: View {
}
public var body: some View {
text
.typeRole(Typography.tooltip)
.foregroundStyle(Palette.text2)
.multilineTextAlignment(.leading)
.fixedSize(horizontal: false, vertical: true)
.padding(.horizontal, 10)
.padding(.vertical, 8)
.frame(maxWidth: Metrics.tooltipMaxWidth, alignment: .leading)
.fixedSize()
.background(Palette.raised, in: RoundedRectangle(cornerRadius: Metrics.radiusSmall))
.overlay(RoundedRectangle(cornerRadius: Metrics.radiusSmall).strokeBorder(Palette.tooltipBorder, lineWidth: Metrics.hairline))
CappedWidth(maxWidth: Metrics.tooltipMaxWidth) {
text
.typeRole(Typography.tooltip)
.foregroundStyle(Palette.text2)
.multilineTextAlignment(.leading)
.padding(.horizontal, 10)
.padding(.vertical, 8)
}
.background(Palette.raised, in: RoundedRectangle(cornerRadius: Metrics.radiusSmall))
.overlay(RoundedRectangle(cornerRadius: Metrics.radiusSmall).strokeBorder(Palette.tooltipBorder, lineWidth: Metrics.hairline))
}
}
/// Sizes its content to its ideal width up to `maxWidth`, wrapping and growing taller beyond it, whatever is proposed.
/// `frame(maxWidth:)` under `fixedSize()` measures a wrapped text at its one-line height, so the text overflows the box.
private struct CappedWidth: Layout {
var maxWidth: CGFloat
func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize {
guard let content = subviews.first else { return .zero }
let ideal = content.sizeThatFits(.unspecified)
return ideal.width <= maxWidth ? ideal : content.sizeThatFits(ProposedViewSize(width: maxWidth, height: nil))
}
func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) {
subviews.first?.place(at: bounds.origin, anchor: .topLeading, proposal: ProposedViewSize(bounds.size))
}
}
@@ -54,18 +69,23 @@ struct TooltipModifier: ViewModifier {
}
.simultaneousGesture(TapGesture().onEnded { pending?.cancel(); isShown = false })
.overlay(alignment: Alignment(horizontal: edge, vertical: .bottom)) {
// A zero-height frame hangs the tip from the host's bottom edge; an explicit `.bottom`
// alignment guide is ignored here and left the tip covering the host.
if isShown {
Tooltip(text)
.alignmentGuide(.bottom) { $0[.top] - 8 }
.frame(height: 0, alignment: .top)
.offset(y: 8)
.allowsHitTesting(false)
}
}
.zIndex(isShown ? 1 : 0)
}
}
extension View {
/// Shows a design tooltip 350ms after the pointer rests on the view, 8pt below it.
/// The host must sit above its neighbours (`zIndex`) so the tip is not drawn under them.
/// The host lifts itself above its siblings while the tip shows; its container must still sit above
/// the views below it (`zIndex`), as the title bar does over the columns.
public func tip(_ text: Text, edge: HorizontalAlignment = .leading) -> some View {
modifier(TooltipModifier(text: text, edge: edge))
}
@@ -284,7 +284,7 @@ final class CodeEditorController: NSObject, NSTextViewDelegate, NSLayoutManagerD
private func applyWrap(_ on: Bool) {
guard wrap != on else { return }
wrap = on
scrollView.hasHorizontalScroller = !on
scrollView.hasHorizontalScroller = false
textView.isHorizontallyResizable = !on
container.widthTracksTextView = on
textView.autoresizingMask = on ? [.width] : []
+1 -1
View File
@@ -1,7 +1,7 @@
import AppKit
/// The NSTextView that holds the code. It only forwards gestures; `CodeEditorController` decides.
final class CodeTextView: NSTextView {
final class CodeTextView: PointerBoundTextView {
weak var controller: CodeEditorController?
/// Pointer travel that still counts as a click and not as a text selection.
+2 -1
View File
@@ -33,7 +33,8 @@ private struct EditorWorkspace: View {
if let path = editor.activePath {
let presentation = editor.presentation(for: path)
EditorBar(editor: editor, presentation: presentation)
EditorPane(editor: editor, presentation: presentation, fontScale: model.layout.textScale)
EditorPane(editor: editor, presentation: presentation, fontScale: model.layout.textScale,
isColumnShown: model.layout.isVisible(.editor))
} else {
EditorBar()
EditorEmptyState()
+3 -1
View File
@@ -8,6 +8,8 @@ struct EditorPane: View {
let presentation: EditorPresentation
/// View → Zoom.
var fontScale: CGFloat = 1
/// False while the File pane toggle hides the column: the code view then takes no focus or select-all.
var isColumnShown = true
var body: some View {
let path = presentation.path
@@ -15,7 +17,7 @@ struct EditorPane: View {
ZStack {
// Kept alive while hidden, so a trip to Preview keeps each file's undo history and colours.
if presentation.kind == .text {
CodeEditorView(configuration: configuration(path, isShown: showsCode), actions: actions)
CodeEditorView(configuration: configuration(path, isShown: showsCode && isColumnShown), actions: actions)
.opacity(showsCode ? 1 : 0)
.allowsHitTesting(showsCode)
}
+11 -10
View File
@@ -7,7 +7,6 @@ public struct PassOnPanel: View {
let insert: (String) -> Void
let cancel: () -> Void
@State private var note = ""
@FocusState private var focused: Bool
public init(request: PassOnRequest, insert: @escaping (String) -> Void, cancel: @escaping () -> Void) {
self.request = request
@@ -42,14 +41,8 @@ public struct PassOnPanel: View {
Spacer()
EscChip()
}
TextField("", text: $note, prompt: Text("Add a note (optional)…").foregroundStyle(Palette.text4))
.textFieldStyle(.plain)
.typeRole(TypeRole(.monoRegular, 13))
.foregroundStyle(Palette.text1)
.focused($focused)
.onSubmit { insert(composed) }
.onExitCommand(perform: cancel)
.padding(.horizontal, 10)
OverlayCommandField(text: $note, placeholder: "Add a note (optional)…", font: TypeRole(.monoRegular, 13).nsFont,
initialSelection: nil, horizontalInset: 10, onKey: handle)
.frame(height: 38)
.background(Palette.editor, in: RoundedRectangle(cornerRadius: Metrics.radiusSmall))
.overlay(RoundedRectangle(cornerRadius: Metrics.radiusSmall).stroke(Palette.amber, lineWidth: Metrics.accentRule))
@@ -68,7 +61,15 @@ public struct PassOnPanel: View {
.background(Palette.panel, in: RoundedRectangle(cornerRadius: Metrics.radiusMedium))
.overlay(RoundedRectangle(cornerRadius: Metrics.radiusMedium).stroke(Palette.raised, lineWidth: Metrics.hairline))
.shadow(color: Palette.menuShadow, radius: Metrics.menuShadowRadius, y: Metrics.menuShadowY)
.onAppear { focused = true }
}
private func handle(_ key: OverlayKey) -> Bool {
switch key {
case .enter: insert(composed)
case .escape: cancel()
default: return false
}
return true
}
@ViewBuilder
@@ -84,8 +84,7 @@ struct NamePromptOverlay: View {
EscChip()
}
OverlayCommandField(text: $name, placeholder: text.placeholder, font: TypeRole(.monoRegular, 13).nsFont,
initialSelection: text.initialSelection, onKey: handle)
.padding(.horizontal, 10)
initialSelection: text.initialSelection, horizontalInset: 10, onKey: handle)
.frame(height: 38)
.background(Palette.editor, in: RoundedRectangle(cornerRadius: Metrics.radiusSmall))
.focusRing(true)
+2 -1
View File
@@ -62,6 +62,7 @@ private struct NoteEditor: NSViewRepresentable {
textView.autoresizingMask = [.width]
textView.textContainer?.widthTracksTextView = true
textView.maxSize = NSSize(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude)
textView.fillsClipView = true
scroll.documentView = textView
let role = Typography.note
let paragraph = NSMutableParagraphStyle()
@@ -119,7 +120,7 @@ private struct NoteEditor: NSViewRepresentable {
}
/// Catches ⌘P before the menu bar's ⌘P (push) and draws the placeholder.
private final class NoteTextView: NSTextView {
private final class NoteTextView: PointerBoundTextView {
var onKey: (OverlayKey) -> Bool = { _ in false }
var placeholder = ""
+64 -4
View File
@@ -39,17 +39,20 @@ enum OverlayKey: Equatable {
}
/// A borderless single-line field that hands navigation keys to the overlay before the text system sees them.
/// It fills the frame it is given and centres the text in it, so the whole box takes the I-beam and the click.
struct OverlayCommandField: NSViewRepresentable {
@Binding var text: String
var placeholder: String
var font: NSFont
/// nil selects the whole text on focus, so typing replaces a seeded query.
var initialSelection: NSRange?
/// Space between the box's edges and the text.
var horizontalInset: CGFloat = 0
var onKey: (OverlayKey) -> Bool
func makeCoordinator() -> Coordinator { Coordinator(self) }
func makeNSView(context: Context) -> NSTextField {
func makeNSView(context: Context) -> CommandFieldBox {
let field = FocusingTextField()
field.isBordered = false
field.drawsBackground = false
@@ -65,12 +68,19 @@ struct OverlayCommandField: NSViewRepresentable {
field.cell?.isScrollable = true
field.cell?.wraps = false
field.initialSelection = initialSelection
return field
return CommandFieldBox(field: field, inset: horizontalInset)
}
func updateNSView(_ field: NSTextField, context: Context) {
func updateNSView(_ box: CommandFieldBox, context: Context) {
context.coordinator.parent = self
if field.stringValue != text { field.stringValue = text }
if box.field.stringValue != text { box.field.stringValue = text }
}
func sizeThatFits(_ proposal: ProposedViewSize, nsView box: CommandFieldBox, context: Context) -> CGSize? {
let fieldHeight = box.field.intrinsicContentSize.height
let width = proposal.width.flatMap { $0.isFinite ? $0 : nil } ?? max(box.field.intrinsicContentSize.width, 0) + 2 * box.inset
let height = proposal.height.flatMap { $0.isFinite ? max($0, fieldHeight) : nil } ?? fieldHeight
return CGSize(width: width, height: height)
}
final class Coordinator: NSObject, NSTextFieldDelegate {
@@ -92,6 +102,38 @@ struct OverlayCommandField: NSViewRepresentable {
}
}
/// The box around an `OverlayCommandField`: an I-beam over all of it, and a click anywhere focuses the field.
final class CommandFieldBox: NSView {
let field: NSTextField
let inset: CGFloat
init(field: NSTextField, inset: CGFloat) {
self.field = field
self.inset = inset
super.init(frame: .zero)
addSubview(field)
}
required init?(coder: NSCoder) {
fatalError("CommandFieldBox is built in code")
}
override func layout() {
super.layout()
let height = min(field.intrinsicContentSize.height, bounds.height)
field.frame = NSRect(x: inset, y: ((bounds.height - height) / 2).rounded(), width: max(0, bounds.width - 2 * inset), height: height)
}
override func resetCursorRects() {
addCursorRect(bounds, cursor: .iBeam)
}
override func mouseDown(with event: NSEvent) {
guard field.currentEditor() == nil else { return }
window?.makeFirstResponder(field)
}
}
/// An invisible first responder that forwards the overlay keys and swallows the ones it handles.
struct OverlayKeyCatcher: NSViewRepresentable {
var onKey: (OverlayKey) -> Bool
@@ -138,6 +180,11 @@ private final class FocusingTextField: NSTextField {
var initialSelection: NSRange?
private var focused = false
override class var cellClass: AnyClass? {
get { PointerBoundFieldCell.self }
set {}
}
override func viewDidMoveToWindow() {
super.viewDidMoveToWindow()
guard !focused, window != nil else { return }
@@ -152,3 +199,16 @@ private final class FocusingTextField: NSTextField {
}
}
}
/// Edits through a PointerBoundTextView instead of the window's shared field editor, which sets the I-beam on every mouse move.
private final class PointerBoundFieldCell: NSTextFieldCell {
private lazy var editor: PointerBoundTextView = {
let editor = PointerBoundTextView()
editor.isFieldEditor = true
return editor
}()
override func fieldEditor(for controlView: NSView) -> NSTextView? {
editor
}
}
@@ -173,7 +173,6 @@ struct SearchOverlay: View {
ForEach(group.rows) { row in
let selected = model.column == .project && model.projectSelection == row.index
hitLine(row.hit, selected: selected)
.id(row.index)
.onHover { inside in if inside { hover(.project, row: row.index) } }
.onTapGesture { open(SearchModel.Target(path: row.path, line: row.hit.line)) }
}
@@ -181,7 +180,10 @@ struct SearchOverlay: View {
}
.padding(.bottom, 12)
}
.onChange(of: model.projectSelection) { _, row in proxy.scrollTo(row) }
// Scrolls by the ForEach id: an extra `.id` on a row makes the LazyVStack keep stale rows.
.onChange(of: model.projectSelection) { _, row in
if model.hitRows.indices.contains(row) { proxy.scrollTo(model.hitRows[row].id) }
}
}
}
}
@@ -238,13 +240,14 @@ struct SearchOverlay: View {
ForEach(Array(matches.enumerated()), id: \.element.path) { index, match in
let selected = model.column == .files && model.fileSelection == index
fileRow(match, selected: selected)
.id(index)
.onHover { inside in if inside { hover(.files, row: index) } }
.onTapGesture { open(SearchModel.Target(path: match.path, line: nil)) }
}
}
}
.onChange(of: model.fileSelection) { _, row in proxy.scrollTo(row) }
.onChange(of: model.fileSelection) { _, row in
if matches.indices.contains(row) { proxy.scrollTo(matches[row].path) }
}
}
}
}
+3 -1
View File
@@ -74,8 +74,10 @@ public enum Command: Equatable, Sendable {
// MARK: Layout and focus
/// ⌘G
/// ⌘G: the Source Control pane toggle.
case toggleGit
/// A title-bar pane toggle: shows or hides one column.
case togglePane(Panel)
/// ⌘L
case toggleAutoFit
/// ⌘.
+10 -1
View File
@@ -66,10 +66,19 @@ struct HelderCommands: Commands {
.keyboardShortcut("r", modifiers: .command)
.disabled(workspace?.root == nil)
Divider()
Button(workspace?.layout.gitVisible == false ? "Show Source Control" : "Hide Source Control") {
Button(workspace?.layout.isVisible(.sourceControl) == false ? "Show Source Control" : "Hide Source Control") {
workspace?.perform(.toggleGit)
}
.keyboardShortcut("g", modifiers: .command)
Button(workspace?.layout.isVisible(.explorer) == false ? "Show Explorer" : "Hide Explorer") {
workspace?.perform(.togglePane(.explorer))
}
Button(workspace?.layout.isVisible(.editor) == false ? "Show File" : "Hide File") {
workspace?.perform(.togglePane(.editor))
}
Button(workspace?.layout.isVisible(.terminal) == false ? "Show Claude" : "Hide Claude") {
workspace?.perform(.togglePane(.terminal))
}
Button(workspace?.layout.fluid == false ? "Fluid Column Widths" : "Lock Column Widths") {
workspace?.perform(.toggleAutoFit)
}
+79 -33
View File
@@ -1,12 +1,13 @@
import HelderCore
import SwiftUI
/// 44pt bar: traffic-light inset, wordmark, project · branch, the open file's breadcrumb, and the toolbar.
/// 44pt bar: traffic-light inset, wordmark, project · branch, the open file's breadcrumb, the pane toggles
/// centred on the window, and the toolbar.
struct TitleBarView: View {
let model: WorkspaceModel
var body: some View {
HStack(spacing: Metrics.titleBarGap) {
TitleBarLayout(leading: model.layout.isFullScreen ? 14 : Metrics.trafficLightInset, trailing: 14, gap: Metrics.titleBarGap) {
HStack(alignment: .firstTextBaseline, spacing: Metrics.titleClusterGap) {
Wordmark()
ProjectName(name: model.name) { model.perform(.openFolder) }
@@ -19,16 +20,45 @@ struct TitleBarView: View {
.fixedSize()
Breadcrumb(path: model.editor?.activePath, isDirty: model.editor.map { e in e.activePath.map(e.isDirty) ?? false } ?? false)
.frame(maxWidth: .infinity, alignment: .leading)
PaneToggles(model: model)
TitleToolbar(model: model)
}
.padding(.leading, model.layout.isFullScreen ? 14 : Metrics.trafficLightInset)
.padding(.trailing, 14)
.frame(height: Metrics.titleBar)
.background(Palette.panel)
.hairline(.bottom)
}
}
/// Lays out the four title-bar parts: the pane toggles sit on the window's centre, and the breadcrumb
/// gets only the room left of them. The toggles move left only when the toolbar would run into them.
private struct TitleBarLayout: Layout {
var leading: CGFloat
var trailing: CGFloat
var gap: CGFloat
func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize {
CGSize(width: proposal.width ?? 0, height: proposal.height ?? Metrics.titleBar)
}
func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) {
guard subviews.count == 4 else { return }
let (cluster, crumb, toggles, toolbar) = (subviews[0], subviews[1], subviews[2], subviews[3])
let y = bounds.midY
let clusterSize = cluster.sizeThatFits(.unspecified)
let togglesSize = toggles.sizeThatFits(.unspecified)
let toolbarSize = toolbar.sizeThatFits(.unspecified)
let clusterX = bounds.minX + leading
let toolbarX = bounds.maxX - trailing - toolbarSize.width
let togglesX = min(bounds.midX - togglesSize.width / 2, toolbarX - gap - togglesSize.width)
let crumbX = clusterX + clusterSize.width + gap
cluster.place(at: CGPoint(x: clusterX, y: y), anchor: .leading, proposal: ProposedViewSize(clusterSize))
toggles.place(at: CGPoint(x: togglesX, y: y), anchor: .leading, proposal: ProposedViewSize(togglesSize))
toolbar.place(at: CGPoint(x: toolbarX, y: y), anchor: .leading, proposal: ProposedViewSize(toolbarSize))
crumb.place(at: CGPoint(x: crumbX, y: y), anchor: .leading,
proposal: ProposedViewSize(width: max(0, togglesX - gap - crumbX), height: bounds.height))
}
}
private struct ProjectName: View {
let name: String
let action: () -> Void
@@ -58,7 +88,7 @@ private struct Breadcrumb: View {
ForEach(Array(segments.enumerated()), id: \.offset) { index, segment in
if index > 0 { Text("›").foregroundStyle(Palette.text4) }
if index == segments.count - 1 {
Text(segment).typeRole(Typography.crumbLeaf).foregroundStyle(Palette.text1)
Text(segment).typeRole(Typography.crumbLeaf).foregroundStyle(Palette.text1).layoutPriority(1)
} else {
Text(segment).foregroundStyle(Palette.text4)
}
@@ -76,42 +106,58 @@ private struct Breadcrumb: View {
}
}
/// Search ⌘F · Fluid ⌘L · Hidden ⌘. · Note ⌘N · Git ⌘G · `?`, each with a tooltip that names its state.
/// Git · Explorer · File · Claude: one toggle per column. Hiding a column keeps everything inside it.
private struct PaneToggles: View {
let model: WorkspaceModel
var body: some View {
ButtonGroup([
toggle("Git", .sourceControl, column: "Source Control"),
toggle("Explorer", .explorer, column: "Explorer"),
toggle("File", .editor, column: "File"),
toggle("Claude", .terminal, column: "Claude"),
])
}
private func toggle(_ label: String, _ panel: Panel, column: String) -> GroupItem {
let shown = model.layout.isVisible(panel)
let tip = shown
? Tooltip.stated(column + " column: ", "shown", ". Click to hide it.")
: Tooltip.stated(column + " column: ", "hidden", ". Click to show it.")
return GroupItem(label, kind: .toggle(isOn: shown), tip: tip) {
model.perform(.togglePane(panel))
}
}
}
/// Search ⌘F · Fluid ⌘L · Hidden ⌘. · Note ⌘N, then `?`. Search and Note are actions; Fluid and Hidden toggle.
private struct TitleToolbar: View {
let model: WorkspaceModel
var body: some View {
let layout = model.layout
let overlay = model.overlay.current
HStack(spacing: Metrics.toolbarGap) {
ToolbarToggle("Search", keys: "⌘F", isOn: isSearch(overlay)) { model.perform(.showSearch(seed: "")) }
.tip("Search the open file, the project and the file names.", edge: .trailing)
ToolbarToggle("Fluid", keys: "⌘L", isOn: layout.fluid) { model.perform(.toggleAutoFit) }
.tip(layout.fluid
? Tooltip.stated("Column widths: ", "fluid", " — the columns re-fit on resize and focus. Click to lock them.")
: Tooltip.stated("Column widths: ", "locked", " — the columns keep their size. Click to make them fluid."),
edge: .trailing)
ToolbarToggle("Hidden", keys: "⌘.", isOn: layout.showHidden, muted: !layout.showHidden) { model.perform(.toggleHidden) }
.tip(layout.showHidden
? Tooltip.stated("Hidden files: ", "shown", " — dotfiles appear in the tree and the search. Click to hide them.")
: Tooltip.stated("Hidden files: ", "hidden", " — dotfiles are excluded from the tree and the search. Click to show them."),
edge: .trailing)
ToolbarToggle("Note", keys: "⌘N", isOn: overlay == .note) { model.perform(.showNote) }
.tip("Project note (.notes.txt) — kept next to this project.", edge: .trailing)
ToolbarToggle("Git", keys: "⌘G", isOn: layout.gitVisible) { model.perform(.toggleGit) }
.tip(layout.gitVisible
? Tooltip.stated("Source Control column: ", "shown", ". Click to hide it.")
: Tooltip.stated("Source Control column: ", "hidden", ". Click to show it."),
edge: .trailing)
HStack(spacing: Metrics.toolbarIconGap) {
ButtonGroup([
GroupItem("Search", keys: "⌘F", kind: .action,
tip: Text("Search the open file, the project and the file names.")) { model.perform(.showSearch(seed: "")) },
GroupItem("Fluid", keys: "⌘L", kind: .toggle(isOn: layout.fluid),
tip: layout.fluid
? Tooltip.stated("Column widths: ", "fluid", " — the columns re-fit on resize and focus. Click to lock them.")
: Tooltip.stated("Column widths: ", "locked", " — the columns keep their size. Click to make them fluid.")) {
model.perform(.toggleAutoFit)
},
GroupItem("Hidden", keys: "⌘.", kind: .toggle(isOn: layout.showHidden),
tip: layout.showHidden
? Tooltip.stated("Hidden files: ", "shown", " — dotfiles appear in the tree and the search. Click to hide them.")
: Tooltip.stated("Hidden files: ", "hidden", " — dotfiles are excluded from the tree and the search. Click to show them.")) {
model.perform(.toggleHidden)
},
GroupItem("Note", keys: "⌘N", kind: .action,
tip: Text("Project note (.notes.txt) — kept next to this project.")) { model.perform(.showNote) },
], tipEdge: .trailing)
ToolbarIconButton("?") { model.perform(.showShortcuts) }
.padding(.leading, 6)
.tip("Keyboard shortcuts.", edge: .trailing)
}
.fixedSize()
}
private func isSearch(_ overlay: Overlay) -> Bool {
if case .search = overlay { return true }
return false
}
}
+85 -9
View File
@@ -1,3 +1,5 @@
import AppKit
import HelderCore
import SwiftUI
/// The launcher without a project; with one, the title bar, four columns and status bar, overlays above.
@@ -37,35 +39,109 @@ struct WorkspaceView: View {
}
}
/// The four columns and their splitters. The agent column is keyed by the project so its terminals respawn on a switch.
/// The four columns and their splitters. Every column stays mounted: a pane toggle only hides it, so the
/// terminals, the editor buffer and the tree keep their state. The editor is the flex column; with the editor
/// hidden the agent column fills. The agent column is keyed by the project so its terminals respawn on a switch.
private struct Columns: View {
let model: WorkspaceModel
/// The editor's last shown width, kept while it is hidden so its text does not re-wrap.
@State private var editorWidth = Metrics.minEditorWidth
var body: some View {
let layout = model.layout
let v = layout.visibility
let agentFills = v.agent && !v.editor
let hiddenEditorWidth = max(editorWidth, Metrics.minEditorWidth)
HStack(spacing: 0) {
if layout.gitVisible {
SourceControlColumn(model: model)
.frame(width: layout.widths.sourceControl)
.refreshFlash(model.refreshTick)
Splitter(onDrag: { layout.dragSourceControl(by: $0) }, onEnd: layout.endDrag)
}
SourceControlColumn(model: model)
.frame(width: layout.widths.sourceControl)
.refreshFlash(model.refreshTick)
.pane(shown: v.sourceControl)
Splitter(onDrag: { layout.dragSourceControl(by: $0) }, onEnd: layout.endDrag)
.pane(shown: v.sourceControl && (v.explorer || v.editor || v.agent))
ExplorerColumn(model: model)
.frame(width: layout.widths.explorer)
.refreshFlash(model.refreshTick)
.pane(shown: v.explorer)
Splitter(onDrag: { layout.dragExplorer(by: $0) }, onEnd: layout.endDrag)
.pane(shown: v.explorer && (v.editor || v.agent))
EditorColumn(model: model)
.frame(minWidth: Metrics.minEditorWidth, maxWidth: .infinity)
.frame(minWidth: v.editor ? Metrics.minEditorWidth : hiddenEditorWidth, maxWidth: v.editor ? .infinity : hiddenEditorWidth)
.onGeometryChange(for: CGFloat.self) { $0.size.width } action: { width in
if v.editor { editorWidth = width }
}
.refreshFlash(model.refreshTick)
.pane(shown: v.editor)
Splitter(onDrag: { layout.dragAgent(by: $0) }, onEnd: layout.endDrag)
.pane(shown: v.editor && v.agent)
AgentColumn(model: model)
.frame(width: layout.widths.agent)
.frame(minWidth: agentFills ? Metrics.minEditorWidth : layout.widths.agent,
maxWidth: agentFills ? .infinity : layout.widths.agent)
.id(model.root)
.pane(shown: v.agent)
if !v.editor && !v.agent {
Spacer(minLength: 0)
}
}
.background(Palette.editor)
.background(HiddenPaneFocusGuard(visibility: v))
.clipped()
}
}
/// Hides a column without unmounting it. The hidden column keeps its own width, so a terminal never
/// resizes to nothing, and is parked outside the window, so its AppKit views own no pixels, clicks or cursor.
private struct PaneVisibility: ViewModifier {
static let parkedOffset: CGFloat = 100_000
let shown: Bool
func body(content: Content) -> some View {
content
.frame(width: shown ? nil : 0, alignment: .leading)
.opacity(shown ? 1 : 0)
.allowsHitTesting(shown)
.accessibilityHidden(!shown)
.offset(x: shown ? 0 : Self.parkedOffset)
}
}
extension View {
fileprivate func pane(shown: Bool) -> some View {
modifier(PaneVisibility(shown: shown))
}
}
/// When a column is hidden while it holds the keyboard (a terminal, the code, the commit box), the window
/// takes the keyboard back, so typing never lands in a pane nobody can see.
private struct HiddenPaneFocusGuard: NSViewRepresentable {
let visibility: ColumnVisibility
func makeNSView(context: Context) -> GuardView {
GuardView()
}
func updateNSView(_ view: GuardView, context: Context) {
view.visibility = visibility
}
final class GuardView: NSView {
var visibility: ColumnVisibility? {
didSet {
guard let oldValue, oldValue != visibility else { return }
DispatchQueue.main.async { [weak self] in self?.releaseParkedResponder() }
}
}
override func hitTest(_ point: NSPoint) -> NSView? { nil }
private func releaseParkedResponder() {
guard let window, let responder = window.firstResponder as? NSView, let content = window.contentView else { return }
let view = responder.enclosingScrollView ?? responder
if view.convert(view.bounds, to: nil).minX >= content.bounds.maxX { window.makeFirstResponder(nil) }
}
}
}
/// ⌘R lightens a column for a moment and lets it settle back; each new tick replays it.
private struct RefreshFlash: ViewModifier {
let tick: Int
@@ -167,6 +167,7 @@ struct CommitTextView: NSViewRepresentable {
textView.isHorizontallyResizable = false
textView.autoresizingMask = [.width]
textView.textContainer?.widthTracksTextView = true
textView.fillsClipView = true
let paragraph = NSMutableParagraphStyle()
paragraph.minimumLineHeight = 18
paragraph.maximumLineHeight = 18
@@ -210,7 +211,7 @@ struct CommitTextView: NSViewRepresentable {
}
}
final class CommitNSTextView: NSTextView {
final class CommitNSTextView: PointerBoundTextView {
var onCommit: (() -> Void)?
var onFocusChange: ((Bool) -> Void)?
+67 -19
View File
@@ -18,13 +18,37 @@ public struct ColumnLayoutSnapshot: Codable, Sendable, Equatable {
public var agentWidth: Double
public var fluid: Bool
public var gitVisible: Bool
public var explorerVisible: Bool
public var fileVisible: Bool
public var claudeVisible: Bool
public init(sourceControlWidth: Double, explorerWidth: Double, agentWidth: Double, fluid: Bool, gitVisible: Bool) {
public init(sourceControlWidth: Double, explorerWidth: Double, agentWidth: Double, fluid: Bool,
visibility: ColumnVisibility = .all) {
self.sourceControlWidth = sourceControlWidth
self.explorerWidth = explorerWidth
self.agentWidth = agentWidth
self.fluid = fluid
self.gitVisible = gitVisible
gitVisible = visibility.sourceControl
explorerVisible = visibility.explorer
fileVisible = visibility.editor
claudeVisible = visibility.agent
}
/// Older snapshots only know `gitVisible`; a missing flag means shown.
public init(from decoder: Decoder) throws {
let c = try decoder.container(keyedBy: CodingKeys.self)
sourceControlWidth = try c.decode(Double.self, forKey: .sourceControlWidth)
explorerWidth = try c.decode(Double.self, forKey: .explorerWidth)
agentWidth = try c.decode(Double.self, forKey: .agentWidth)
fluid = try c.decode(Bool.self, forKey: .fluid)
gitVisible = try c.decodeIfPresent(Bool.self, forKey: .gitVisible) ?? true
explorerVisible = try c.decodeIfPresent(Bool.self, forKey: .explorerVisible) ?? true
fileVisible = try c.decodeIfPresent(Bool.self, forKey: .fileVisible) ?? true
claudeVisible = try c.decodeIfPresent(Bool.self, forKey: .claudeVisible) ?? true
}
public var visibility: ColumnVisibility {
ColumnVisibility(sourceControl: gitVisible, explorer: explorerVisible, editor: fileVisible, agent: claudeVisible)
}
public static func key(root: String) -> String { "helder.layout:" + root }
@@ -71,8 +95,8 @@ public final class LayoutStore {
/// The agent pane's share of the right column; persisted across launches.
public private(set) var agentFraction: Double
public private(set) var windowWidth: Double = 1680
/// ⌘G: the Source Control column is shown.
public private(set) var gitVisible = true
/// The title bar's pane toggles; ⌘G flips Source Control.
public private(set) var visibility = ColumnVisibility.all
/// ⌘L: columns re-fit on resize and focus. A manual splitter drag turns this off.
public private(set) var fluid = true
/// ⌘.: dotfiles show in the tree and the search.
@@ -122,7 +146,7 @@ public final class LayoutStore {
activePanel = nil
focusZone = .neutral
let saved = persistence?.load(root: root)
gitVisible = saved?.gitVisible ?? true
visibility = saved?.visibility ?? .all
fluid = saved?.fluid ?? true
if let saved, !saved.fluid {
widths = ColumnWidths(sourceControl: clamp(saved.sourceControlWidth, ColumnLayout.sourceControlRange),
@@ -134,12 +158,32 @@ public final class LayoutStore {
public var snapshot: ColumnLayoutSnapshot {
ColumnLayoutSnapshot(sourceControlWidth: widths.sourceControl, explorerWidth: widths.explorer,
agentWidth: widths.agent, fluid: fluid, gitVisible: gitVisible)
agentWidth: widths.agent, fluid: fluid, visibility: visibility)
}
public func toggleGit() {
gitVisible.toggle()
if !gitVisible && activePanel == .sourceControl { activePanel = nil }
public func isVisible(_ panel: Panel) -> Bool {
switch panel {
case .sourceControl: visibility.sourceControl
case .explorer: visibility.explorer
case .editor: visibility.editor
case .terminal: visibility.agent
}
}
/// Shows or hides one column; a hidden column loses keyboard focus but keeps everything inside it.
public func togglePane(_ panel: Panel) {
setVisible(panel, !isVisible(panel))
}
public func setVisible(_ panel: Panel, _ visible: Bool) {
guard isVisible(panel) != visible else { return }
switch panel {
case .sourceControl: visibility.sourceControl = visible
case .explorer: visibility.explorer = visible
case .editor: visibility.editor = visible
case .terminal: visibility.agent = visible
}
if !visible && activePanel == panel { activePanel = nil }
refit()
save()
}
@@ -161,7 +205,7 @@ public final class LayoutStore {
/// Focus moves the fluid widths below 1600pt: the editor or the terminals get more room.
public func focus(_ panel: Panel) {
if panel == .sourceControl && !gitVisible { return }
guard isVisible(panel) else { return }
activePanel = panel
switch panel {
case .editor: focusZone = .editor
@@ -190,7 +234,7 @@ public final class LayoutStore {
/// The agent splitter sits on the column's left edge, so dragging right shrinks it.
public func dragAgent(by delta: Double) {
fluid = false
let maxWidth = ColumnLayout.maxAgentWidth(windowWidth: windowWidth, widths: widths, sourceControlVisible: gitVisible)
let maxWidth = ColumnLayout.maxAgentWidth(windowWidth: windowWidth, widths: widths, visible: visibility)
widths.agent = clamp(widths.agent - delta, ColumnLayout.minEditorWidth...maxWidth)
}
@@ -214,19 +258,22 @@ public final class LayoutStore {
/// The visible columns, left to right.
public var columns: [Panel] {
gitVisible ? Panel.allCases : [.explorer, .editor, .terminal]
Panel.allCases.filter(isVisible)
}
/// The horizontal extent of a column in window coordinates; nil for a hidden column.
/// The editor is the flex column; with the editor hidden the agent column fills the rest.
public func span(of panel: Panel) -> ClosedRange<Double>? {
guard isVisible(panel) else { return nil }
let splitter = ColumnLayout.splitterWidth
let sc = gitVisible ? widths.sourceControl + splitter : 0
let editorStart = sc + widths.explorer + splitter
let agentStart = max(editorStart, windowWidth - widths.agent)
let v = visibility
let explorerStart = v.sourceControl ? widths.sourceControl + splitter : 0
let flexStart = explorerStart + (v.explorer ? widths.explorer + splitter : 0)
let agentStart = v.editor ? max(flexStart, windowWidth - widths.agent) : flexStart
switch panel {
case .sourceControl: return gitVisible ? 0...widths.sourceControl : nil
case .explorer: return sc...(sc + widths.explorer)
case .editor: return editorStart...max(editorStart, agentStart - splitter)
case .sourceControl: return 0...widths.sourceControl
case .explorer: return explorerStart...(explorerStart + widths.explorer)
case .editor: return flexStart...max(flexStart, v.agent ? agentStart - splitter : windowWidth)
case .terminal: return agentStart...max(agentStart, windowWidth)
}
}
@@ -242,13 +289,14 @@ public final class LayoutStore {
/// The column `step` places left (−1) or right (+1) of `panel`, clamped at the ends. No focus counts as the editor.
public func neighbour(of panel: Panel?, step: Int) -> Panel {
let list = columns
guard !list.isEmpty else { return panel ?? .editor }
let index = list.firstIndex(of: panel ?? .editor) ?? list.firstIndex(of: .editor) ?? 0
return list[min(max(index + step, 0), list.count - 1)]
}
private func refit() {
var next = fluid ? ColumnLayout.fluid(windowWidth: windowWidth, focus: focusZone) : widths
next = ColumnLayout.fitted(next, windowWidth: windowWidth, sourceControlVisible: gitVisible)
next = ColumnLayout.fitted(next, windowWidth: windowWidth, visible: visibility)
if next != widths { widths = next }
}
+3 -2
View File
@@ -149,7 +149,8 @@ public final class WorkspaceModel {
case let .launcherSelect(index): launcher.select(index)
case .launcherActivate: activateLauncher()
case .toggleGit: layout.toggleGit()
case .toggleGit: layout.togglePane(.sourceControl)
case let .togglePane(panel): layout.togglePane(panel)
case .toggleAutoFit: layout.toggleFluid()
case .toggleHidden: layout.toggleHidden()
case let .focus(panel): focus(panel)
@@ -180,7 +181,7 @@ public final class WorkspaceModel {
guard let sourceControl else { return }
track { _ = await sourceControl.push() }
case .focusCommitMessage:
if !layout.gitVisible { layout.toggleGit() }
layout.setVisible(.sourceControl, true)
layout.focus(.sourceControl)
focusRequest = FocusRequest(.commitMessage)
@@ -18,6 +18,7 @@ final class HelderTerminalView: LocalProcessTerminalView, TerminalSessionHandle
super.init(frame: NSRect(x: 0, y: 0, width: 480, height: 320),
font: TerminalAppearance.font(store.config.terminal),
options: TerminalAppearance.options(store.config.terminal))
Self.arrowCursorUpdate
events.owner = self
processDelegate = events
appliedSettings = store.config.terminal
@@ -58,6 +59,20 @@ final class HelderTerminalView: LocalProcessTerminalView, TerminalSessionHandle
super.send(source: source, data: data)
}
/// ⌥← and ⌥→ jump by word (ESC b / ESC f, as Terminal.app does) while Option is not the Meta key.
override func interpretKeyEvents(_ events: [NSEvent]) {
if !optionAsMetaKey, events.count == 1, let event = events.first, event.type == .keyDown,
event.modifierFlags.intersection([.shift, .control, .option, .command]) == .option,
let key = event.charactersIgnoringModifiers?.unicodeScalars.first.map({ Int($0.value) }) {
switch key {
case NSLeftArrowFunctionKey: return send(EscapeSequences.emacsBack)
case NSRightArrowFunctionKey: return send(EscapeSequences.emacsForward)
default: break
}
}
super.interpretKeyEvents(events)
}
/// Selecting text copies it, in both panes.
override func selectionChanged(source: Terminal) {
super.selectionChanged(source: source)
@@ -87,6 +102,23 @@ final class HelderTerminalView: LocalProcessTerminalView, TerminalSessionHandle
return nil
}
// MARK: Pointer
/// The terminal shows the arrow, so SwiftTerm's I-beam rect is dropped; its `resetCursorRects` is not open.
override func addCursorRect(_ rect: NSRect, cursor object: NSCursor) {
guard object != .iBeam else { return }
super.addCursorRect(rect, cursor: object)
}
/// Gives this class its own `cursorUpdate:` that sets the arrow; Swift cannot override SwiftTerm's I-beam one,
/// which runs when an update reaches the pane through a subview or a neighbour's tracking area.
private static let arrowCursorUpdate: Void = {
let block: @convention(block) (AnyObject, NSEvent) -> Void = { _, _ in NSCursor.arrow.set() }
let selector = #selector(NSResponder.cursorUpdate(with:))
let types = method_getTypeEncoding(class_getInstanceMethod(NSView.self, selector)!)
class_addMethod(HelderTerminalView.self, selector, imp_implementationWithBlock(block), types)
}()
// MARK: Lifetime
/// Closing the window kills the child; moving the view between containers does not.
+8 -2
View File
@@ -62,8 +62,12 @@ public enum Metrics {
public static let titleBarGap: CGFloat = 18
public static let titleClusterGap: CGFloat = 10
public static let crumbGap: CGFloat = 7
public static let toolbarGap: CGFloat = 4
public static let toolbarPadding = EdgeInsets(top: 6, leading: 9, bottom: 6, trailing: 9)
/// A button inside a `ButtonGroup`: the pane toggles and the toolbar.
public static let groupButtonPadding = EdgeInsets(top: 6, leading: 10, bottom: 6, trailing: 10)
public static let groupButtonGap: CGFloat = 7
public static let groupButtonDot: CGFloat = 6
/// Between the toolbar group and the `?`.
public static let toolbarIconGap: CGFloat = 8
/// The `?` button: a square with a hairline border.
public static let toolbarIconButton: CGFloat = 26
public static let statusBarGap: CGFloat = 16
@@ -76,6 +80,8 @@ public enum Metrics {
// MARK: Overlays
public static let overlayInset: CGFloat = 34
/// The widest an `.inset` overlay grows; past it the card stays centred.
public static let insetOverlayMaxWidth: CGFloat = 1200
public static let contextMenuWidth: CGFloat = 320
public static let passOnWidth: CGFloat = 460
public static let launcherWidth: CGFloat = 520
+1 -1
View File
@@ -45,7 +45,7 @@ public enum Palette {
public static let amberSoft = Color(hex: 0xF0B476)
public static let amberTint = Color(hex: 0xE8913A, alpha: 0.10)
public static let focusRing = Color(hex: 0xE8913A, alpha: 0.22)
/// Border of an active toolbar toggle's keycap.
/// Border of a lit key in the symbol popup.
public static let amberKeycapBorder = Color(hex: 0xE8913A, alpha: 0.35)
/// Text on an amber fill: always ink, never white.
public static let ink = Color(hex: 0x171C22)
-1
View File
@@ -86,7 +86,6 @@ public enum Typography {
public static let segment = TypeRole(.sansRegular, 11)
public static let segmentOn = TypeRole(.sansMedium, 11)
public static let toolbarLabel = TypeRole(.sansRegular, 12)
public static let toolbarLabelOn = TypeRole(.sansMedium, 12)
public static let menuItem = TypeRole(.sansRegular, 13)
public static let menuItemHighlighted = TypeRole(.sansMedium, 13)
public static let note = TypeRole(.monoRegular, 14, lineHeight: 23.8)
@@ -13,7 +13,52 @@ import Testing
}
@Test func fittingKeepsTheEditorMinimum() {
let fitted = ColumnLayout.fitted(ColumnWidths(sourceControl: 400, explorer: 400, agent: 400), windowWidth: 1000, sourceControlVisible: true)
let fitted = ColumnLayout.fitted(ColumnWidths(sourceControl: 400, explorer: 400, agent: 400), windowWidth: 1000, visible: .all)
#expect(fitted.sourceControl + fitted.explorer + fitted.agent <= 1000 - 3 - ColumnLayout.minEditorWidth)
}
@Test func aHiddenColumnIsNeitherCountedNorScaled() {
let widths = ColumnWidths(sourceControl: 400, explorer: 400, agent: 400)
let visible = ColumnVisibility(sourceControl: false)
let fitted = ColumnLayout.fitted(widths, windowWidth: 1000, visible: visible)
#expect(fitted.sourceControl == 400)
#expect(fitted.explorer + fitted.agent <= 1000 - 2 - ColumnLayout.minEditorWidth)
}
@Test func withTheEditorHiddenTheAgentIsTheFlexColumn() {
let widths = ColumnWidths(sourceControl: 400, explorer: 400, agent: 900)
let fitted = ColumnLayout.fitted(widths, windowWidth: 1000, visible: ColumnVisibility(editor: false))
#expect(fitted.agent == 900)
#expect(fitted.sourceControl + fitted.explorer <= 1000 - 2 - ColumnLayout.minEditorWidth)
}
@Test func withoutAFlexColumnTheFixedOnesOnlyHaveToFitTheWindow() {
let widths = ColumnWidths(sourceControl: 300, explorer: 300, agent: 480)
let visible = ColumnVisibility(editor: false, agent: false)
#expect(ColumnLayout.fitted(widths, windowWidth: 1000, visible: visible) == widths)
let narrow = ColumnLayout.fitted(widths, windowWidth: 501, visible: visible)
#expect(narrow.sourceControl + narrow.explorer <= 500)
#expect(narrow.agent == 480)
}
@Test func fittingWithOnlyTheAgentBesideTheEditor() {
let widths = ColumnWidths(sourceControl: 300, explorer: 300, agent: 900)
let fitted = ColumnLayout.fitted(widths, windowWidth: 1000, visible: ColumnVisibility(sourceControl: false, explorer: false))
#expect(fitted.sourceControl == 300)
#expect(fitted.agent <= 1000 - 1 - ColumnLayout.minEditorWidth)
#expect(fitted.agent >= 1000 - 2 - ColumnLayout.minEditorWidth)
}
@Test func splittersSitOnlyBetweenVisibleColumns() {
#expect(ColumnVisibility.all.splitterCount == 3)
#expect(ColumnVisibility(sourceControl: false, editor: false).splitterCount == 1)
#expect(ColumnVisibility(sourceControl: false, explorer: false, editor: false, agent: false).splitterCount == 0)
}
@Test func theAgentLimitCountsOnlyVisibleColumns() {
let widths = ColumnWidths(sourceControl: 300, explorer: 300, agent: 480)
#expect(ColumnLayout.maxAgentWidth(windowWidth: 1600, widths: widths, visible: .all) == 1600 - 3 - 600 - ColumnLayout.minEditorWidth)
#expect(ColumnLayout.maxAgentWidth(windowWidth: 1600, widths: widths, visible: ColumnVisibility(explorer: false))
== 1600 - 2 - 300 - ColumnLayout.minEditorWidth)
}
}
@@ -1,6 +1,7 @@
import HelderCore
import HelderServices
@testable import HelderUI
import Foundation
import Testing
private struct MemorySession: SessionStoring {
@@ -81,7 +82,7 @@ private struct MemorySession: SessionStoring {
@Test func hidingGitDropsItsFocus() {
let layout = LayoutStore(session: MemorySession())
layout.focus(.sourceControl)
layout.toggleGit()
layout.togglePane(.sourceControl)
#expect(layout.activePanel == nil)
layout.focus(.sourceControl)
#expect(layout.activePanel == nil)
@@ -94,13 +95,13 @@ private struct MemorySession: SessionStoring {
first.windowResized(width: 1760)
first.dragExplorer(by: 40)
first.endDrag()
first.toggleGit()
first.togglePane(.sourceControl)
let second = LayoutStore(session: MemorySession(), persistence: store)
second.windowResized(width: 1760)
second.restore(root: "/p")
#expect(!second.fluid)
#expect(!second.gitVisible)
#expect(!second.isVisible(.sourceControl))
#expect(second.widths.explorer == first.widths.explorer)
#expect(second.widths.agent == first.widths.agent)
}
@@ -109,11 +110,11 @@ private struct MemorySession: SessionStoring {
let store = FakeLayouts()
let layout = LayoutStore(session: MemorySession(), persistence: store)
layout.restore(root: "/a")
layout.toggleGit()
layout.togglePane(.sourceControl)
layout.restore(root: "/b")
#expect(layout.gitVisible)
#expect(layout.isVisible(.sourceControl))
layout.restore(root: "/a")
#expect(!layout.gitVisible)
#expect(!layout.isVisible(.sourceControl))
}
@Test func dragsSaveOnlyWhenTheyEnd() {
@@ -144,7 +145,7 @@ private struct MemorySession: SessionStoring {
#expect(layout.panel(atX: 900) == .editor)
#expect(layout.panel(atX: 1700) == .terminal)
#expect(layout.panel(atX: 236, splitterMargin: 4) == nil)
layout.toggleGit()
layout.togglePane(.sourceControl)
#expect(layout.panel(atX: 10) == .explorer)
}
@@ -153,7 +154,106 @@ private struct MemorySession: SessionStoring {
#expect(layout.neighbour(of: nil, step: 1) == .terminal)
#expect(layout.neighbour(of: .terminal, step: 1) == .terminal)
#expect(layout.neighbour(of: .explorer, step: -1) == .sourceControl)
layout.toggleGit()
layout.togglePane(.sourceControl)
#expect(layout.neighbour(of: .explorer, step: -1) == .explorer)
}
@Test func everyPaneStartsShownAndTogglesOnItsOwn() {
let layout = LayoutStore(session: MemorySession())
#expect(layout.visibility == .all)
layout.togglePane(.explorer)
layout.togglePane(.terminal)
#expect(layout.visibility == ColumnVisibility(sourceControl: true, explorer: false, editor: true, agent: false))
#expect(layout.columns == [.sourceControl, .editor])
layout.togglePane(.terminal)
#expect(layout.isVisible(.terminal))
}
@Test func hidingAFocusedPaneDropsItsFocusAndAHiddenPaneTakesNone() {
let layout = LayoutStore(session: MemorySession())
layout.focus(.terminal)
layout.togglePane(.terminal)
#expect(layout.activePanel == nil)
layout.focus(.terminal)
#expect(layout.activePanel == nil)
layout.focus(.editor)
layout.togglePane(.explorer)
#expect(layout.activePanel == .editor)
}
@Test func allFourPaneFlagsSurviveARestart() {
let store = FakeLayouts()
let first = LayoutStore(session: MemorySession(), persistence: store)
first.restore(root: "/p")
first.togglePane(.explorer)
first.togglePane(.editor)
first.togglePane(.terminal)
let second = LayoutStore(session: MemorySession(), persistence: store)
second.restore(root: "/p")
#expect(second.visibility == ColumnVisibility(sourceControl: true, explorer: false, editor: false, agent: false))
}
@Test func anOlderSnapshotWithOnlyTheGitFlagStillLoads() throws {
let json = #"{"sourceControlWidth":240,"explorerWidth":300,"agentWidth":500,"fluid":false,"gitVisible":false}"#
let snapshot = try JSONDecoder().decode(ColumnLayoutSnapshot.self, from: Data(json.utf8))
#expect(snapshot.visibility == ColumnVisibility(sourceControl: false, explorer: true, editor: true, agent: true))
#expect(snapshot.explorerWidth == 300)
#expect(!snapshot.fluid)
}
@Test func aSnapshotRoundTripsItsPaneFlags() throws {
let visibility = ColumnVisibility(sourceControl: true, explorer: false, editor: true, agent: false)
let snapshot = ColumnLayoutSnapshot(sourceControlWidth: 236, explorerWidth: 288, agentWidth: 480, fluid: true, visibility: visibility)
let decoded = try JSONDecoder().decode(ColumnLayoutSnapshot.self, from: JSONEncoder().encode(snapshot))
#expect(decoded == snapshot)
#expect(decoded.visibility == visibility)
}
@Test func withTheEditorHiddenTheAgentColumnFillsTheRest() {
let layout = LayoutStore(session: MemorySession())
layout.windowResized(width: 1760)
layout.togglePane(.editor)
#expect(layout.columns == [.sourceControl, .explorer, .terminal])
#expect(layout.span(of: .editor) == nil)
let agentStart = layout.widths.sourceControl + 1 + layout.widths.explorer + 1
#expect(layout.span(of: .terminal) == agentStart...1760)
#expect(layout.panel(atX: 1000) == .terminal)
}
@Test func withTheAgentHiddenTheEditorReachesTheWindowEdge() {
let layout = LayoutStore(session: MemorySession())
layout.windowResized(width: 1760)
layout.togglePane(.terminal)
layout.togglePane(.sourceControl)
#expect(layout.span(of: .explorer) == 0...layout.widths.explorer)
#expect(layout.span(of: .editor) == (layout.widths.explorer + 1)...1760)
#expect(layout.span(of: .terminal) == nil)
#expect(layout.panel(atX: 1700) == .editor)
}
@Test func withEveryPaneHiddenNothingIsUnderThePointer() {
let layout = LayoutStore(session: MemorySession())
layout.windowResized(width: 1760)
for panel in Panel.allCases { layout.togglePane(panel) }
#expect(layout.columns.isEmpty)
#expect(layout.panel(atX: 500) == nil)
#expect(layout.neighbour(of: .editor, step: 1) == .editor)
}
@Test func neighboursSkipEveryHiddenPane() {
let layout = LayoutStore(session: MemorySession())
layout.togglePane(.editor)
layout.togglePane(.explorer)
#expect(layout.neighbour(of: .sourceControl, step: 1) == .terminal)
#expect(layout.neighbour(of: .terminal, step: -1) == .sourceControl)
}
@Test func theAgentMayGrowIntoTheRoomAHiddenExplorerLeaves() {
let layout = LayoutStore(session: MemorySession())
layout.windowResized(width: 1760)
layout.togglePane(.explorer)
layout.dragAgent(by: -5000)
#expect(layout.widths.agent == 1760 - 2 - layout.widths.sourceControl - ColumnLayout.minEditorWidth)
}
}
@@ -476,11 +476,27 @@ import Testing
let harness = WorkspaceHarness()
await harness.start()
harness.model.perform(.toggleGit)
#expect(!harness.model.layout.isVisible(.sourceControl))
harness.model.perform(.focusCommitMessage)
#expect(harness.model.layout.gitVisible)
#expect(harness.model.layout.isVisible(.sourceControl))
#expect(harness.model.focusRequest?.target == .commitMessage)
}
@Test func aPaneToggleHidesItsColumnAndAHiddenColumnTakesNoFocus() async {
let harness = WorkspaceHarness()
await harness.start()
harness.model.perform(.focus(.terminal))
harness.model.perform(.togglePane(.terminal))
#expect(!harness.model.layout.isVisible(.terminal))
#expect(harness.model.layout.activePanel == nil)
harness.model.perform(.focus(.editor))
harness.model.perform(.focus(.terminal))
#expect(harness.model.layout.activePanel == .editor)
#expect(harness.model.focusRequest?.target == .panel(.editor))
harness.model.perform(.togglePane(.terminal))
#expect(harness.model.layout.isVisible(.terminal))
}
@Test func rowCursorKeysDriveTheFocusedList() async {
let harness = WorkspaceHarness(git: snapshot([("a.php", .modified, false), ("b.php", .added, true)]),
contents: ["a.php": "", "b.php": ""])
+1 -1
View File
@@ -58,7 +58,7 @@ Sources/HelderUI/
KeyRouter, Command, SystemActions, title bar, status bar, launcher, toasts, focus flash
Components/ OverlayShell/OverlayCard/OverlayHeader/OverlayFooter, ContextMenuPanel/Header/Row/Separator,
Keycap, EscChip, Primary/Secondary button styles, focusRing, SegmentButton, Splitter,
ToolbarToggle, Tooltip, TypeBadge, PanelLabel/PanelHeader, Hairline, selectableRow, Blink
ButtonGroup (pane toggles, toolbar), Tooltip, TypeBadge, PanelLabel/PanelHeader, Hairline, selectableRow, Blink
SourceControl/ the git column and the commit box
Explorer/ the file tree column and the row glyphs
Editor/ the bar above the code, code/markdown/image panes, Diff overlay, pass-on panel, symbol popup
+6 -1
View File
@@ -33,7 +33,8 @@ The top bar contains, left to right:
- The Helder wordmark.
- A breadcrumb showing the path to the active file, for example `console / src / Http / Controller / UserController.php`. The breadcrumb is **display only** for now. It is not clickable and does not navigate.
- On the right, two controls: **Go to File** (`Cmd+P`) and **Search** (`Cmd+F`). Both open overlays described in section 9.
- Centred on the window, the **pane toggles**: Git · Explorer · File · Claude, one per column, all on by default (see Pane toggles in section 9). The breadcrumb truncates before it reaches them.
- On the right, the toolbar: **Search** (`Cmd+F`) and **Note** (`Cmd+N`) are actions; **Fluid** (`Cmd+L`) and **Hidden** (`Cmd+.`) are toggles. Then `?` for the keyboard shortcuts.
---
@@ -215,6 +216,10 @@ Inside the overlay:
Dragging any splitter resizes the adjacent panes. Positions persist across launches.
### Pane toggles
Each title-bar toggle shows or hides its column; `Cmd+G` is the same as the Git toggle. Hiding only hides: the terminals and their processes, the editor buffer and scroll, and the Explorer's expanded folders survive any number of hide/show cycles. The editor absorbs the freed width; with the editor hidden the Agent and Terminal column fills the rest. With every column off the body shows the editor background. A hidden column cannot take focus, and hiding the focused column hands the keyboard back to the window. `Cmd+C` to the commit box shows a hidden Source Control column. The four flags are saved per project.
### Session restore
When `session.restoreOnLaunch` is on (default), reopening a project restores the previously open file, its view, and the pane and splitter layout.
File diff suppressed because it is too large Load Diff
+81 -41
View File
@@ -1,22 +1,26 @@
# Design: Helder — editor for working with Claude Code
# Handoff: Helder — editor for working with Claude Code
## Overview
Helder is a macOS code editor built around one job: work on a codebase together with
Helder is a desktop code editor built around one job: work on a codebase together with
Claude Code. It replaces a general IDE with four columns — source control, explorer,
editor, agent — plus five overlays (search, keyboard shortcuts, project note, project
launcher, expanded diff) and a set of small surfaces (context menus, a pass-on-to-agent
prompt, tooltips, a markdown preview).
This document describes one consistent visual system for all of those screens.
This handoff describes one consistent visual system for all of those screens.
## About the design files
The files in this folder are **design references written in HTML**. They show the
intended look, spacing and states. They are not production code to copy: the app
recreates these screens in SwiftUI and AppKit.
The files in this bundle are **design references written in HTML**. They show the
intended look, spacing and states. They are not production code to copy.
`design-canvas.dc.html` is a single-canvas board: every screen sits on one page, side by
The task is to **recreate these screens in the target codebase's own environment**
(Electron + React, Tauri + Svelte, SwiftUI, whatever the app already uses) with its
established patterns. If no environment exists yet, pick the framework that fits a
desktop editor and implement the design there.
`Helder IDE.dc.html` is a single-canvas board: every screen sits on one page, side by
side, at real pixel sizes. Open it in a browser to inspect any value with devtools.
## Fidelity
@@ -69,16 +73,18 @@ heading.
`#EFF0EE` page · `#E5E7E4` spec card · `#CDD1CD` hairline · `#171C22` ink ·
`#3A424C` ink muted · `#6B7480` ink dim. The application itself is dark only.
### Syntax — six colours, all muted
### Syntax — eight colours, lifted but unsaturated
| Role | Hex |
|---|---|
| plain / function name | `#E4E7E6` |
| variable / property | `#BAC0C0` |
| comment | `#6C7783` |
| keyword / operator / pseudo-class | `#C3A6CE` |
| string / value / type path | `#8FBFB4` |
| number / tag / hex literal | `#F0B476` |
| plain / punctuation | `#F1F3F2` |
| function / method name | `#A9C0E4` |
| class / type / CSS selector | `#EFBCB0` |
| variable / property | `#D4D9D8` |
| comment | `#828D9A` |
| keyword / operator / pseudo-class | `#D8BEE4` |
| string / value / type path | `#A8D6CB` |
| number / tag / hex literal | `#F8C793` |
No bold, no italic in code. Weight stays 400 so the column reads flat.
@@ -118,7 +124,7 @@ No green, no red anywhere. The diff reads on shape and on the 2px rule.
| 26px | Source-control row height |
| 28px | Status bar, state-specimen rows |
| 30px | Context-menu item height |
| 34px | Editor bar, markdown/code panel header |
| 34px | Editor tab strip, markdown/code panel header |
| 44px | Title bar and toolbar |
| 20px | Code line box (13px type) |
| 2px | Radius: buttons, inputs, tags, keycaps, menus' inner rows, code blocks |
@@ -128,8 +134,8 @@ No green, no red anywhere. The diff reads on shape and on the 2px rule.
| 2px | Accent rule: selection, focus border, pull-quote |
| 9999px | Traffic-light dots and avatars only |
Column widths in the workspace: source control 236 · explorer 288 · editor flex ·
agent 480. Agent terminal block 190px tall. Full frame 1760 × 1000.
Column widths in the workspace: source control 300 · explorer 288 · editor flex ·
agent 480 (the agent takes `flex: 1` when the editor is hidden). Agent terminal block 190px tall. Full frame 1760 × 1000.
### Elevation
@@ -156,21 +162,37 @@ Vertical stack: title bar 44px → body (flex row) → status bar 28px.
**Title bar** (`#18202B`, 1px bottom `#232C39`, padding 0 14px, gap 18px)
Traffic lights 12px (`#E8913A`, `#6C7783`, `#3A424C`, gap 8px) · wordmark
`Helder` Mono 700 13px `#F4F5F4` with a blinking `.` in `#E8913A` · project `odynt`
`helder` Mono 700 13px `#F4F5F4` with a blinking `.` in `#E8913A` · project `odynt`
Mono 12px `#6C7783` · `·` · branch `main` Mono 500 12px `#E8913A` · breadcrumb of the
open path in Mono 12px `#6C7783`, last segment `#F4F5F4` 600, `›` separators · then the
toolbar, right-aligned, gap 4px.
open path in Mono 12px `#6C7783`, last segment `#F4F5F4` 600, `›` separators · the
pane-toggle group, centred · the toolbar group, right-aligned · `?` (26px square, 1px
`#232C39`, radius 2, Mono 600 12px `#6C7783`), 8px gap from the toolbar group.
Toolbar toggle: label Sans 12px + keycap. Off = label `#BAC0C0`, no fill. On = fill
`rgba(232,145,58,.10)`, label `#F4F5F4` 500, keycap border `rgba(232,145,58,.35)`.
Hidden-files-off is the muted case: label and keycap both `#6C7783`. Toggles:
Search ⌘F · Fluid ⌘L · Hidden ⌘. · Note ⌘N · Git ⌘G · `?` (26px square, 1px border).
**Button group** — one shared treatment for both header groups. Container: 1px
`#232C39`, radius 2, overflow hidden, no gap. Each button: padding 6px 10px, gap 7px,
Sans 500 12px/1, `white-space: nowrap`, 1px `#232C39` left divider (not on the first).
- On: fill `rgba(232,145,58,.10)`, label `#F4F5F4`, 6px round dot `#E8913A`.
- Off: no fill, label `#6C7783`, dot `#3A424C`.
- Action (not a toggle): no dot, label `#BAC0C0`.
- Shortcut, when shown: Mono 600 11px, no border — `#E8913A` when on or on an action,
`#6C7783` when off.
**Source control column** (236px, `#18202B`, 1px right border)
**Pane toggles** (centred: `position:absolute; left:50%; top:50%;
transform:translate(-50%,-50%)` inside the title bar) — Git · Explorer · File · Claude.
One per column, all on by default, no shortcut shown.
**Toolbar** (right) — Search ⌘F (action) · Auto-fit ⌘A (toggle, on) · Hidden ⌘.
(toggle, off) · Note ⌘N (action). The old Git ⌘G toolbar button is removed; the
Git pane toggle replaces it.
**Source control column** (300px, `#18202B`, 1px right border)
Commit box: 52px `#101720` field, 1px `#232C39`, radius 2, placeholder
"Shift+Enter to commit" `#6C7783`; 34px push button `↑` beside it, same border.
Group header: Mono 700 10px `0.14em` uppercase `#6C7783`, count right in `#E8913A`
("STAGED CHANGES 4", "CHANGES 1"). Rows 26px: status letter (Mono 600 10px — staged
("STAGED CHANGES 4", "CHANGES 1"). Under each group the files are clustered per folder:
a 22px subhead carries `▤` plus the directory path in Mono 400 11px `#6C7783` —
one path per cluster, never repeated on the rows — and clusters are separated by an 8px
gap. Rows 26px: status letter (Mono 600 10px — staged
`#8FBFB4`, unstaged `#F0B476`) · 8px type badge · file name Sans 12px, ellipsised.
Footer line "4 staged · 1 unstaged" Mono 11px `#6C7783`.
@@ -182,10 +204,10 @@ badge and, when dirty, a trailing `M` in `#8FBFB4`.
Type badge: Mono 600 8px, ink text `#101720` on a per-extension fill, radius 2,
padding 3px 4px — php `#C3A6CE` · md `#BAC0C0` · js `#F0B476` · css `#8FBFB4`.
**Editor** (flex, `#101720`) — 34px bar: type badge, path, unsaved dot, `+1` / `−1`
counts, then right-aligned buttons (1px `#232C39`, radius 2): Preview on Markdown,
Diff on a changed file. Active button = amber fill with `#171C22` text.
Code area: CSS grid `56px 1fr`, line box 20px, numbers right-aligned `#3A424C` with
**Editor** (flex, `#101720`) — 34px strip: "MODIFIED" label, `+1` / `−1` counts, then a
right-aligned segmented control (1px `#232C39`, radius 2, dividers 1px): Actual ·
Original · Diff · Split. Active segment = amber fill with `#171C22` text.
Code area: CSS grid `56px 1fr`, line box 20px, numbers right-aligned `#5A6472` with
14px right padding. **Indentation is padding-left on the code cell** (7.82px per space:
31.3 / 62.6 / 93.8 / 125.1) — do not ship non-breaking spaces.
@@ -287,11 +309,11 @@ with amber glyphs.
**Tooltip** — `#232C39` surface, 1px `#3A424C`, radius 2, padding 8px 10px, max 300px,
Sans 12px/1.5 `#E4E7E6`. No arrow, no shadow. The current state is named inside the
sentence in amber ("Hidden files: *hidden* — …", "Column widths: *fluid* — …"), then one
sentence in amber ("Hidden files: *hidden* — …", "Auto-fit panels: *on* — …"), then one
sentence saying what a click does.
**Markdown code / Preview** — same 34px header on both halves; the active button is the
amber fill. Code = the code grid (`44px 1fr`, line box 20px) with
**Markdown Actual / Preview** — same 34px header on both halves; the segmented control's
active side is the amber fill. Actual = the code grid (`44px 1fr`, line box 20px) with
`##` headings in `#F0B476`. Preview: 18px/20px padding, max 68ch, Sans 13px/1.7 body,
Mono 700 headings with a 1px `#232C39` underline.
@@ -299,7 +321,7 @@ Mono 700 headings with a 1px `#232C39` underline.
Four specimens at 620px: a JS module, a PHP class, a CSS file and the full markdown
preview. Each panel: 34px header with type badge, path Mono 500 12px, and a right
language label (or the Preview button).
language label (or the Actual/Preview control).
The markdown preview is the reading surface, so it is the one place where Sans body copy
gets room:
@@ -329,17 +351,31 @@ gets room:
| `⌘←` / `⌘→` | Move focus between search columns |
| `↵` | Open the selected row (search hit, file, recent project) |
| `⌘→` (editor) | Pass the current selection to the agent |
| `⌘M` | Markdown: code or rendered preview |
| `⌘C` / `⌘↵` / `⌘P` (git) | Focus commit message (not from a terminal) / commit staged / push branch |
| `⌘M` | Cycle Actual · Original · Diff · Split |
| `⌘C` / `⌘↵` / `⌘P` (git) | Focus commit message / commit staged / push branch |
| `⌘A` | Toggle auto-fit panels (columns re-fit on resize and focus) |
| `⌘.` | Toggle hidden dotfiles in tree and search |
| `⌘G` | Show or hide the source-control column |
| `⌘G` | Show or hide the source-control column (same as the Git pane toggle) |
| Pane toggle click | Show or hide that column — see below |
| `⌘S` / `⌘W` / `⌘D` | Save / close / delete (confirm) the current file |
| `⌘N` | Open the project note; it saves on focus loss |
| `⌘P` (note open) | Send the whole note to the agent |
| right-click a row | Context menu, anchored to the pointer, first item pre-highlighted |
| `esc` | Close the top overlay, menu or prompt; never more than one |
**Pane visibility — strictly visibility.** A pane toggle only hides or shows its
column. It must never unmount, re-create or reset what is inside it:
- Keep every column mounted; hide with `display: none` (or equivalent), not by removing
it from the tree or rendering conditionally.
- The Claude Code session, the terminal process and its scrollback, the prompt draft,
the explorer's expanded state, the editor buffer, cursor and scroll position all
survive any number of hide/show cycles.
- No session restart, no PTY respawn, no re-fetch when a column comes back.
- Remaining columns reflow: the editor (flex) absorbs freed width; when the editor is
hidden the agent column grows to fill. All four may be off at once; the body then
shows the editor background.
- Persist the four flags per project.
Rules that hold everywhere:
- Exactly one overlay at a time, on a flat ink scrim. Overlays never stack.
- Hover changes fill one step and nothing else. No lift, no scale, no shadow, no opacity.
@@ -353,12 +389,13 @@ Rules that hold everywhere:
- `project` — path, branch, recent list (persisted)
- `openFile` — path, language, dirty flag, cursor line/col, view mode
(`code|actual|preview|diff`)
(`actual|original|diff|split`)
- `tree` — expanded paths, selected path, `showHidden`
- `git` — staged[], unstaged[], commit message draft, ahead/behind counts
- `agent` — model, session, transcript, prompt draft, pending tool calls, auth notices
- `overlay` — `null | search | shortcuts | note | diff | launcher | menu | passOn`
- `panels` — column widths, `autoFit`, `gitVisible`
- `panels` — column widths, `autoFit`, and `visible: { git, explorer, file, claude }`
(all `true` by default, persisted per project)
- `note` — text, dirty flag (write on blur)
Search runs per keystroke against three indexes (open file, project contents, file
@@ -374,9 +411,12 @@ woff2 for a desktop build).
## Files
- `design-canvas.dc.html` — the design board: all screens, one canvas, real sizes
- `Helder IDE.dc.html` — the design board: all screens, one canvas, real sizes
- `tokens/*.css` — the Kade token files the board is built on (colour, type, spacing,
radius, elevation, motion, fonts)
- `styles.css` — the token entry point
Open `design-canvas.dc.html` in a browser; the board is inert (no interaction) by design.
- `support.js` — the runtime the board needs to open in a browser (not part of the design)
Open `Helder IDE.dc.html` in a browser. The board is inert except for the four pane
toggles in the workspace title bar, which demonstrate the hide/show behaviour.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 260 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 171 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 176 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 192 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

File diff suppressed because it is too large Load Diff