adds claude-generated commit messages and a recent commits panel to the git view - adds log tailing in the explorer, branch merging and a clean up button
This commit is contained in:
@@ -46,12 +46,18 @@ public final class TerminalStore {
|
||||
public private(set) var isConfigured = false
|
||||
public private(set) var agentExited = false
|
||||
public private(set) var shellExited = false
|
||||
public private(set) var tailExited = false
|
||||
/// The file the Explorer's tail block follows; nil while no block is shown.
|
||||
public private(set) var tailedPath: String?
|
||||
/// Moves on every new tail, so the block builds a fresh pane and the old file's output never stays.
|
||||
public private(set) var tailGeneration = 0
|
||||
/// True while the agent's composer holds typed or pasted text, so the next paste starts on a new line.
|
||||
public private(set) var agentComposerHasText = false
|
||||
|
||||
@ObservationIgnored public let projectRoot: String?
|
||||
@ObservationIgnored public private(set) var agent: TerminalSessionHandle?
|
||||
@ObservationIgnored public private(set) var shell: TerminalSessionHandle?
|
||||
@ObservationIgnored public private(set) var tail: TerminalSessionHandle?
|
||||
@ObservationIgnored private let environment: [String: String]
|
||||
/// A right-click in a pane: its kind, whether it holds a selection, the click in window coordinates.
|
||||
@ObservationIgnored public var contextMenuRequested: ((TerminalKind, Bool, CGPoint) -> Void)?
|
||||
@@ -63,7 +69,10 @@ public final class TerminalStore {
|
||||
|
||||
/// Executable, arguments, environment and cwd for a pane.
|
||||
public func launch(for kind: TerminalKind) -> TerminalLaunch {
|
||||
TerminalLaunch.make(kind: kind, config: config, projectRoot: projectRoot, environment: environment)
|
||||
guard kind == .tail else {
|
||||
return TerminalLaunch.make(kind: kind, config: config, projectRoot: projectRoot, environment: environment)
|
||||
}
|
||||
return TerminalLaunch.tail(path: tailedPath ?? "", projectRoot: projectRoot, environment: environment)
|
||||
}
|
||||
|
||||
/// argv[0] with a leading dash, which makes the shell a login shell: a Finder-launched app
|
||||
@@ -76,6 +85,7 @@ public final class TerminalStore {
|
||||
switch kind {
|
||||
case .agent: agent
|
||||
case .shell: shell
|
||||
case .tail: tail
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,15 +99,37 @@ public final class TerminalStore {
|
||||
case .shell:
|
||||
shell = handle
|
||||
if shellExited { shellExited = false }
|
||||
case .tail:
|
||||
tail = handle
|
||||
if tailExited { tailExited = false }
|
||||
}
|
||||
}
|
||||
|
||||
/// Attaches a pane and spawns its process.
|
||||
public func start(_ kind: TerminalKind, on handle: TerminalSessionHandle) {
|
||||
if kind == .tail && tailedPath == nil { return }
|
||||
attach(handle, as: kind)
|
||||
let launch = launch(for: kind)
|
||||
Log.info("pty", "spawn \(kind.rawValue): \(launch.executable) \(launch.arguments.joined(separator: " ")) in \(launch.workingDirectory)")
|
||||
handle.start(launch, argv0: Self.loginArgv0(for: launch.executable))
|
||||
let argv0 = kind == .tail ? (launch.executable as NSString).lastPathComponent : Self.loginArgv0(for: launch.executable)
|
||||
handle.start(launch, argv0: argv0)
|
||||
}
|
||||
|
||||
/// Shows the tail block on `path`; a running tail is killed first, and the block's new pane spawns the fresh one.
|
||||
public func startTail(_ path: String) {
|
||||
tail.map(Self.terminate)
|
||||
tail = nil
|
||||
tailExited = false
|
||||
tailedPath = path
|
||||
tailGeneration += 1
|
||||
}
|
||||
|
||||
/// Kills the tail and removes its block.
|
||||
public func closeTail() {
|
||||
tail.map(Self.terminate)
|
||||
tail = nil
|
||||
tailExited = false
|
||||
tailedPath = nil
|
||||
}
|
||||
|
||||
/// Kills whatever runs in the pane and spawns it again with the current config.
|
||||
@@ -112,6 +144,7 @@ public final class TerminalStore {
|
||||
switch kind {
|
||||
case .agent: agentExited = true
|
||||
case .shell: shellExited = true
|
||||
case .tail: tailExited = true
|
||||
}
|
||||
if let exitCode, exitCode != 0 {
|
||||
Log.warn("pty", "\(kind.rawValue) exited unexpectedly with code \(exitCode)")
|
||||
@@ -121,7 +154,11 @@ public final class TerminalStore {
|
||||
}
|
||||
|
||||
public func hasExited(_ kind: TerminalKind) -> Bool {
|
||||
kind == .agent ? agentExited : shellExited
|
||||
switch kind {
|
||||
case .agent: agentExited
|
||||
case .shell: shellExited
|
||||
case .tail: tailExited
|
||||
}
|
||||
}
|
||||
|
||||
/// Feed every keystroke the user sends to the agent: Enter empties the composer, printable text fills it.
|
||||
@@ -157,16 +194,19 @@ public final class TerminalStore {
|
||||
agent = nil
|
||||
} else if shell === handle {
|
||||
shell = nil
|
||||
} else if tail === handle {
|
||||
tail = nil
|
||||
} else {
|
||||
return
|
||||
}
|
||||
Self.terminate(handle)
|
||||
}
|
||||
|
||||
/// Kills both processes; call it before the window closes or the store is replaced.
|
||||
/// Kills every process, the tail included; call it before the window closes or the store is replaced.
|
||||
public func terminateAll() {
|
||||
agent.map(Self.terminate)
|
||||
shell.map(Self.terminate)
|
||||
closeTail()
|
||||
agent = nil
|
||||
shell = nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user