diff --git a/Sources/HelderCore/Session/ColumnLayout.swift b/Sources/HelderCore/Session/ColumnLayout.swift index 48c6362..c8a982b 100644 --- a/Sources/HelderCore/Session/ColumnLayout.swift +++ b/Sources/HelderCore/Session/ColumnLayout.swift @@ -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) } } diff --git a/Sources/HelderUI/Components/ButtonGroup.swift b/Sources/HelderUI/Components/ButtonGroup.swift new file mode 100644 index 0000000..4b86b1a --- /dev/null +++ b/Sources/HelderUI/Components/ButtonGroup.swift @@ -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) + } +} diff --git a/Sources/HelderUI/Components/Keycap.swift b/Sources/HelderUI/Components/Keycap.swift index 7287fca..2b79756 100644 --- a/Sources/HelderUI/Components/Keycap.swift +++ b/Sources/HelderUI/Components/Keycap.swift @@ -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) } diff --git a/Sources/HelderUI/Components/OverlayShell.swift b/Sources/HelderUI/Components/OverlayShell.swift index fb8091d..491c9c0 100644 --- a/Sources/HelderUI/Components/OverlayShell.swift +++ b/Sources/HelderUI/Components/OverlayShell.swift @@ -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: 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: 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) diff --git a/Sources/HelderUI/Components/PointerBoundTextView.swift b/Sources/HelderUI/Components/PointerBoundTextView.swift new file mode 100644 index 0000000..b2d68cb --- /dev/null +++ b/Sources/HelderUI/Components/PointerBoundTextView.swift @@ -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) + } +} diff --git a/Sources/HelderUI/Components/Splitter.swift b/Sources/HelderUI/Components/Splitter.swift index 3ee57aa..cc254ff 100644 --- a/Sources/HelderUI/Components/Splitter.swift +++ b/Sources/HelderUI/Components/Splitter.swift @@ -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() } } diff --git a/Sources/HelderUI/Components/ToolbarToggle.swift b/Sources/HelderUI/Components/ToolbarToggle.swift deleted file mode 100644 index fef83c4..0000000 --- a/Sources/HelderUI/Components/ToolbarToggle.swift +++ /dev/null @@ -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) - } -} diff --git a/Sources/HelderUI/Components/Tooltip.swift b/Sources/HelderUI/Components/Tooltip.swift index e913557..a664c48 100644 --- a/Sources/HelderUI/Components/Tooltip.swift +++ b/Sources/HelderUI/Components/Tooltip.swift @@ -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)) } diff --git a/Sources/HelderUI/Editor/CodeEditorController.swift b/Sources/HelderUI/Editor/CodeEditorController.swift index 60b93ac..eeb9152 100644 --- a/Sources/HelderUI/Editor/CodeEditorController.swift +++ b/Sources/HelderUI/Editor/CodeEditorController.swift @@ -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] : [] diff --git a/Sources/HelderUI/Editor/CodeTextView.swift b/Sources/HelderUI/Editor/CodeTextView.swift index d25bda6..374105d 100644 --- a/Sources/HelderUI/Editor/CodeTextView.swift +++ b/Sources/HelderUI/Editor/CodeTextView.swift @@ -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. diff --git a/Sources/HelderUI/Editor/EditorColumn.swift b/Sources/HelderUI/Editor/EditorColumn.swift index 291dde9..e07ab4f 100644 --- a/Sources/HelderUI/Editor/EditorColumn.swift +++ b/Sources/HelderUI/Editor/EditorColumn.swift @@ -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() diff --git a/Sources/HelderUI/Editor/EditorPane.swift b/Sources/HelderUI/Editor/EditorPane.swift index 0501d40..54d7c96 100644 --- a/Sources/HelderUI/Editor/EditorPane.swift +++ b/Sources/HelderUI/Editor/EditorPane.swift @@ -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) } diff --git a/Sources/HelderUI/Editor/PassOnPanel.swift b/Sources/HelderUI/Editor/PassOnPanel.swift index 2d53422..e69fff5 100644 --- a/Sources/HelderUI/Editor/PassOnPanel.swift +++ b/Sources/HelderUI/Editor/PassOnPanel.swift @@ -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 diff --git a/Sources/HelderUI/Overlays/NamePromptOverlay.swift b/Sources/HelderUI/Overlays/NamePromptOverlay.swift index 6584e89..7bd4b16 100644 --- a/Sources/HelderUI/Overlays/NamePromptOverlay.swift +++ b/Sources/HelderUI/Overlays/NamePromptOverlay.swift @@ -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) diff --git a/Sources/HelderUI/Overlays/NoteOverlay.swift b/Sources/HelderUI/Overlays/NoteOverlay.swift index ae5063f..fe254f4 100644 --- a/Sources/HelderUI/Overlays/NoteOverlay.swift +++ b/Sources/HelderUI/Overlays/NoteOverlay.swift @@ -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 = "" diff --git a/Sources/HelderUI/Overlays/OverlayKeys.swift b/Sources/HelderUI/Overlays/OverlayKeys.swift index 845a09e..9cfd17c 100644 --- a/Sources/HelderUI/Overlays/OverlayKeys.swift +++ b/Sources/HelderUI/Overlays/OverlayKeys.swift @@ -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 + } +} diff --git a/Sources/HelderUI/Overlays/SearchOverlay.swift b/Sources/HelderUI/Overlays/SearchOverlay.swift index 1f8beb2..558fe3b 100644 --- a/Sources/HelderUI/Overlays/SearchOverlay.swift +++ b/Sources/HelderUI/Overlays/SearchOverlay.swift @@ -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) } + } } } } diff --git a/Sources/HelderUI/Shell/Command.swift b/Sources/HelderUI/Shell/Command.swift index b3a8505..5644f7a 100644 --- a/Sources/HelderUI/Shell/Command.swift +++ b/Sources/HelderUI/Shell/Command.swift @@ -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 /// ⌘. diff --git a/Sources/HelderUI/Shell/HelderScene.swift b/Sources/HelderUI/Shell/HelderScene.swift index ab035c8..8373907 100644 --- a/Sources/HelderUI/Shell/HelderScene.swift +++ b/Sources/HelderUI/Shell/HelderScene.swift @@ -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) } diff --git a/Sources/HelderUI/Shell/TitleBarView.swift b/Sources/HelderUI/Shell/TitleBarView.swift index 92781a0..1836235 100644 --- a/Sources/HelderUI/Shell/TitleBarView.swift +++ b/Sources/HelderUI/Shell/TitleBarView.swift @@ -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 - } } diff --git a/Sources/HelderUI/Shell/WorkspaceView.swift b/Sources/HelderUI/Shell/WorkspaceView.swift index d030457..cee1372 100644 --- a/Sources/HelderUI/Shell/WorkspaceView.swift +++ b/Sources/HelderUI/Shell/WorkspaceView.swift @@ -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 diff --git a/Sources/HelderUI/SourceControl/CommitBox.swift b/Sources/HelderUI/SourceControl/CommitBox.swift index d516745..1ca39d3 100644 --- a/Sources/HelderUI/SourceControl/CommitBox.swift +++ b/Sources/HelderUI/SourceControl/CommitBox.swift @@ -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)? diff --git a/Sources/HelderUI/State/LayoutStore.swift b/Sources/HelderUI/State/LayoutStore.swift index 1c8eced..707a960 100644 --- a/Sources/HelderUI/State/LayoutStore.swift +++ b/Sources/HelderUI/State/LayoutStore.swift @@ -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? { + 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 } } diff --git a/Sources/HelderUI/State/WorkspaceModel.swift b/Sources/HelderUI/State/WorkspaceModel.swift index f11676d..9040f06 100644 --- a/Sources/HelderUI/State/WorkspaceModel.swift +++ b/Sources/HelderUI/State/WorkspaceModel.swift @@ -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) diff --git a/Sources/HelderUI/Terminal/HelderTerminalView.swift b/Sources/HelderUI/Terminal/HelderTerminalView.swift index 10c6297..ebdb18d 100644 --- a/Sources/HelderUI/Terminal/HelderTerminalView.swift +++ b/Sources/HelderUI/Terminal/HelderTerminalView.swift @@ -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. diff --git a/Sources/HelderUI/Theme/Metrics.swift b/Sources/HelderUI/Theme/Metrics.swift index c4b0282..9607c3e 100644 --- a/Sources/HelderUI/Theme/Metrics.swift +++ b/Sources/HelderUI/Theme/Metrics.swift @@ -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 diff --git a/Sources/HelderUI/Theme/Palette.swift b/Sources/HelderUI/Theme/Palette.swift index 4dcec4a..6d725d8 100644 --- a/Sources/HelderUI/Theme/Palette.swift +++ b/Sources/HelderUI/Theme/Palette.swift @@ -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) diff --git a/Sources/HelderUI/Theme/Typography.swift b/Sources/HelderUI/Theme/Typography.swift index 841b209..7350c50 100644 --- a/Sources/HelderUI/Theme/Typography.swift +++ b/Sources/HelderUI/Theme/Typography.swift @@ -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) diff --git a/Tests/HelderCoreTests/Session/ColumnLayoutTests.swift b/Tests/HelderCoreTests/Session/ColumnLayoutTests.swift index 4acf18f..2ffa7df 100644 --- a/Tests/HelderCoreTests/Session/ColumnLayoutTests.swift +++ b/Tests/HelderCoreTests/Session/ColumnLayoutTests.swift @@ -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) + } } diff --git a/Tests/HelderUITests/State/LayoutStoreTests.swift b/Tests/HelderUITests/State/LayoutStoreTests.swift index 11886b7..411e600 100644 --- a/Tests/HelderUITests/State/LayoutStoreTests.swift +++ b/Tests/HelderUITests/State/LayoutStoreTests.swift @@ -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) + } } diff --git a/Tests/HelderUITests/State/WorkspaceModelTests.swift b/Tests/HelderUITests/State/WorkspaceModelTests.swift index 2f078e8..e46268c 100644 --- a/Tests/HelderUITests/State/WorkspaceModelTests.swift +++ b/Tests/HelderUITests/State/WorkspaceModelTests.swift @@ -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": ""]) diff --git a/docs/architecture.md b/docs/architecture.md index 3060e89..8b12406 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -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 diff --git a/docs/behaviour.md b/docs/behaviour.md index 2891b69..085923e 100644 --- a/docs/behaviour.md +++ b/docs/behaviour.md @@ -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. diff --git a/docs/design/design-canvas.dc.html b/docs/design/Helder IDE.dc.html similarity index 54% rename from docs/design/design-canvas.dc.html rename to docs/design/Helder IDE.dc.html index 94680ad..b2d4aa3 100644 --- a/docs/design/design-canvas.dc.html +++ b/docs/design/Helder IDE.dc.html @@ -31,7 +31,7 @@
[ 00 ] design canvas · helder
-

