Skip to content

Commit 5fcacdd

Browse files
authored
Merge pull request #61 from mcintyre94/display-tool-call-summaries-with-working-directory-643a726f
Apply relativeToCwd to active tool shimmer label
2 parents 1b5772e + 653ae2b commit 5fcacdd

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

Wisp/ViewModels/ChatViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ final class ChatViewModel {
164164
guard let message = currentAssistantMessage else { return nil }
165165
for item in message.content.reversed() {
166166
if case .toolUse(let card) = item, card.result == nil {
167-
return card.activityLabel
167+
return card.activityLabel.relativeToCwd(workingDirectory)
168168
}
169169
}
170170
return nil

Wisp/Views/SpriteDetail/Chat/ToolInputDetailView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ struct ToolInputDetailView: View {
4444
Text(label)
4545
.font(.caption2)
4646
.foregroundStyle(.secondary)
47-
Text(input["file_path"]?.stringValue ?? "")
47+
Text((input["file_path"]?.stringValue ?? "").relativeToCwd(workingDirectory))
4848
.font(.system(.caption, design: .monospaced))
4949
.textSelection(.enabled)
5050
}
5151
}
5252

5353
private var writeInput: some View {
5454
VStack(alignment: .leading, spacing: 4) {
55-
Text(input["file_path"]?.stringValue ?? "")
55+
Text((input["file_path"]?.stringValue ?? "").relativeToCwd(workingDirectory))
5656
.font(.system(.caption, design: .monospaced))
5757
.foregroundStyle(.secondary)
5858

@@ -67,7 +67,7 @@ struct ToolInputDetailView: View {
6767

6868
private var editInput: some View {
6969
VStack(alignment: .leading, spacing: 4) {
70-
Text(input["file_path"]?.stringValue ?? "")
70+
Text((input["file_path"]?.stringValue ?? "").relativeToCwd(workingDirectory))
7171
.font(.system(.caption, design: .monospaced))
7272
.foregroundStyle(.secondary)
7373

Wisp/Views/SpriteDetail/Chat/ToolStepRow.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct ToolStepRow: View {
3434
}
3535

3636
if let preview = card.result?.previewContent {
37-
Text(preview)
37+
Text(preview.relativeToCwd(workingDirectory))
3838
.font(.system(.caption2, design: .monospaced))
3939
.foregroundStyle(.tertiary)
4040
.lineLimit(2)

WispTests/ChatViewModelTests.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,26 @@ struct ChatViewModelTests {
250250
#expect(vm.activeToolLabel?.contains("npm test") == true)
251251
}
252252

253+
@Test func activeToolLabel_relativisesCwd() throws {
254+
let ctx = try makeModelContext()
255+
let (vm, _) = makeChatViewModel(modelContext: ctx)
256+
257+
let msg = ChatMessage(role: .assistant)
258+
vm.messages.append(msg)
259+
vm.setCurrentAssistantMessage(msg)
260+
261+
let event = ClaudeStreamEvent.assistant(ClaudeAssistantEvent(
262+
type: "assistant",
263+
message: ClaudeAssistantMessage(role: "assistant", content: [
264+
.toolUse(ClaudeToolUse(id: "tu-cwd", name: "Bash", input: .object(["command": .string("find /home/sprite/project/src -name '*.swift'")])))
265+
])
266+
))
267+
vm.handleEvent(event, modelContext: ctx)
268+
269+
#expect(vm.activeToolLabel?.contains("/home/sprite/project") == false)
270+
#expect(vm.activeToolLabel?.contains("./src") == true)
271+
}
272+
253273
@Test func activeToolLabel_returnsNilWhenAllToolsComplete() throws {
254274
let ctx = try makeModelContext()
255275
let (vm, _) = makeChatViewModel(modelContext: ctx)

0 commit comments

Comments
 (0)