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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions macos/Sources/Features/Worktrunk/WorktrunkPreferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ enum WorktrunkPreferences {
static let defaultAgentKey = "GhosttyWorktrunkDefaultAgent.v1"
static let githubIntegrationKey = "GhostreeGitHubIntegration.v1"
static let lastEditorKey = "GhostreeLastEditor.v1"
static let displaySessionTimeKey = "GhostreeDisplaySessionTime.v1"

static var worktreeTabsEnabled: Bool {
UserDefaults.standard.bool(forKey: worktreeTabsKey)
Expand Down Expand Up @@ -311,4 +312,11 @@ enum WorktrunkPreferences {
}
return installed.first
}

static var displaySessionTimeEnabled: Bool {
if !UserDefaults.standard.dictionaryRepresentation().keys.contains(displaySessionTimeKey) {
return true
}
return UserDefaults.standard.bool(forKey: displaySessionTimeKey)
}
}
8 changes: 8 additions & 0 deletions macos/Sources/Features/Worktrunk/WorktrunkSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ struct WorktrunkSettingsView: View {
@AppStorage(WorktrunkPreferences.openBehaviorKey) private var openBehaviorRaw: String = WorktrunkOpenBehavior.newTab.rawValue
@AppStorage(WorktrunkPreferences.defaultAgentKey) private var defaultActionRaw: String = WorktrunkDefaultAction.terminal.rawValue
@AppStorage(WorktrunkPreferences.githubIntegrationKey) private var githubIntegrationEnabled: Bool = true
@AppStorage(WorktrunkPreferences.displaySessionTimeKey) private var displaySessionTimeEnabled: Bool = true

@State private var ghAvailable: Bool = false

Expand Down Expand Up @@ -79,6 +80,13 @@ struct WorktrunkSettingsView: View {
}
}
}

Section("Display") {
Toggle("Display session time", isOn: $displaySessionTimeEnabled)
Text("Show relative timestamps next to worktrees and sessions in the sidebar.")
.font(.caption)
.foregroundStyle(.secondary)
}
}
.formStyle(.grouped)
.navigationTitle("Worktrunk")
Expand Down
22 changes: 14 additions & 8 deletions macos/Sources/Features/Worktrunk/WorktrunkSidebarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ struct WorktrunkSidebarView: View {

@AppStorage(WorktrunkPreferences.defaultAgentKey) private var defaultActionRaw: String = WorktrunkDefaultAction.terminal.rawValue
@AppStorage(WorktrunkPreferences.sidebarTabsKey) private var sidebarTabsEnabled: Bool = true
@AppStorage(WorktrunkPreferences.displaySessionTimeKey) private var displaySessionTimeEnabled: Bool = true
@State private var createSheetRepo: WorktrunkStore.Repository?
@State private var removeRepoConfirm: WorktrunkStore.Repository?
@State private var removeWorktreeConfirm: WorktrunkStore.Worktree?
Expand Down Expand Up @@ -675,7 +676,7 @@ struct WorktrunkSidebarView: View {
VStack(alignment: .leading, spacing: 1) {
Text(wt.branch)
.lineLimit(1)
if let recencyDate {
if displaySessionTimeEnabled, let recencyDate {
(Text(repoName) + Text(" • ") + Text(recencyDate, style: .relative))
.font(.caption)
.foregroundStyle(.secondary)
Expand Down Expand Up @@ -947,6 +948,7 @@ private struct WorktreeTabRowLabel: View {
let onDropBefore: (Int) -> Void
let windowNumberByWorktreePath: [String: Int]

@AppStorage(WorktrunkPreferences.displaySessionTimeKey) private var displaySessionTimeEnabled: Bool = true
@State private var isDropTarget: Bool = false

private var isDropTargetBinding: Binding<Bool> {
Expand Down Expand Up @@ -977,7 +979,7 @@ private struct WorktreeTabRowLabel: View {
.fontWeight(tab.isActive ? .semibold : .regular)
if let repoName {
let recencyDate = store.recencyDate(for: worktree.path)
if let recencyDate {
if displaySessionTimeEnabled, let recencyDate {
(Text(repoName) + Text(" • ") + Text(recencyDate, style: .relative))
.font(.caption)
.foregroundStyle(.secondary)
Expand Down Expand Up @@ -1100,7 +1102,7 @@ private struct CreateWorktreeSheet: View {
@State private var base: String = ""
@State private var createBranch: Bool = true
@State private var isWorking: Bool = false
@State private var errorText: String? = nil
@State private var errorText: String?

var body: some View {
VStack(alignment: .leading, spacing: 12) {
Expand Down Expand Up @@ -1170,6 +1172,8 @@ private struct SessionRow: View {
let session: AISession
let onResume: () -> Void

@AppStorage(WorktrunkPreferences.displaySessionTimeKey) private var displaySessionTimeEnabled: Bool = true

var body: some View {
Button(action: onResume) {
HStack {
Expand All @@ -1186,11 +1190,13 @@ private struct SessionRow: View {
.font(.caption2)
.foregroundStyle(.secondary)
}
Text("•")
.foregroundStyle(.secondary)
Text(session.timestamp, style: .relative)
.font(.caption2)
.foregroundStyle(.secondary)
if displaySessionTimeEnabled {
Text("•")
.foregroundStyle(.secondary)
Text(session.timestamp, style: .relative)
.font(.caption2)
.foregroundStyle(.secondary)
}
}
}
Spacer()
Expand Down
Loading