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
3 changes: 3 additions & 0 deletions lua/opencode/protocols/v2/operations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,9 @@ end
---@return Promise<OpencodeV2FileDiff[]>
function M.diff_session(connection, session_id, from, to, reverse_path_map)
return json_request(connection, 'V2 diff_session', 'GET', '/api/session/' .. session_id .. '/diff', {
-- The server's INT_MAX default can overflow Git's hunk merging. Keep effectively
-- full-file context below INT_MAX / 2 so side-by-side reconstruction stays valid.
context = 1000000000,
from = from,
to = to,
}):and_then(function(value)
Expand Down
14 changes: 13 additions & 1 deletion tests/unit/protocol_v2_operations_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,23 @@ describe('V2 protocol operations', function()
end)
:wait()
assert.equals('/api/session/ses_123/diff', request.path)
assert.equals('from=msg_one&to=msg_two', request.query)
assert.equals('context=1000000000&from=msg_one&to=msg_two', request.query)
assert.equals('/host/file.lua', files[1].file)
assert.equals('@@ -1 +1 @@\n-old\n+new', files[1].patch)
end)

it('requests bounded full-file context even without explicit turn boundaries', function()
local request
transport.request = function(_, value)
request = value
return Promise.new():resolve({ status = 200, body = '{"data":[]}' })
end
assert.same({}, operations.diff_session(ready_connection(), 'ses_123'):wait())
assert.equals('GET', request.method)
assert.equals('/api/session/ses_123/diff', request.path)
assert.equals('context=1000000000', request.query)
end)

it('uses direct, location/data, and page response contracts from the V2 fixtures', function()
local bodies = {
['/api/location'] = fixture('location.json'),
Expand Down
Loading