Helder.

+

helder.

An editor for working with Claude Code. One slate shell, one amber accent, IBM Plex Mono for everything that is code or label. Every layer below uses the same four surfaces, the same 24px row height and the same selection marker: 2px amber on the left, fill one step deeper.

workspace @@ -52,14 +52,14 @@
-
+
- Helder. + helder. odynt · main @@ -68,81 +68,93 @@ resources›views›admin›vaults› form.blade.php
-
- Search ⌘F - Fluid ⌘L - Hidden ⌘. - Note ⌘N - Git ⌘G - ? +
+ + + + +
+
+
+ Search⌘F + Auto-fit⌘A + Hidden⌘. + Note⌘N +
+ ?
-
-
-
Shift+Enter to commit
-
↑
-
+
staged changes4
-
Mphpcategory.blade.php
-
Mphpform.blade.php
-
Mphpsubcategory.blade.php
-
Mphpdeclined-names.blade.php
+
▤resources/views/admin/vaults
+
Mphpcategory.blade.php
+
Mphpform.blade.php
+
Mphpsubcategory.blade.php
+
+
▤resources/views/help/vault
+
Mphpdeclined-names.blade.php
changes1
-
Mphpdeclined-names.blade.php
+
+
▤resources/views/help/vault
+
Mphpdeclined-names.blade.php
+
-
4 staged · 1 unstaged
+
+
Shift+Enter to commit
+
Commit↑
+
-
-
explorerodynt
+
+
explorerodynt
-
›▤app
-
›▤blueprints
-
›▤bootstrap
-
›▤config
-
›▤database
-
›▤docs
-
›▤lang
-
›▤public
-
⌄▤resources
-
›▤css
-
›▤js
-
›▤markdown
-
⌄▤views
-
⌄▤admin
-
⌄▤vaults
-
›▤_partials
-
phpcategory.blade.phpM
-
phpform.blade.phpM
-
phpindex.blade.php
-
phpsubcategory.blade.phpM
-
›▤components
-
›▤conversation
-
›▤help
-
›▤settings
-
›▤routes
-
›▤tests
-
mdAGENTS.md
-
mdCLAUDE.md
-
jsvite.config.js
+
›▤app
+
›▤blueprints
+
›▤bootstrap
+
›▤config
+
›▤database
+
›▤docs
+
›▤lang
+
›▤public
+
⌄▤resources
+
›▤css
+
›▤js
+
›▤markdown
+
⌄▤views
+
⌄▤admin
+
⌄▤vaults
+
›▤_partials
+
phpcategory.blade.phpM
+
phpform.blade.phpM
+
phpindex.blade.php
+
phpsubcategory.blade.phpM
+
›▤components
+
›▤conversation
+
›▤help
+
›▤settings
+
›▤routes
+
›▤tests
+
mdAGENTS.md
+
mdCLAUDE.md
+
jsvite.config.js
-
-
+
+
modified +1 −1 @@ -155,43 +167,43 @@
- 1{{-- - 24B — the Vault editor. `$vault === null` means create. - 3--}} - 4 - 5@php - 6$isCreate = $vault === null; - 7$teamClass = \App\Models\Team::class; - 8$userClass = \App\Models\User::class; - 9@endphp - 10 - 11<x-layouts.app :title="$vault?->name"> - 12 - 13<style> - 14.vlt-head { - 15display: flex; - 16align-items: flex-end; - 17gap: 20px; - 18} - 19 - 20.vlt-card { - 21background: var(--color-surface-raised); - 22border: 1px solid var(--color-border-default); - 23border-radius: 4px; - 24padding: 22px 24px; - 25} - 26 - 27.vlt-group-label { - 28font-family: 'IBM Plex Mono', monospace; - 29letter-spacing: .14em; - 30text-transform: uppercase; - 31} - 32</style> + 1{{-- + 24B — the Vault editor. `$vault === null` means create. + 3--}} + 4 + 5@php + 6$isCreate = $vault === null; + 7$teamClass = \App\Models\Team::class; + 8$userClass = \App\Models\User::class; + 9@endphp + 10 + 11<x-layouts.app :title="$vault?->name"> + 12 + 13<style> + 14.vlt-head { + 15display: flex; + 16align-items: flex-end; + 17gap: 20px; + 18} + 19 + 20.vlt-card { + 21background: var(--color-surface-raised); + 22border: 1px solid var(--color-border-default); + 23border-radius: 4px; + 24padding: 22px 24px; + 25} + 26 + 27.vlt-group-label { + 28font-family: 'IBM Plex Mono', monospace; + 29letter-spacing: .14em; + 30text-transform: uppercase; + 31} + 32</style>
-
+
◆
@@ -214,9 +226,9 @@ I read the handoff and the existing policies. Then I write the tests first.
- Read docs/design_handoff_vaults/README.md · 412 lines - Grep "VaultPolicy" · 7 hits - Edit app/Policies/VaultPolicy.php + Read docs/design_handoff_vaults/README.md · 412 lines + Grep "VaultPolicy" · 7 hits + Edit app/Policies/VaultPolicy.php
@@ -233,9 +245,9 @@ /rc
-
[main][~/code/odynt]$ php artisan test --filter=Vault
-
PASS Tests\Feature\VaultAdminTest · 14 assertions
-
[main][~/code/odynt]$
+
[main][~/code/odynt]$ php artisan test --filter=Vault
+
PASS Tests\Feature\VaultAdminTest · 14 assertions
+
[main][~/code/odynt]$
@@ -243,10 +255,11 @@
⑂ main - +16−12 + +16−12 + 4 staged · 1 unstaged resources/views/admin/vaults/form.blade.php - ·Ln 20, Col 12·UTF-8·LF·Blade + ·Ln 20, Col 12·UTF-8·LF·Blade
@@ -279,30 +292,30 @@
this file
-
phpConfigSyncCommand.php
+
phpConfigSyncCommand.php
No matches in this file.
project226
-
phpcypress/e2e/Conversation/ConversationWelcome.php4
+
phpcypress/e2e/Conversation/ConversationWelcome.php4
80function conversationSeedConfig(): void - 99conversationSeedConfig(); - 163conversationSeedConfig(); + 99conversationSeedConfig(); + 163conversationSeedConfig();
-
phpdatabase/seeders/DatabaseSeeder.php3
+
phpdatabase/seeders/DatabaseSeeder.php3
- 230* This row is consumed by AppData::resolveDefaultThemeConfig() - 245'config' => self::guestThemeConfig(), - 257private static function guestThemeConfig(): array + 230* This row is consumed by AppData::resolveDefaultThemeConfig() + 245'config' => self::guestThemeConfig(), + 257private static function guestThemeConfig(): array
-
jscypress/e2e/blueprint-038-conversation-menu.cy.js1
+
jscypress/e2e/blueprint-038-conversation-menu.cy.js1
- 163cy.url().should('eq', Cypress.config('baseUrl') + '/conversation'); + 163cy.url().should('eq', Cypress.config('baseUrl') + '/conversation');
-
mdblueprints/done/012-dialog-page/blueprint.md1
+
mdblueprints/done/012-dialog-page/blueprint.md1
- 162— `config/ai.php` — providers.anthropic.api_key + 162— `config/ai.php` — providers.anthropic.api_key
@@ -404,7 +417,7 @@
◆ - Helder. + helder. Open a project to begin
@@ -416,13 +429,13 @@
recent
-
▤odynt~/code/odynt
-
▤stedt~/code/stedt
+
▤odynt~/code/odynt
+
▤stedt~/code/stedt
▤loopt~/code/loopt
-
▤doen-r~/code/doen-r
-
▤vakwerk~/code/vakwerk
-
▤diagram~/code/diagram
-
▤marketingtools~/code/marketingtools
+
▤doen-r~/code/doen-r
+
▤vakwerk~/code/vakwerk
+
▤diagram~/code/diagram
+
▤marketingtools~/code/marketingtools
⌘↑↓ navigate↵ open @@ -439,9 +452,11 @@
[ 03 ] Diff - Added is teal, removed is amber-deep. No green, no red. + Actual is always the view. Changed lines carry a teal rule; hover one and the old line steps out to the right.
+
3a · opened full — side by side
+
@@ -461,37 +476,298 @@
originalbefore
- 18{{ __('A merge writes a declined row…') }} - 19</p> - 20</section> - 21 - 22<section class="odynt-help__section"> - 23<h2>{{ __('The reason a row can carry') }}</h2> - 24 - 25<p> - 26{{ __('A row can carry one of eleven reason codes…') }} - 27</p> - 28</section> + 18{{ __('A merge writes a declined row…') }} + 19</p> + 20</section> + 21 + 22<section class="odynt-help__section"> + 23<h2>{{ __('The reason a row can carry') }}</h2> + 24 + 25<p> + 26{{ __('A row can carry one of eleven reason codes…') }} + 27</p> + 28</section>
updatedafter
- 18{{ __('A merge writes a declined row…') }} - 19</p> - 20</section> - 21 - 22<section class="odynt-help__section is-reasons"> - 23<h2>{{ __('The reason a row can carry') }}</h2> - 24 - 25<p> - 26{{ __('A row can carry one of eleven reason codes…') }} - 27</p> - 28</section> + 18{{ __('A merge writes a declined row…') }} + 19</p> + 20</section> + 21 + 22<section class="odynt-help__section is-reasons"> + 23<h2>{{ __('The reason a row can carry') }}</h2> + 24 + 25<p> + 26{{ __('A row can carry one of eleven reason codes…') }} + 27</p> + 28</section>
+ +
3b · in the pane — actual view, hover a changed line to see what it was
+ +
+ +
+
+ + + +
+
+ helder. + bob + · + bob2 +
+
+ agents›mail-checker› + README.md +
+
+ Search ⌘F + Fluid ⌘L + Hidden ⌘. + Note ⌘N + Git ⌘G + ? +
+
+ +
+ + +
+
+
runs mail check once an hour
+
↑
+
+
+ staged changes3 +
+
+
▤agents/mail-checker
+
MmdREADME.md
+
▤scheduler
+
Mymlscheduler.yaml
+
▤state
+
Mtsvskill-usage.tsv
+
+
+
+ changes3 +
+
+
▤.
+
MmdCLAUDE.md
+
▤scripts
+
MmdREADME.md
+
Mshcheck-docs-rot.sh
+
+
+
3 staged · 3 unstaged
+
+ + +
+
explorerbob
+
+
⌄▤agents
+
›▤knowledge-researcher
+
›▤lead-agent
+
⌄▤mail-checker
+
mdPROMPT.md
+
mdREADME.mdM
+
mdSTATE.md
+
›▤ok-monitor
+
›▤sterrenkijker
+
›▤tony
+
mdREADME.md
+
›▤assets
+
›▤data
+
›▤docker
+
›▤logs
+
⌄▤scheduler
+
›▤prompts
+
mdREADME.md
+
mdruns-2026H2.md
+
mdruns.md
+
ymlscheduler.yamlM
+
shtest.sh
+
shtick.sh
+
›▤scripts
+
⌄▤state
+
jsonmail-state.json
+
jsonread-counts.json
+
mdREADME.md
+
tsvskill-usage.tsvM
+
mdCLAUDE.mdM
+
mdGUARDRAILS.md
+
mdLOOP.md
+
mdMEMORY.md
+
+
+ + +
+
+ bob +
+ modified + +2 + −2 + +
+ Actual + Original + Preview + Diff +
+
+
+
+
+ + M + + M +
+
+ 1# mail-checker — how I dispatch it + 2 + 3This file is for me (Bob), the dispatcher. It says when to run this agent and how. The agent's own prompt is [`PROMPT.md`](PROMPT.md). I do not read that file myself. + 6 + 7## What it does + 8 + 9It works through imported mails that no AI has looked at yet. Per mail it does three things: + 11 + 121. Judges whether Jonathan should actually read it. + 132. Cleans the body into readable Markdown. + 143. Makes a todo when the mail asks for a concrete action. + 15 + 16New people it meets get a Vault note, so Blijnder remembers them. + 17 + 18## The hard boundary + 19 + 20It reads, cleans, classifies and records. It never replies to a mail, never deletes a mail, and never chooses a recipient. Nothing that it touches leaves Blijnder, and there is no exception to that. + 23 + 24Between 2026-08-22 and 2026-08-27 there was one: an invoice went to the administration through a script of its own. Skynet does that job now (skynet#41), thus the workspace gave it up (bob#371). The agent is mute again, and the outbound gate refuses every command that would speak for it. + 28 + 29## When to dispatch + 30 + 31- The scheduler fires it. Job `mail-checker-ronde`, every hour, on the hour. + 32- Jonathan asks for a mail sweep. + 33- The mail step of my tick shows unchecked mail piling up. + 34 + 35## How to dispatch + 36 + 37Send a subagent the path, not the content: + 38 + 39``` + 40Agent tool → "Read agents/mail-checker/PROMPT.md and follow it." + 41``` +
+
+ + + + + + + + +
+
+
+ + +
+
+
98:| [`check-docs-rot.sh`](check-docs-rot.sh) | It checks my rule files for references that are not correct any more: a script or a flag that does not exist, a dead markdown link, an orphan script, an
+
└ Allowed by auto mode classifier
+
●The column is gone. CLAUDE.md now names which agents exist, and nothing about their clock.
+
Why it was there. The table was written as one map with three columns, and check-docs-rot.sh section L then enforced the third against the cron lines. That made the coupling real: each change of a schedule broke the check until somebody opened a pull request on the root.
+
What changed. The table is two columns. Below it stands one rule: when a job runs, and whether it runs at all, stands in scheduler/scheduler.yaml and only there. Section L still holds the table against agents/ in both directions, and it no longer reads a clock.
+
The check is cleaner now. It reported knowledge-researcher and sterrenkijker as wrong; both were this same duplication, and both are gone.
+
Five files stand changed and uncommitted. CLAUDE.md is a root file, so it needs a pull request when you commit it.
+
✳ Churned for 2m 49s · done 8:10 AM
+
+
+ › + + + +
+
+ original + before this change · same scroll + + hold hover +
+
+ 1# mail-checker — how I dispatch it + 2 + 3This file is for me (Bob), the dispatcher. It says when to run this agent and how. The agent's own prompt is [`PROMPT.md`](PROMPT.md). I do not read that file myself. + 6 + 7## What it does + 8 + 9It works through imported mails that no AI has looked at yet. Per mail it does three things: + 11 + 121. Judges whether Jonathan should actually read it. + 132. Cleans the body into readable Markdown. + 143. Makes a todo when the mail asks for a concrete action. + 15 + 16New people it meets get a Vault note, so Blijnder remembers them. + 17 + 18## The hard boundary + 19 + 20It reads, cleans, classifies and records. It never replies to a mail, never deletes a mail, and never chooses a recipient. Nothing that it touches leaves Blijnder, and there is no exception to that. + 23 + 24Between 2026-08-22 and 2026-08-27 there was one: an invoice went to the administration through a script of its own. Skynet does that job now (skynet#41), thus the workspace gave it up (bob#371). The agent is mute again, and the outbound gate refuses every command that would speak for it. + 28 + 29## When to dispatch + 30 + 31- The scheduler fires it. Job `mail-checker-ronde`, every 15 minutes. + 32- Jonathan asks for a mail sweep. + 33- The mail step of my tick shows unchecked mail piling up. + 34 + 35## How to dispatch + 36 + 37Send a subagent the path, not the content: + 38 + 39``` + 40Agent tool → "Read agents/mail-checker/PROMPT.md and follow it." + 41``` +
+
+
+
+
+ [Opus 5 · 1M] + bob + |⑂ bob2 + /rc +
+
▸▸ auto mode on (shift+tab to cycle) · ← for agents
+
+
+
[bob2][~/code/bob]$
+
+
+
+ +
+ ⑂ bob2 + +22−66 + + agents/mail-checker/README.md + ·Ln 1, Col 1·UTF-8·LF·Markdown +
+
@@ -509,12 +785,12 @@
tests/Unit/ExampleTest.php
◇Pass on reference
-
⧉Copy reference
-
◇Pass on file name
-
⧉Copy file name
+
⧉Copy reference
+
◇Pass on file name
+
⧉Copy file name
-
✎Rename file
-
▤Show in Finder
+
✎Rename file
+
▤Show in Finder
⌫Delete file
@@ -524,10 +800,10 @@
resources/views/help/vault/declined-names.blade.php
◇Pass on reference
-
⧉Copy reference
+
⧉Copy reference
-
+Stage changes
-
⇄Open diff
+
+Stage changes
+
⇄Open diff
↺Discard changes
@@ -558,7 +834,7 @@
Search ⌘F - Fluid ⌘L + Auto-fit ⌘A Hidden ⌘. Note ⌘N Git ⌘G @@ -566,7 +842,7 @@
Hidden files: hidden — dotfiles excluded from the tree and the search. Click to show.
-
Column widths: fluid — the columns re-fit on resize and focus. Click to lock them.
+
Auto-fit panels: on — columns re-fit on resize and focus. Click to lock the current sizes.
Project note (.notes.txt) — kept next to this project.
@@ -587,16 +863,16 @@
- 1You write the handover record for a - 2conversation that is about to be cut. - 3 - 4The reader is a model with no access to - 5the original messages. - 6 - 7## Sources - 8 - 9Use only the messages, the tool results - 10and the previous summary. + 1You write the handover record for a + 2conversation that is about to be cut. + 3 + 4The reader is a model with no access to + 5the original messages. + 6 + 7## Sources + 8 + 9Use only the messages, the tool results + 10and the previous summary.
@@ -642,20 +918,22 @@
-
syntax
+
syntax · eight roles
- text · #E4E7E6 - variable · #BAC0C0 - comment · #6C7783 - keyword · #C3A6CE - string · #8FBFB4 - number · tag · #F0B476 + plain · #F1F3F2 + variable · #D4D9D8 + comment · #828D9A + keyword · #D8BEE4 + string · #A8D6CB + number · tag · #F8C793 + function · method · #A9C0E4 + class · selector · #EFBCB0
- + added — #8FBFB4 op rgba(143,191,180,.12) - − removed — #C4741F op rgba(196,116,31,.14) + + added — #8FBFB4 on rgba(143,191,180,.12) + − removed — #C4741F on rgba(196,116,31,.14)
-

