{"action":"created","comment":{"url":"https://api.github.com/repos/weaveworks/scope/pulls/comments/86305570","pull_request_review_id":6968716,"id":86305570,"diff_hunk":"@@ -32,27 +32,29 @@ function ab2str(buf) {\n   return decodedString;\n }\n \n-function terminalCellSize(wrapperNode, rows, cols) {\n-  const height = wrapperNode.clientHeight;\n+function terminalCellSize(wrapperNode) {\n+  // Badly guess the width/height of the row.\n+  let characterWidth = 20;\n+  let characterHeight = 20;\n \n-  // Guess the width of the row.\n-  let width = wrapperNode.clientWidth;\n   // Now try and measure the first row we find.\n-  const firstRow = wrapperNode.querySelector('.terminal div');\n-  if (!firstRow) {\n+  const subjectRow = wrapperNode.querySelector('.terminal .xterm-rows div');\n+  if (!subjectRow) {\n     log(\"ERROR: Couldn't find first row, resizing might not work very well.\");\n   } else {\n-    const rowDisplay = firstRow.style.display;\n-    firstRow.style.display = 'inline';\n-    width = firstRow.offsetWidth;\n-    firstRow.style.display = rowDisplay;\n+    const rowDisplay = subjectRow.style.display;\n+    const contentBuffer = subjectRow.innerHTML;\n+\n+    subjectRow.innerHTML = 'W';\n+    subjectRow.style.display = 'inline';\n+    characterWidth = subjectRow.getBoundingClientRect().width;\n+    subjectRow.style.display = rowDisplay;\n+    characterHeight = parseInt(subjectRow.offsetHeight, 10);\n+    subjectRow.innerHTML = contentBuffer;\n   }\n \n-  const pixelPerCol = width / cols;\n-  const pixelPerRow = height / rows;\n-\n-  log('Caculated (col, row) sizes in px: ', pixelPerCol, pixelPerRow);\n-  return {pixelPerCol, pixelPerRow};\n+  log('Caculated (charWidth, charHeight) sizes in px: ', characterWidth, characterHeight);","path":"client/app/scripts/components/terminal.js","position":49,"original_position":49,"commit_id":"487635cb62ccb3ee79c6450e371a1ec22ddd7120","original_commit_id":"487635cb62ccb3ee79c6450e371a1ec22ddd7120","user":{"login":"foot","id":22008,"avatar_url":"https://avatars.githubusercontent.com/u/22008?v=3","gravatar_id":"","url":"https://api.github.com/users/foot","html_url":"https://github.com/foot","followers_url":"https://api.github.com/users/foot/followers","following_url":"https://api.github.com/users/foot/following{/other_user}","gists_url":"https://api.github.com/users/foot/gists{/gist_id}","starred_url":"https://api.github.com/users/foot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/foot/subscriptions","organizations_url":"https://api.github.com/users/foot/orgs","repos_url":"https://api.github.com/users/foot/repos","events_url":"https://api.github.com/users/foot/events{/privacy}","received_events_url":"https://api.github.com/users/foot/received_events","type":"User","site_admin":false},"body":"I like logs.","created_at":"2016-11-03T09:17:32Z","updated_at":"2016-11-03T09:17:32Z","html_url":"https://github.com/weaveworks/scope/pull/1966#discussion_r86305570","pull_request_url":"https://api.github.com/repos/weaveworks/scope/pulls/1966","_links":{"self":{"href":"https://api.github.com/repos/weaveworks/scope/pulls/comments/86305570"},"html":{"href":"https://github.com/weaveworks/scope/pull/1966#discussion_r86305570"},"pull_request":{"href":"https://api.github.com/repos/weaveworks/scope/pulls/1966"}}},"pull_request":{"url":"https://api.github.com/repos/weaveworks/scope/pulls/1966","id":91486650,"html_url":"https://github.com/weaveworks/scope/pull/1966","diff_url":"https://github.com/weaveworks/scope/pull/1966.diff","patch_url":"https://github.com/weaveworks/scope/pull/1966.patch","issue_url":"https://api.github.com/repos/weaveworks/scope/issues/1966","number":1966,"state":"open","locked":false,"title":"Resize TTYs","user":{"login":"2opremio","id":2362916,"avatar_url":"https://avatars.githubusercontent.com/u/2362916?v=3","gravatar_id":"","url":"https://api.github.com/users/2opremio","html_url":"https://github.com/2opremio","followers_url":"https://api.github.com/users/2opremio/followers","following_url":"https://api.github.com/users/2opremio/following{/other_user}","gists_url":"https://api.github.com/users/2opremio/gists{/gist_id}","starred_url":"https://api.github.com/users/2opremio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/2opremio/subscriptions","organizations_url":"https://api.github.com/users/2opremio/orgs","repos_url":"https://api.github.com/users/2opremio/repos","events_url":"https://api.github.com/users/2opremio/events{/privacy}","received_events_url":"https://api.github.com/users/2opremio/received_events","type":"User","site_admin":false},"body":"This PR adds the possibility to resize TTYs. It adds (optional) arguments to controls and modifies the UI<->App contract in the following way:\r\n- Control requests now take optional arguments (a JSON string map)\r\n- Pipe request add an additional key in the response: `resize_tty_control` which indicates what control to use in order to resize the TTY\r\n- That control takes three (mandatory) parameters: `width`, `height` and `pipeID`\r\n\r\nHere's an example:\r\n1. The UI requests `POST http://172.16.0.3:4040/api/control/3b89ec4023a94f3e/516cc48f99788d7d6b558d4ebf3d0e3bd1d3f2eae65ceb4e405a53498ed99b45%3B%3Ccontainer%3E/docker_exec_container` to create a containter TTY\r\n2. The App responds with `{\"pipe\":\"pipe-4012265930510560261\",\"raw_tty\":true,\"resize_tty_control\":\"docker_resize_exec_tty\"}`. Note the new `resize_tty_control` field.\r\n3. We can set the terminal size by doing `curl -X POST -d '{ \"pipeID\": \"pipe-4012265930510560261\", \"height\": \"100\", \"width\": \"100\"}' http://172.16.0.3:4040/api/control/3b89ec4023a94f3e/516cc48f99788d7d6b558d4ebf3d0e3bd1d3f2eae65ceb4e405a53498ed99b45%3B%3Ccontainer%3E/docker_resize_exec_tty`\r\n4. The tty gets adjusted accordingly by the App:\r\n\r\n<img width=\"2108\" alt=\"screen shot 2016-10-29 at 13 25 20\" src=\"https://cloud.githubusercontent.com/assets/2362916/19829255/246d41de-9ddc-11e6-989d-5bd09ccc4f57.png\">\r\n\r\nTODO:\r\n- [x] Implement (3) in the UI (CC @foot )\r\n- [x] Implement resizing for host TTYs in the backend\r\n\r\nI would appreciate a design review (maybe by @tomwilkie )\r\n\r\nFixes #746.\r\nFixs #1964 \r\n","created_at":"2016-10-29T11:35:01Z","updated_at":"2016-11-03T09:17:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b0360163615675139ef9b984b84f9137951854d6","assignee":{"login":"jml","id":125674,"avatar_url":"https://avatars.githubusercontent.com/u/125674?v=3","gravatar_id":"","url":"https://api.github.com/users/jml","html_url":"https://github.com/jml","followers_url":"https://api.github.com/users/jml/followers","following_url":"https://api.github.com/users/jml/following{/other_user}","gists_url":"https://api.github.com/users/jml/gists{/gist_id}","starred_url":"https://api.github.com/users/jml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jml/subscriptions","organizations_url":"https://api.github.com/users/jml/orgs","repos_url":"https://api.github.com/users/jml/repos","events_url":"https://api.github.com/users/jml/events{/privacy}","received_events_url":"https://api.github.com/users/jml/received_events","type":"User","site_admin":false},"assignees":[{"login":"jml","id":125674,"avatar_url":"https://avatars.githubusercontent.com/u/125674?v=3","gravatar_id":"","url":"https://api.github.com/users/jml","html_url":"https://github.com/jml","followers_url":"https://api.github.com/users/jml/followers","following_url":"https://api.github.com/users/jml/following{/other_user}","gists_url":"https://api.github.com/users/jml/gists{/gist_id}","starred_url":"https://api.github.com/users/jml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jml/subscriptions","organizations_url":"https://api.github.com/users/jml/orgs","repos_url":"https://api.github.com/users/jml/repos","events_url":"https://api.github.com/users/jml/events{/privacy}","received_events_url":"https://api.github.com/users/jml/received_events","type":"User","site_admin":false},{"login":"davkal","id":859729,"avatar_url":"https://avatars.githubusercontent.com/u/859729?v=3","gravatar_id":"","url":"https://api.github.com/users/davkal","html_url":"https://github.com/davkal","followers_url":"https://api.github.com/users/davkal/followers","following_url":"https://api.github.com/users/davkal/following{/other_user}","gists_url":"https://api.github.com/users/davkal/gists{/gist_id}","starred_url":"https://api.github.com/users/davkal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davkal/subscriptions","organizations_url":"https://api.github.com/users/davkal/orgs","repos_url":"https://api.github.com/users/davkal/repos","events_url":"https://api.github.com/users/davkal/events{/privacy}","received_events_url":"https://api.github.com/users/davkal/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/weaveworks/scope/pulls/1966/commits","review_comments_url":"https://api.github.com/repos/weaveworks/scope/pulls/1966/comments","review_comment_url":"https://api.github.com/repos/weaveworks/scope/pulls/comments{/number}","comments_url":"https://api.github.com/repos/weaveworks/scope/issues/1966/comments","statuses_url":"https://api.github.com/repos/weaveworks/scope/statuses/487635cb62ccb3ee79c6450e371a1ec22ddd7120","head":{"label":"weaveworks:746-resize-ttys","ref":"746-resize-ttys","sha":"487635cb62ccb3ee79c6450e371a1ec22ddd7120","user":{"login":"weaveworks","id":9976052,"avatar_url":"https://avatars.githubusercontent.com/u/9976052?v=3","gravatar_id":"","url":"https://api.github.com/users/weaveworks","html_url":"https://github.com/weaveworks","followers_url":"https://api.github.com/users/weaveworks/followers","following_url":"https://api.github.com/users/weaveworks/following{/other_user}","gists_url":"https://api.github.com/users/weaveworks/gists{/gist_id}","starred_url":"https://api.github.com/users/weaveworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weaveworks/subscriptions","organizations_url":"https://api.github.com/users/weaveworks/orgs","repos_url":"https://api.github.com/users/weaveworks/repos","events_url":"https://api.github.com/users/weaveworks/events{/privacy}","received_events_url":"https://api.github.com/users/weaveworks/received_events","type":"Organization","site_admin":false},"repo":{"id":34659664,"name":"scope","full_name":"weaveworks/scope","owner":{"login":"weaveworks","id":9976052,"avatar_url":"https://avatars.githubusercontent.com/u/9976052?v=3","gravatar_id":"","url":"https://api.github.com/users/weaveworks","html_url":"https://github.com/weaveworks","followers_url":"https://api.github.com/users/weaveworks/followers","following_url":"https://api.github.com/users/weaveworks/following{/other_user}","gists_url":"https://api.github.com/users/weaveworks/gists{/gist_id}","starred_url":"https://api.github.com/users/weaveworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weaveworks/subscriptions","organizations_url":"https://api.github.com/users/weaveworks/orgs","repos_url":"https://api.github.com/users/weaveworks/repos","events_url":"https://api.github.com/users/weaveworks/events{/privacy}","received_events_url":"https://api.github.com/users/weaveworks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/weaveworks/scope","description":"Monitoring, visualisation & management for Docker & Kubernetes","fork":false,"url":"https://api.github.com/repos/weaveworks/scope","forks_url":"https://api.github.com/repos/weaveworks/scope/forks","keys_url":"https://api.github.com/repos/weaveworks/scope/keys{/key_id}","collaborators_url":"https://api.github.com/repos/weaveworks/scope/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/weaveworks/scope/teams","hooks_url":"https://api.github.com/repos/weaveworks/scope/hooks","issue_events_url":"https://api.github.com/repos/weaveworks/scope/issues/events{/number}","events_url":"https://api.github.com/repos/weaveworks/scope/events","assignees_url":"https://api.github.com/repos/weaveworks/scope/assignees{/user}","branches_url":"https://api.github.com/repos/weaveworks/scope/branches{/branch}","tags_url":"https://api.github.com/repos/weaveworks/scope/tags","blobs_url":"https://api.github.com/repos/weaveworks/scope/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/weaveworks/scope/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/weaveworks/scope/git/refs{/sha}","trees_url":"https://api.github.com/repos/weaveworks/scope/git/trees{/sha}","statuses_url":"https://api.github.com/repos/weaveworks/scope/statuses/{sha}","languages_url":"https://api.github.com/repos/weaveworks/scope/languages","stargazers_url":"https://api.github.com/repos/weaveworks/scope/stargazers","contributors_url":"https://api.github.com/repos/weaveworks/scope/contributors","subscribers_url":"https://api.github.com/repos/weaveworks/scope/subscribers","subscription_url":"https://api.github.com/repos/weaveworks/scope/subscription","commits_url":"https://api.github.com/repos/weaveworks/scope/commits{/sha}","git_commits_url":"https://api.github.com/repos/weaveworks/scope/git/commits{/sha}","comments_url":"https://api.github.com/repos/weaveworks/scope/comments{/number}","issue_comment_url":"https://api.github.com/repos/weaveworks/scope/issues/comments{/number}","contents_url":"https://api.github.com/repos/weaveworks/scope/contents/{+path}","compare_url":"https://api.github.com/repos/weaveworks/scope/compare/{base}...{head}","merges_url":"https://api.github.com/repos/weaveworks/scope/merges","archive_url":"https://api.github.com/repos/weaveworks/scope/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/weaveworks/scope/downloads","issues_url":"https://api.github.com/repos/weaveworks/scope/issues{/number}","pulls_url":"https://api.github.com/repos/weaveworks/scope/pulls{/number}","milestones_url":"https://api.github.com/repos/weaveworks/scope/milestones{/number}","notifications_url":"https://api.github.com/repos/weaveworks/scope/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/weaveworks/scope/labels{/name}","releases_url":"https://api.github.com/repos/weaveworks/scope/releases{/id}","deployments_url":"https://api.github.com/repos/weaveworks/scope/deployments","created_at":"2015-04-27T10:12:35Z","updated_at":"2016-11-02T07:10:46Z","pushed_at":"2016-11-03T00:58:41Z","git_url":"git://github.com/weaveworks/scope.git","ssh_url":"git@github.com:weaveworks/scope.git","clone_url":"https://github.com/weaveworks/scope.git","svn_url":"https://github.com/weaveworks/scope","homepage":"https://www.weave.works/product/weave-scope/","size":66772,"stargazers_count":868,"watchers_count":868,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":79,"mirror_url":null,"open_issues_count":275,"forks":79,"open_issues":275,"watchers":868,"default_branch":"master"}},"base":{"label":"weaveworks:master","ref":"master","sha":"654ba35be6cd696353a300a434d314bbfe99abbb","user":{"login":"weaveworks","id":9976052,"avatar_url":"https://avatars.githubusercontent.com/u/9976052?v=3","gravatar_id":"","url":"https://api.github.com/users/weaveworks","html_url":"https://github.com/weaveworks","followers_url":"https://api.github.com/users/weaveworks/followers","following_url":"https://api.github.com/users/weaveworks/following{/other_user}","gists_url":"https://api.github.com/users/weaveworks/gists{/gist_id}","starred_url":"https://api.github.com/users/weaveworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weaveworks/subscriptions","organizations_url":"https://api.github.com/users/weaveworks/orgs","repos_url":"https://api.github.com/users/weaveworks/repos","events_url":"https://api.github.com/users/weaveworks/events{/privacy}","received_events_url":"https://api.github.com/users/weaveworks/received_events","type":"Organization","site_admin":false},"repo":{"id":34659664,"name":"scope","full_name":"weaveworks/scope","owner":{"login":"weaveworks","id":9976052,"avatar_url":"https://avatars.githubusercontent.com/u/9976052?v=3","gravatar_id":"","url":"https://api.github.com/users/weaveworks","html_url":"https://github.com/weaveworks","followers_url":"https://api.github.com/users/weaveworks/followers","following_url":"https://api.github.com/users/weaveworks/following{/other_user}","gists_url":"https://api.github.com/users/weaveworks/gists{/gist_id}","starred_url":"https://api.github.com/users/weaveworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weaveworks/subscriptions","organizations_url":"https://api.github.com/users/weaveworks/orgs","repos_url":"https://api.github.com/users/weaveworks/repos","events_url":"https://api.github.com/users/weaveworks/events{/privacy}","received_events_url":"https://api.github.com/users/weaveworks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/weaveworks/scope","description":"Monitoring, visualisation & management for Docker & Kubernetes","fork":false,"url":"https://api.github.com/repos/weaveworks/scope","forks_url":"https://api.github.com/repos/weaveworks/scope/forks","keys_url":"https://api.github.com/repos/weaveworks/scope/keys{/key_id}","collaborators_url":"https://api.github.com/repos/weaveworks/scope/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/weaveworks/scope/teams","hooks_url":"https://api.github.com/repos/weaveworks/scope/hooks","issue_events_url":"https://api.github.com/repos/weaveworks/scope/issues/events{/number}","events_url":"https://api.github.com/repos/weaveworks/scope/events","assignees_url":"https://api.github.com/repos/weaveworks/scope/assignees{/user}","branches_url":"https://api.github.com/repos/weaveworks/scope/branches{/branch}","tags_url":"https://api.github.com/repos/weaveworks/scope/tags","blobs_url":"https://api.github.com/repos/weaveworks/scope/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/weaveworks/scope/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/weaveworks/scope/git/refs{/sha}","trees_url":"https://api.github.com/repos/weaveworks/scope/git/trees{/sha}","statuses_url":"https://api.github.com/repos/weaveworks/scope/statuses/{sha}","languages_url":"https://api.github.com/repos/weaveworks/scope/languages","stargazers_url":"https://api.github.com/repos/weaveworks/scope/stargazers","contributors_url":"https://api.github.com/repos/weaveworks/scope/contributors","subscribers_url":"https://api.github.com/repos/weaveworks/scope/subscribers","subscription_url":"https://api.github.com/repos/weaveworks/scope/subscription","commits_url":"https://api.github.com/repos/weaveworks/scope/commits{/sha}","git_commits_url":"https://api.github.com/repos/weaveworks/scope/git/commits{/sha}","comments_url":"https://api.github.com/repos/weaveworks/scope/comments{/number}","issue_comment_url":"https://api.github.com/repos/weaveworks/scope/issues/comments{/number}","contents_url":"https://api.github.com/repos/weaveworks/scope/contents/{+path}","compare_url":"https://api.github.com/repos/weaveworks/scope/compare/{base}...{head}","merges_url":"https://api.github.com/repos/weaveworks/scope/merges","archive_url":"https://api.github.com/repos/weaveworks/scope/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/weaveworks/scope/downloads","issues_url":"https://api.github.com/repos/weaveworks/scope/issues{/number}","pulls_url":"https://api.github.com/repos/weaveworks/scope/pulls{/number}","milestones_url":"https://api.github.com/repos/weaveworks/scope/milestones{/number}","notifications_url":"https://api.github.com/repos/weaveworks/scope/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/weaveworks/scope/labels{/name}","releases_url":"https://api.github.com/repos/weaveworks/scope/releases{/id}","deployments_url":"https://api.github.com/repos/weaveworks/scope/deployments","created_at":"2015-04-27T10:12:35Z","updated_at":"2016-11-02T07:10:46Z","pushed_at":"2016-11-03T00:58:41Z","git_url":"git://github.com/weaveworks/scope.git","ssh_url":"git@github.com:weaveworks/scope.git","clone_url":"https://github.com/weaveworks/scope.git","svn_url":"https://github.com/weaveworks/scope","homepage":"https://www.weave.works/product/weave-scope/","size":66772,"stargazers_count":868,"watchers_count":868,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":79,"mirror_url":null,"open_issues_count":275,"forks":79,"open_issues":275,"watchers":868,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/weaveworks/scope/pulls/1966"},"html":{"href":"https://github.com/weaveworks/scope/pull/1966"},"issue":{"href":"https://api.github.com/repos/weaveworks/scope/issues/1966"},"comments":{"href":"https://api.github.com/repos/weaveworks/scope/issues/1966/comments"},"review_comments":{"href":"https://api.github.com/repos/weaveworks/scope/pulls/1966/comments"},"review_comment":{"href":"https://api.github.com/repos/weaveworks/scope/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/weaveworks/scope/pulls/1966/commits"},"statuses":{"href":"https://api.github.com/repos/weaveworks/scope/statuses/487635cb62ccb3ee79c6450e371a1ec22ddd7120"}}}}
{"actor":{"display_login":"foot"}}