zotero / zotero-google-docs-integration

32 stars 6 forks source link

Bugginess when switching between in-text and footnote styles #16

Closed dstillman closed 5 years ago

dstillman commented 5 years ago

I'm seeing some weird stuff switching between APA and Chicago Full Note.

I didn't switch away, but got this:

switch-away

And after the update I was left with this:

orphaned-citation

It's still a field, but I can't seem to collect it into the current style even by switching back and forth or refreshing.

adomasven commented 5 years ago

This occurs if the cursor is placed in a citation when switching styles. We don't have a reliable way to move the cursor out of citations, so we'll just have to prompt and ask the users to do that by hand.

dstillman commented 5 years ago

I'm getting the alert when the cursor is most definitely not in a citation.

dstillman commented 5 years ago

(Or maybe you mean the orphaned citation, in which case that might've been the case.)

adomasven commented 5 years ago

I'm getting the alert when the cursor is most definitely not in a citation.

Yes, I'm adjusting the wording there to

The Zotero plugin needs the Google Docs tab to stay active for the current operation. Please do not switch away from the window until the operation is complete.

Since the prompt only applies for converting from inline to footnote citation styles.

dstillman commented 5 years ago

To be clear, this is just totally broken for me — it's not an issue of the wording. My cursor isn't in a citation, and I'm not switching tabs or switching programs. I'm just trying to change to Chicago and this happens.

adomasven commented 5 years ago

Ok, so the full situation is the following:

Switching from inline to footnote styles is not possible from gdocs backend, so we're manually converting every citation by issuing a bunch of commands:

  1. Invoke the find dialog and iterate over all citations with a specific citation text and check whether their id matches with the one we are looking to convert
  2. Remove the found citation text and insert a footnote in its place
  3. Insert a placeholder for the citation with the correct ID in the footnote
  4. Go back to 1 until all citations converted
  5. Write the correct citation text from the gdocs backend.

For the first phase (1-4) we need the browser focused, which is why you are getting the prompt. If you press "OK" the operation continues.

It appears that if the cursor is placed in one of the citations the conversion procedure for that citation breaks and it remains in the text. This is where you are right now. If you convert back to an inline style and then try to convert to a footnote style with the cursor out of any citations, it will work.

Note: switching from footnote to inline styles can be done fully in the gdocs backend and is much more reliable.

dstillman commented 5 years ago

For the first phase (1-4) we need the browser focused, which is why you are getting the prompt. If you press "OK" the operation continues.

OK, but then this is just a fundamental problem with the way this works. So if we can't focus the browser automatically after closing doc prefs, the prompt can't sound like the user did something wrong, when all they did was make a selection in the doc prefs (which isn't clearly not part of the browser) and click OK.

adomasven commented 5 years ago

OK, but then this is just a fundamental problem with the way this works. So if we can't focus the browser automatically after closing doc prefs, the prompt can't sound like the user did something wrong, when all they did was make a selection in the doc prefs (which isn't clearly not part of the browser) and clicking OK.

Which is why I am adjusting the wording to where it works in any scenario.

dstillman commented 5 years ago

I'm saying the proposed wording doesn't work for that, though — that makes me feel like I did something wrong.

adomasven commented 5 years ago

Why not? It's a notice. "Please do not switch away from the window until the operation is complete." You actually need to know this as an user, since a conversion can take a while.

dstillman commented 5 years ago

Because I didn’t switch away to begin with, and wasn’t planning to switch away. Maybe it’s more accurate to say that it seems like something unexpected happened. And the way that it appears on screen, behind the progress bar, looks like a bug. So if this is just how style switching in this direction needs to work, it should say something like “Zotero will now update your document.\n\n” and then “Zotero needs…”.

Can we move the progress bar at this moment so that the prompt can appear without the bar blocking it?

adomasven commented 5 years ago

Can we move the progress bar at this moment so that the prompt can appear without the bar blocking it?

I'll see what we can do.

So if this is just how style switching in this direction needs to work, it should say something like “Zotero will now update your document.\n\n” and then “Zotero needs…”.

I've adjusted the text for the initial invocation to "Zotero will now update your document and needs the Google Docs tab to stay active. Please do not switch away from the window until the operation is complete."

dstillman commented 5 years ago

That's good.

dstillman commented 5 years ago

I'm now seeing "Zotero needs the Google Docs tab to stay active…" but not "Zotero will now update your document…" when switching to Chicago.

dstillman commented 5 years ago

I'm also getting some hanging after a style switch that doesn't update the document. This is master, Chrome, and Connector 5.0.46.

zotero(5)(+0006892): POST /connector/document/execCommand HTTP/1.1
Host: 127.0.0.1:23119
Connection: keep-alive
Content-Length: 80
X-Zotero-Version: 5.0.46
Origin: chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc
X-Zotero-Connector-API-Version: 2
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36
Content-Type: application/json
Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9

zotero(3)(+0000002): Integration: http-setDocPrefs:'1vCX-b1VlsTEDdGpKExgQiBOglEn_MSLMntWGQcDoiD4' invoked

zotero(5)(+0000004): HTTP/1.0 200 OK
X-Zotero-Version: 5.0.57.SOURCE.9a8c676ed
X-Zotero-Connector-API-Version: 2
Content-Type: application/json

{"command":"Application.getActiveDocument","arguments":[]}

zotero(5)(+0000006): POST /connector/document/respond HTTP/1.1
Host: 127.0.0.1:23119
Connection: keep-alive
Content-Length: 158
X-Zotero-Version: 5.0.46
Origin: chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc
X-Zotero-Connector-API-Version: 2
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36
Content-Type: application/json
Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9

zotero(5)(+0000012): HTTP/1.0 200 OK
X-Zotero-Version: 5.0.57.SOURCE.9a8c676ed
X-Zotero-Connector-API-Version: 2
Content-Type: application/json

{"command":"Document.getDocumentData","arguments":["1vCX-b1VlsTEDdGpKExgQiBOglEn_MSLMntWGQcDoiD4"]}

zotero(3)(+0000252): Moving window to 880, 769

zotero(5)(+0000042): POST /connector/document/respond HTTP/1.1
Host: 127.0.0.1:23119
Connection: keep-alive
Content-Length: 435
X-Zotero-Version: 5.0.46
Origin: chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc
X-Zotero-Connector-API-Version: 2
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36
Content-Type: application/json
Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9

zotero(5)(+0000010): HTTP/1.0 200 OK
X-Zotero-Version: 5.0.57.SOURCE.9a8c676ed
X-Zotero-Connector-API-Version: 2
Content-Type: application/json

{"command":"Document.getFields","arguments":["1vCX-b1VlsTEDdGpKExgQiBOglEn_MSLMntWGQcDoiD4","Http"]}

zotero(3)(+0000002): Integration: Displaying dialog chrome://zotero/content/integration/integrationDocPrefs.xul

zotero(5)(+0000584): POST /connector/document/respond HTTP/1.1
Host: 127.0.0.1:23119
Connection: keep-alive
Content-Length: 7693
X-Zotero-Version: 5.0.46
Origin: chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc
X-Zotero-Connector-API-Version: 2
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36
Content-Type: application/json
Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9

zotero(3)(+0000004): Integration: Retrieved 8 fields in 0.592; 13.513513513513514 fields/second

zotero(5)(+0002878): HTTP/1.0 200 OK
X-Zotero-Version: 5.0.57.SOURCE.9a8c676ed
X-Zotero-Connector-API-Version: 2
Content-Type: application/json

{"command":"Field.convert","arguments":["1vCX-b1VlsTEDdGpKExgQiBOglEn_MSLMntWGQcDoiD4",["Hd0JZw","5lPC1F","sYnXnR","OHQJ4a","lRMelB","BnJPlL","5iv6d9"],"Http",[1,1,1,1,1,1,1]]}

zotero(3)(+0000548): Moving window to 880, 769

After this, the document isn't updated and stays in APA. If I then go to change the style again, I get this:

zotero(5)(+0042980): POST /connector/document/execCommand HTTP/1.1
Host: 127.0.0.1:23119
Connection: keep-alive
Content-Length: 80
X-Zotero-Version: 5.0.46
Origin: chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc
X-Zotero-Connector-API-Version: 2
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36
Content-Type: application/json
Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9

zotero(3)(+0000004): Integration: Request already in progress; not executing http setDocPrefs

zotero(5)(+0000000): HTTP/1.0 503 Service Unavailable
X-Zotero-Version: 5.0.57.SOURCE.9a8c676ed
X-Zotero-Connector-API-Version: 2
Content-Type: text/plain

Integration transaction is already in progress
adomasven commented 5 years ago

Should be fixed with e0f8e3e06267ddb4ce0e0a39b2e3b326b1476657