Six colours, all muted. No green for good and no red for bad — the diff reads on shape and on the 2px rule, not on alarm.

+

Eight colours, all lifted off the surface but never saturated. No green for good and no red for bad — the diff reads on shape and on the 2px rule, not on alarm.

@@ -692,7 +970,7 @@
[ 06 ] Code colours - The same six colours across every language. Nothing bold, nothing italic — weight stays 400 so the column reads flat. + The same eight colours across every language. Nothing bold, nothing italic — weight stays 400 so the column reads flat.
@@ -701,33 +979,33 @@
6a · javascript
- js + js resources/js/symbols-service.js javascript
- 1// One request per file. The tree keeps the last answer. - 2 - 3import { cache } from './cache.js'; - 4 - 5const ENDPOINT = '/api/symbols'; - 6const TIMEOUT = 2500; - 7 - 8export async function readSymbols(path, signal) { - 9if (cache.has(path)) return cache.get(path); - 10 - 11const res = await fetch(`${ENDPOINT}?p=${path}`, { signal }); - 12 - 13if (!res.ok) { - 14throw new Error(`symbols: ${res.status}`); - 15} - 16 - 17const rows = await res.json(); - 18cache.set(path, rows); - 19 - 20return rows; - 21} + 1// One request per file. The tree keeps the last answer. + 2 + 3import { cache } from './cache.js'; + 4 + 5const ENDPOINT = '/api/symbols'; + 6const TIMEOUT = 2500; + 7 + 8export async function readSymbols(path, signal) { + 9if (cache.has(path)) return cache.get(path); + 10 + 11const res = await fetch(`${ENDPOINT}?p=${path}`, { signal }); + 12 + 13if (!res.ok) { + 14throw new Error(`symbols: ${res.status}`); + 15} + 16 + 17const rows = await res.json(); + 18cache.set(path, rows); + 19 + 20return rows; + 21}
@@ -736,40 +1014,40 @@
6b · php
- php + php app/Console/Commands/ConfigSyncCommand.php php
- 1<?php - 2 - 3declare(strict_types=1); - 4 - 5namespace App\Console\Commands; - 6 - 7use App\Models\Config; - 8 - 9/** Writes one row per config group. */ - 10final class ConfigSyncCommand extends Command - 11{ - 12protected $signature = 'config:sync'; - 13 - 14public function handle(): int - 15{ - 16$created = 0; - 17 - 18foreach ($this->registry() as $key => $class) { - 19$row = Config::query()->find($key); - 20 - 21if ($row === null) { - 22$created++; - 23} - 24} - 25 - 26return self::SUCCESS; - 27} - 28} + 1<?php + 2 + 3declare(strict_types=1); + 4 + 5namespace App\Console\Commands; + 6 + 7use App\Models\Config; + 8 + 9/** Writes one row per config group. */ + 10final class ConfigSyncCommand extends Command + 11{ + 12protected $signature = 'config:sync'; + 13 + 14public function handle(): int + 15{ + 16$created = 0; + 17 + 18foreach ($this->registry() as $key => $class) { + 19$row = Config::query()->find($key); + 20 + 21if ($row === null) { + 22$created++; + 23} + 24} + 25 + 26return self::SUCCESS; + 27} + 28}
@@ -778,36 +1056,36 @@
6c · css
- css + css resources/css/panels.css css
- 1/* Four surfaces, one accent. Nothing else. */ - 2 - 3:root { - 4--editor: #101720; - 5--panel: #18202B; - 6--accent: #E8913A; - 7} - 8 - 9.row { - 10display: flex; - 11gap: 8px; - 12height: 24px; - 13border-left: 2px solid transparent; - 14transition: background 160ms ease-out; - 15} - 16 - 17.row:hover { - 18background: #1E2733; - 19} - 20 - 21.row[aria-selected='true'] { - 22background: #232C39; - 23border-left-color: var(--accent); - 24} + 1/* Four surfaces, one accent. Nothing else. */ + 2 + 3:root { + 4--editor: #101720; + 5--panel: #18202B; + 6--accent: #E8913A; + 7} + 8 + 9.row { + 10display: flex; + 11gap: 8px; + 12height: 24px; + 13border-left: 2px solid transparent; + 14transition: background 160ms ease-out; + 15} + 16 + 17.row:hover { + 18background: #1E2733; + 19} + 20 + 21.row[aria-selected='true'] { + 22background: #232C39; + 23border-left-color: var(--accent); + 24}
@@ -816,7 +1094,7 @@
6d · markdown preview
- md + md blueprints/046-symbols/blueprint.md @@ -836,8 +1114,8 @@
A symbol list nobody asked for is a symbol list nobody reads. Open the file first.
- // the shape one row returns - { rel: 'class', line: 42, kind: 'php' } + // the shape one row returns + { rel: 'class', line: 42, kind: 'php' }
@@ -863,8 +1141,29 @@